зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1245798: re-enable browser_social_activation.js, browser_social_chatwindowfocus.js and browser_social_contextmenu.js. r=mixedpuppy
This commit is contained in:
Родитель
3e07f6589e
Коммит
f923e76fc7
|
@ -34,11 +34,8 @@ support-files =
|
|||
skip-if = true # bug 1115131
|
||||
[browser_social_activation.js]
|
||||
[browser_social_chatwindow.js]
|
||||
skip-if = true # Bug 1245798 'document-element-inserted' is not fired for chat windows anymore, so no mozSocial
|
||||
[browser_social_chatwindow_resize.js]
|
||||
skip-if = true # Bug 1245798 'document-element-inserted' is not fired for chat windows anymore, so no mozSocial
|
||||
[browser_social_chatwindowfocus.js]
|
||||
skip-if = true # Bug 1245798 'document-element-inserted' is not fired for chat windows anymore, so no mozSocial
|
||||
[browser_social_contextmenu.js]
|
||||
skip-if = (os == 'linux' && e10s) # Bug 1072669 context menu relies on target element
|
||||
[browser_social_errorPage.js]
|
||||
|
|
|
@ -96,28 +96,29 @@ var tests = {
|
|||
let topic = e.data.topic;
|
||||
switch (topic) {
|
||||
case "got-sidebar-message":
|
||||
port.postMessage({topic: "test-chatbox-open"});
|
||||
openChatViaUser();
|
||||
break;
|
||||
case "got-chatbox-visibility":
|
||||
let selectedChat = chats.selectedChat || chats.lastElementChild;
|
||||
if (e.data.result == "hidden") {
|
||||
ok(true, "chatbox got minimized");
|
||||
chats.selectedChat.toggle();
|
||||
selectedChat.toggle();
|
||||
} else if (e.data.result == "shown") {
|
||||
ok(true, "chatbox got shown");
|
||||
// close it now
|
||||
let content = chats.selectedChat.content;
|
||||
let content = selectedChat.content;
|
||||
content.addEventListener("unload", function chatUnload() {
|
||||
content.removeEventListener("unload", chatUnload, true);
|
||||
ok(true, "got chatbox unload on close");
|
||||
next();
|
||||
}, true);
|
||||
chats.selectedChat.close();
|
||||
selectedChat.close();
|
||||
}
|
||||
break;
|
||||
case "got-chatbox-message":
|
||||
ok(true, "got chatbox message");
|
||||
ok(e.data.result == "ok", "got chatbox windowRef result: "+e.data.result);
|
||||
chats.selectedChat.toggle();
|
||||
selectedChat.toggle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +154,7 @@ var tests = {
|
|||
let topic = e.data.topic;
|
||||
switch (topic) {
|
||||
case "test-init-done":
|
||||
port.postMessage({topic: "test-chatbox-open"});
|
||||
openChatViaUser();
|
||||
break;
|
||||
case "got-chatbox-visibility":
|
||||
is(e.data.result, "shown", "chatbox shown");
|
||||
|
@ -161,12 +162,9 @@ var tests = {
|
|||
let chat = chats.selectedChat;
|
||||
ok(chat.parentNode, "chat has a parent node before it is closed");
|
||||
// ask it to close itself.
|
||||
let doc = chat.contentDocument;
|
||||
let evt = doc.createEvent("CustomEvent");
|
||||
evt.initCustomEvent("socialTest-CloseSelf", true, true, {});
|
||||
doc.documentElement.dispatchEvent(evt);
|
||||
ok(!chat.parentNode, "chat is now closed");
|
||||
next();
|
||||
let mm = chat.content.messageManager;
|
||||
mm.sendAsyncMessage("Social:CustomEvent", { name: "socialTest-CloseSelf" });
|
||||
waitForCondition(() => !chat.parentNode, next, "chat should close");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,25 +2,10 @@
|
|||
* 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/. */
|
||||
|
||||
// Is the currently opened tab focused?
|
||||
function isTabFocused() {
|
||||
let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab);
|
||||
return Services.focus.focusedWindow == tabb.contentWindow;
|
||||
}
|
||||
|
||||
function isChatFocused(chat) {
|
||||
return getChatBar()._isChatFocused(chat);
|
||||
}
|
||||
|
||||
function openChatViaUser() {
|
||||
let sidebarDoc = document.getElementById("social-sidebar-browser").contentDocument;
|
||||
let button = sidebarDoc.getElementById("chat-opener");
|
||||
// Note we must use synthesizeMouseAtCenter() rather than calling
|
||||
// .click() directly as this causes nsIDOMWindowUtils.isHandlingUserInput
|
||||
// to be true.
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, sidebarDoc.defaultView);
|
||||
}
|
||||
|
||||
function openChatViaSidebarMessage(port, data, callback) {
|
||||
port.onmessage = function (e) {
|
||||
if (e.data.topic == "chatbox-opened")
|
||||
|
@ -98,15 +83,18 @@ function test() {
|
|||
// So we load a page with an <input> field and focus that before testing.
|
||||
let url = "data:text/html;charset=utf-8," + encodeURI('<input id="theinput">');
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab(url, {skipAnimation: true});
|
||||
tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
|
||||
tab.linkedBrowser.removeEventListener("load", tabLoad, true);
|
||||
let browser = tab.linkedBrowser;
|
||||
browser.addEventListener("load", function tabLoad(event) {
|
||||
browser.removeEventListener("load", tabLoad, true);
|
||||
// before every test we focus the input field.
|
||||
let preSubTest = function(cb) {
|
||||
// XXX - when bug 604289 is fixed it should be possible to just do:
|
||||
// tab.linkedBrowser.contentWindow.focus()
|
||||
// but instead we must do:
|
||||
tab.linkedBrowser.contentDocument.getElementById("theinput").focus();
|
||||
waitForCondition(() => isTabFocused(), cb, "tab should have focus");
|
||||
ContentTask.spawn(browser, null, function* () {
|
||||
content.focus();
|
||||
content.document.getElementById("theinput").focus();
|
||||
|
||||
yield ContentTaskUtils.waitForCondition(
|
||||
() => Services.focus.focusedWindow == content, "tab should have focus");
|
||||
}).then(cb);
|
||||
}
|
||||
let postSubTest = function(cb) {
|
||||
Task.spawn(closeAllChats).then(cb);
|
||||
|
@ -136,19 +124,28 @@ var tests = {
|
|||
openChatViaSidebarMessage(port, {stealFocus: 1}, function() {
|
||||
ok(true, "got chatbox message");
|
||||
is(chatbar.childElementCount, 1, "exactly 1 chat open");
|
||||
ok(isTabFocused(), "tab should still be focused");
|
||||
// re-request the same chat via a message.
|
||||
openChatViaSidebarMessage(port, {stealFocus: 1}, function() {
|
||||
is(chatbar.childElementCount, 1, "still exactly 1 chat open");
|
||||
ok(isTabFocused(), "tab should still be focused");
|
||||
// re-request the same chat via user event.
|
||||
openChatViaUser();
|
||||
waitForCondition(() => isChatFocused(chatbar.selectedChat),
|
||||
function() {
|
||||
|
||||
let browser = gBrowser.selectedTab.linkedBrowser;
|
||||
ContentTask.spawn(browser, null, function* () {
|
||||
is(Services.focus.focusedWindow, content, "tab should still be focused");
|
||||
}).then(() => {
|
||||
// re-request the same chat via a message.
|
||||
openChatViaSidebarMessage(port, {stealFocus: 1}, function() {
|
||||
is(chatbar.childElementCount, 1, "still exactly 1 chat open");
|
||||
is(chatbar.selectedChat, chatbar.firstElementChild, "chat should be selected");
|
||||
next();
|
||||
}, "chat should be focused");
|
||||
|
||||
ContentTask.spawn(browser, null, function* () {
|
||||
is(Services.focus.focusedWindow, content, "tab should still be focused");
|
||||
}).then(() => {
|
||||
// re-request the same chat via user event.
|
||||
openChatViaUser();
|
||||
waitForCondition(() => isChatFocused(chatbar.selectedChat), function() {
|
||||
is(chatbar.childElementCount, 1, "still exactly 1 chat open");
|
||||
is(chatbar.selectedChat, chatbar.firstElementChild,
|
||||
"chat should be selected");
|
||||
next();
|
||||
}, "chat should be focused");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -161,8 +158,7 @@ var tests = {
|
|||
let chatbar = getChatBar();
|
||||
openChatViaUser();
|
||||
ok(chatbar.firstElementChild, "chat opened");
|
||||
waitForCondition(() => isChatFocused(chatbar.selectedChat),
|
||||
function() {
|
||||
waitForCondition(() => isChatFocused(chatbar.selectedChat), function() {
|
||||
is(chatbar.selectedChat, chatbar.firstElementChild, "chat is selected");
|
||||
next();
|
||||
}, "chat should be focused");
|
||||
|
|
|
@ -658,6 +658,15 @@ function closeAllChats() {
|
|||
}
|
||||
}
|
||||
|
||||
function openChatViaUser() {
|
||||
let sidebarDoc = document.getElementById("social-sidebar-browser").contentDocument;
|
||||
let button = sidebarDoc.getElementById("chat-opener");
|
||||
// Note we must use synthesizeMouseAtCenter() rather than calling
|
||||
// .click() directly as this causes nsIDOMWindowUtils.isHandlingUserInput
|
||||
// to be true.
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, sidebarDoc.defaultView);
|
||||
}
|
||||
|
||||
|
||||
// Support for going on and offline.
|
||||
// (via browser/base/content/test/browser_bookmark_titles.js)
|
||||
|
|
|
@ -20,14 +20,9 @@
|
|||
if (data && data.id) {
|
||||
url = url + "?id="+data.id;
|
||||
}
|
||||
navigator.mozSocial.openChatWindow(url, function(chatwin) {
|
||||
// Note that the following .focus() call should *not* arrange
|
||||
// to steal focus - see browser_social_chatwindowfocus.js
|
||||
if (data && data.stealFocus && chatwin) {
|
||||
chatwin.focus();
|
||||
}
|
||||
navigator.mozSocial.openChatWindow(url, function(success) {
|
||||
port.postMessage({topic: "chatbox-opened",
|
||||
result: chatwin ? "ok" : "failed"});
|
||||
result: success ? "ok" : "failed"});
|
||||
});
|
||||
break;
|
||||
case "test-isVisible":
|
||||
|
|
|
@ -145,7 +145,15 @@ function attachToWindow(provider, targetWindow) {
|
|||
writable: true,
|
||||
value: function(toURL, callback) {
|
||||
let url = targetWindow.document.documentURIObject.resolve(toURL);
|
||||
openChatWindow(targetWindow, provider, url, callback);
|
||||
let dwu = getChromeWindow(targetWindow)
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
openChatWindow(targetWindow, provider, url, chatWin => {
|
||||
if (chatWin && dwu.isHandlingUserInput)
|
||||
chatWin.focus();
|
||||
if (callback)
|
||||
callback(!!chatWin);
|
||||
});
|
||||
}
|
||||
},
|
||||
openPanel: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче