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