зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1270943 - fix e10s issues in browser_focus.js mochitest and enable all chat tests, for sure this time. r=mixedpuppy
This commit is contained in:
Родитель
3bc2440a04
Коммит
eee09d89ec
|
@ -1,5 +1,5 @@
|
|||
[DEFAULT]
|
||||
skip-if = buildapp == 'mulet' || e10s # Bug 1270943
|
||||
skip-if = buildapp == 'mulet'
|
||||
support-files =
|
||||
head.js
|
||||
chat.html
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/Promise.jsm", this);
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
var chatbar = document.getElementById("pinnedchats");
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Tests the focus functionality.
|
||||
|
||||
Components.utils.import("resource://gre/modules/Promise.jsm", this);
|
||||
Cu.import("resource://testing-common/ContentTask.jsm", this);
|
||||
const CHAT_URL = "https://example.com/browser/browser/base/content/test/chat/chat.html";
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
@ -33,9 +33,12 @@ function* setUp() {
|
|||
// So we load a page with an <input> field and focus that before testing.
|
||||
let html = '<input id="theinput"><button id="chat-opener"></button>';
|
||||
let url = "data:text/html;charset=utf-8," + encodeURI(html);
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(url, {skipAnimation: true});
|
||||
yield promiseOneEvent(tab.linkedBrowser, "load", true);
|
||||
tab.linkedBrowser.contentDocument.getElementById("theinput").focus();
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, url);
|
||||
let browser = tab.linkedBrowser;
|
||||
yield ContentTask.spawn(browser, null, function* () {
|
||||
content.document.getElementById("theinput").focus();
|
||||
});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
@ -62,10 +65,11 @@ add_chat_task(function* testDefaultFocusUserInput() {
|
|||
let browser = gBrowser.selectedTab.linkedBrowser;
|
||||
let mm = browser.messageManager;
|
||||
|
||||
let deferred = Promise.defer();
|
||||
mm.addMessageListener("ChatOpenerClicked", function handler() {
|
||||
mm.removeMessageListener("ChatOpenerClicked", handler);
|
||||
promiseOpenChat("http://example.com").then(chat => deferred.resolve(chat));
|
||||
let promise = new Promise(resolve => {
|
||||
mm.addMessageListener("ChatOpenerClicked", function handler() {
|
||||
mm.removeMessageListener("ChatOpenerClicked", handler);
|
||||
promiseOpenChat("http://example.com").then(resolve);
|
||||
});
|
||||
});
|
||||
|
||||
yield ContentTask.spawn(browser, null, function* () {
|
||||
|
@ -79,7 +83,7 @@ add_chat_task(function* testDefaultFocusUserInput() {
|
|||
// .click() directly as this causes nsIDOMWindowUtils.isHandlingUserInput
|
||||
// to be true.
|
||||
yield BrowserTestUtils.synthesizeMouseAtCenter("#chat-opener", {}, browser);
|
||||
let chat = yield deferred.promise;
|
||||
let chat = yield promise;
|
||||
|
||||
// we use the default focus behaviour but the chat was opened via user input,
|
||||
// so the chat should be focused.
|
||||
|
@ -241,10 +245,10 @@ add_chat_task(function* testFocusedElement() {
|
|||
content.document.getElementById("input2").focus();
|
||||
});
|
||||
|
||||
// set focus to the tab.
|
||||
// set focus to the main window.
|
||||
let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab);
|
||||
let promise = promiseOneEvent(tabb.contentWindow, "focus");
|
||||
Services.focus.moveFocus(tabb.contentWindow, null, Services.focus.MOVEFOCUS_ROOT, 0);
|
||||
let promise = promiseOneEvent(window, "focus");
|
||||
Services.focus.moveFocus(window, null, Services.focus.MOVEFOCUS_ROOT, 0);
|
||||
yield promise;
|
||||
|
||||
promise = promiseOneMessage(chat.content, "Social:FocusEnsured");
|
||||
|
|
|
@ -2,30 +2,28 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/Promise.jsm", this);
|
||||
|
||||
var chatbar = document.getElementById("pinnedchats");
|
||||
|
||||
function promiseNewWindowLoaded() {
|
||||
let deferred = Promise.defer();
|
||||
Services.wm.addListener({
|
||||
onWindowTitleChange: function() {},
|
||||
onCloseWindow: function(xulwindow) {},
|
||||
onOpenWindow: function(xulwindow) {
|
||||
var domwindow = xulwindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||
Services.wm.removeListener(this);
|
||||
// wait for load to ensure the window is ready for us to test
|
||||
domwindow.addEventListener("load", function _load(event) {
|
||||
let doc = domwindow.document;
|
||||
if (event.target != doc)
|
||||
return;
|
||||
domwindow.removeEventListener("load", _load);
|
||||
deferred.resolve(domwindow);
|
||||
});
|
||||
},
|
||||
return new Promise(resolve => {
|
||||
Services.wm.addListener({
|
||||
onWindowTitleChange: function() {},
|
||||
onCloseWindow: function(xulwindow) {},
|
||||
onOpenWindow: function(xulwindow) {
|
||||
var domwindow = xulwindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindow);
|
||||
Services.wm.removeListener(this);
|
||||
// wait for load to ensure the window is ready for us to test
|
||||
domwindow.addEventListener("load", function _load(event) {
|
||||
let doc = domwindow.document;
|
||||
if (event.target != doc)
|
||||
return;
|
||||
domwindow.removeEventListener("load", _load);
|
||||
resolve(domwindow);
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
add_chat_task(function* testTearoffChat() {
|
||||
|
|
|
@ -11,28 +11,28 @@ function promiseOpenChat(url, mode, focus, buttonSet = null) {
|
|||
let uri = Services.io.newURI(url, null, null);
|
||||
let origin = uri.prePath;
|
||||
let title = origin;
|
||||
let deferred = Promise.defer();
|
||||
// we just through a few hoops to ensure the content document is fully
|
||||
// loaded, otherwise tests that rely on that content may intermittently fail.
|
||||
let callback = function(chatbox) {
|
||||
let mm = chatbox.content.messageManager;
|
||||
mm.sendAsyncMessage("WaitForDOMContentLoaded");
|
||||
mm.addMessageListener("DOMContentLoaded", function cb() {
|
||||
mm.removeMessageListener("DOMContentLoaded", cb);
|
||||
deferred.resolve(chatbox);
|
||||
});
|
||||
}
|
||||
let chatbox = Chat.open(null, {
|
||||
origin: origin,
|
||||
title: title,
|
||||
url: url,
|
||||
mode: mode,
|
||||
focus: focus
|
||||
}, callback);
|
||||
if (buttonSet) {
|
||||
chatbox.setAttribute("buttonSet", buttonSet);
|
||||
}
|
||||
return deferred.promise;
|
||||
return new Promise(resolve => {
|
||||
// we just through a few hoops to ensure the content document is fully
|
||||
// loaded, otherwise tests that rely on that content may intermittently fail.
|
||||
let callback = function(chatbox) {
|
||||
let mm = chatbox.content.messageManager;
|
||||
mm.sendAsyncMessage("WaitForDOMContentLoaded");
|
||||
mm.addMessageListener("DOMContentLoaded", function cb() {
|
||||
mm.removeMessageListener("DOMContentLoaded", cb);
|
||||
resolve(chatbox);
|
||||
});
|
||||
}
|
||||
let chatbox = Chat.open(null, {
|
||||
origin: origin,
|
||||
title: title,
|
||||
url: url,
|
||||
mode: mode,
|
||||
focus: focus
|
||||
}, callback);
|
||||
if (buttonSet) {
|
||||
chatbox.setAttribute("buttonSet", buttonSet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Opens a chat, returns a promise resolved when the chat callback fired.
|
||||
|
@ -40,26 +40,20 @@ function promiseOpenChatCallback(url, mode) {
|
|||
let uri = Services.io.newURI(url, null, null);
|
||||
let origin = uri.prePath;
|
||||
let title = origin;
|
||||
let deferred = Promise.defer();
|
||||
let callback = deferred.resolve;
|
||||
Chat.open(null, {
|
||||
origin: origin,
|
||||
title: title,
|
||||
url: url,
|
||||
mode: mode
|
||||
}, callback);
|
||||
return deferred.promise;
|
||||
return new Promise(resolve => {
|
||||
Chat.open(null, { origin, title, url, mode }, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
// Opens a chat, returns the chat window's promise which fires when the chat
|
||||
// starts loading.
|
||||
function promiseOneEvent(target, eventName, capture) {
|
||||
let deferred = Promise.defer();
|
||||
target.addEventListener(eventName, function handler(event) {
|
||||
target.removeEventListener(eventName, handler, capture);
|
||||
deferred.resolve();
|
||||
}, capture);
|
||||
return deferred.promise;
|
||||
return new Promise(resolve => {
|
||||
target.addEventListener(eventName, function handler(event) {
|
||||
target.removeEventListener(eventName, handler, capture);
|
||||
resolve();
|
||||
}, capture);
|
||||
});
|
||||
}
|
||||
|
||||
function promiseOneMessage(target, messageName) {
|
||||
|
@ -79,9 +73,7 @@ function numChatsInWindow(win) {
|
|||
}
|
||||
|
||||
function promiseWaitForFocus() {
|
||||
let deferred = Promise.defer();
|
||||
waitForFocus(deferred.resolve);
|
||||
return deferred.promise;
|
||||
return new Promise(resolve => waitForFocus(resolve));
|
||||
}
|
||||
|
||||
// A simple way to clean up after each test.
|
||||
|
|
Загрузка…
Ссылка в новой задаче