deleted file mode 100644
--- a/browser/base/content/test/chat/.eslintrc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "extends": [
- "../../../../../testing/mochitest/browser.eslintrc"
- ]
-}
deleted file mode 100644
--- a/browser/base/content/test/chat/browser.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[DEFAULT]
-skip-if = buildapp == 'mulet'
-support-files =
- head.js
- chat.html
-
-[browser_chatwindow.js]
-[browser_focus.js]
-[browser_tearoff.js]
deleted file mode 100644
--- a/browser/base/content/test/chat/browser_chatwindow.js
+++ /dev/null
@@ -1,197 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-requestLongerTimeout(2);
-
-var chatbar = document.getElementById("pinnedchats");
-
-add_chat_task(function* testOpenCloseChat() {
- let chatbox = yield promiseOpenChat("http://example.com");
- Assert.strictEqual(chatbox, chatbar.selectedChat);
- // we requested a "normal" chat, so shouldn't be minimized
- Assert.ok(!chatbox.minimized, "chat is not minimized");
- Assert.equal(chatbar.childNodes.length, 1, "should be 1 chat open");
-
-
- // now request the same URL again - we should get the same chat.
- let chatbox2 = yield promiseOpenChat("http://example.com");
- Assert.strictEqual(chatbox2, chatbox, "got the same chat");
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
-
- chatbox.toggle();
- is(chatbox.minimized, true, "chat is now minimized");
- // was no other chat to select, so selected becomes null.
- is(chatbar.selectedChat, null);
-
- // We check the content gets an unload event as we close it.
- chatbox.close();
-});
-
-// In this case we open a chat minimized, then request the same chat again
-// without specifying minimized. On that second call the chat should open,
-// selected, and no longer minimized.
-add_chat_task(function* testMinimized() {
- let chatbox = yield promiseOpenChat("http://example.com", "minimized");
- Assert.strictEqual(chatbox, chatbar.selectedChat);
- Assert.ok(chatbox.minimized, "chat is minimized");
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
- yield promiseOpenChat("http://example.com");
- Assert.ok(!chatbox.minimized, false, "chat is no longer minimized");
-});
-
-// open enough chats to overflow the window, then check
-// if the menupopup is visible
-add_chat_task(function* testManyChats() {
- Assert.ok(chatbar.menupopup.parentNode.collapsed, "popup nub collapsed at start");
- // we should *never* find a test box that needs more than this to cause
- // an overflow!
- let maxToOpen = 20;
- let numOpened = 0;
- for (let i = 0; i < maxToOpen; i++) {
- yield promiseOpenChat("http://example.com#" + i);
- if (!chatbar.menupopup.parentNode.collapsed) {
- info("the menu popup appeared");
- return;
- }
- }
- Assert.ok(false, "We didn't find a collapsed chat after " + maxToOpen + "chats!");
-});
-
-// Check that closeAll works as expected.
-add_chat_task(function* testOpenTwiceCallbacks() {
- yield promiseOpenChat("http://example.com#1");
- yield promiseOpenChat("http://example.com#2");
- yield promiseOpenChat("http://test2.example.com");
- Assert.equal(numChatsInWindow(window), 3, "should be 3 chats open");
- Chat.closeAll("http://example.com");
- Assert.equal(numChatsInWindow(window), 1, "should have closed 2 chats");
- Chat.closeAll("http://test2.example.com");
- Assert.equal(numChatsInWindow(window), 0, "should have closed last chat");
-});
-
-// Check that when we open the same chat twice, the callbacks are called back
-// twice.
-add_chat_task(function* testOpenTwiceCallbacks() {
- yield promiseOpenChatCallback("http://example.com");
- yield promiseOpenChatCallback("http://example.com");
-});
-
-// Bug 817782 - check chats work in new top-level windows.
-add_chat_task(function* testSecondTopLevelWindow() {
- const chatUrl = "http://example.com";
- let winPromise = BrowserTestUtils.waitForNewWindow();
- OpenBrowserWindow();
- let secondWindow = yield winPromise;
- yield promiseOpenChat(chatUrl);
- // the chat was created - let's make sure it was created in the second window.
- Assert.equal(numChatsInWindow(window), 0, "main window has no chats");
- Assert.equal(numChatsInWindow(secondWindow), 1, "second window has 1 chat");
- secondWindow.close();
-});
-
-// Test that findChromeWindowForChats() returns the expected window.
-add_chat_task(function* testChatWindowChooser() {
- let chat = yield promiseOpenChat("http://example.com");
- Assert.equal(numChatsInWindow(window), 1, "first window has the chat");
- // create a second window - this will be the "most recent" and will
- // therefore be the window that hosts the new chat (see bug 835111)
- let secondWindow = OpenBrowserWindow();
- yield promiseOneEvent(secondWindow, "load");
- Assert.equal(secondWindow, Chat.findChromeWindowForChats(null), "Second window is the preferred chat window");
-
- // focus the first window, and check it will be selected for future chats.
- // Bug 1090633 - there are lots of issues around focus, especially when the
- // browser itself doesn't have focus. We can end up with
- // Services.wm.getMostRecentWindow("navigator:browser") returning a different
- // window than, say, Services.focus.activeWindow. But the focus manager isn't
- // the point of this test.
- // So we simply keep focusing the first window until it is reported as the
- // most recent.
- do {
- dump("trying to force window to become the most recent.\n");
- secondWindow.focus();
- window.focus();
- yield promiseWaitForFocus();
- } while (Services.wm.getMostRecentWindow("navigator:browser") != window)
-
- Assert.equal(window, Chat.findChromeWindowForChats(null), "First window now the preferred chat window");
-
- let privateWindow = OpenBrowserWindow({private: true});
- yield promiseOneEvent(privateWindow, "load")
-
- // The focused window can't accept chats (it's a private window), so the
- // chat should open in the window that was selected before. This will be
- // either window or secondWindow (linux may choose a different one) but the
- // point is that the window is *not* the private one.
- Assert.ok(Chat.findChromeWindowForChats(null) == window ||
- Chat.findChromeWindowForChats(null) == secondWindow,
- "Private window isn't selected for new chats.");
- privateWindow.close();
- secondWindow.close();
-});
-
-add_chat_task(function* testButtonSet() {
- let chatbox = yield promiseOpenChat("http://example.com#1");
- let document = chatbox.ownerDocument;
-
- // Expect all default buttons to be visible.
- for (let buttonId of kDefaultButtonSet) {
- let button = document.getAnonymousElementByAttribute(chatbox, "anonid", buttonId);
- Assert.ok(!button.hidden, "Button '" + buttonId + "' should be visible");
- }
-
- let visible = new Set(["minimize", "close"]);
- chatbox = yield promiseOpenChat("http://example.com#2", null, null, [...visible].join(","));
-
- for (let buttonId of kDefaultButtonSet) {
- let button = document.getAnonymousElementByAttribute(chatbox, "anonid", buttonId);
- if (visible.has(buttonId)) {
- Assert.ok(!button.hidden, "Button '" + buttonId + "' should be visible");
- } else {
- Assert.ok(button.hidden, "Button '" + buttonId + "' should NOT be visible");
- }
- }
-});
-
-add_chat_task(function* testCustomButton() {
- let commanded = 0;
- let customButton = {
- id: "custom",
- onCommand: function() {
- ++commanded;
- }
- };
-
- Chat.registerButton(customButton);
-
- let chatbox = yield promiseOpenChat("http://example.com#1");
- let document = chatbox.ownerDocument;
- let titlebarNode = document.getAnonymousElementByAttribute(chatbox, "class",
- "chat-titlebar");
-
- Assert.equal(titlebarNode.getElementsByClassName("chat-custom")[0], null,
- "Custom chat button should not be in the toolbar yet.");
-
- let visible = new Set(["minimize", "close", "custom"]);
- Chat.loadButtonSet(chatbox, [...visible].join(","));
-
- for (let buttonId of kDefaultButtonSet) {
- let button = document.getAnonymousElementByAttribute(chatbox, "anonid", buttonId);
- if (visible.has(buttonId)) {
- Assert.ok(!button.hidden, "Button '" + buttonId + "' should be visible");
- } else {
- Assert.ok(button.hidden, "Button '" + buttonId + "' should NOT be visible");
- }
- }
-
- let customButtonNode = titlebarNode.getElementsByClassName("chat-custom")[0];
- Assert.ok(!customButtonNode.hidden, "Custom button should be visible");
-
- let ev = document.createEvent("XULCommandEvent");
- ev.initCommandEvent("command", true, true, document.defaultView, 0, false,
- false, false, false, null);
- customButtonNode.dispatchEvent(ev);
-
- Assert.equal(commanded, 1, "Button should have been commanded once");
-});
deleted file mode 100644
--- a/browser/base/content/test/chat/browser_focus.js
+++ /dev/null
@@ -1,262 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-// Tests the focus functionality.
-
-Cu.import("resource://testing-common/ContentTask.jsm", this);
-const CHAT_URL = "https://example.com/browser/browser/base/content/test/chat/chat.html";
-
-requestLongerTimeout(2);
-
-// Is the currently opened tab focused?
-function isTabFocused() {
- let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab);
- // focus sucks in tests - our window may have lost focus.
- let elt = Services.focus.getFocusedElementForWindow(window, false, {});
- return elt == tabb;
-}
-
-// Is the specified chat focused?
-function isChatFocused(chat) {
- // focus sucks in tests - our window may have lost focus.
- let elt = Services.focus.getFocusedElementForWindow(window, false, {});
- return elt == chat.content;
-}
-
-var chatbar = document.getElementById("pinnedchats");
-
-function* setUp() {
- // Note that (probably) due to bug 604289, if a tab is focused but the
- // focused element is null, our chat windows can "steal" focus. This is
- // avoided if we explicitly focus an element in the tab.
- // 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 = 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);
- });
-}
-
-// Test default focus - not user input.
-add_chat_task(function* testDefaultFocus() {
- yield setUp();
- let chat = yield promiseOpenChat("http://example.com");
- // we used the default focus behaviour, which means that because this was
- // not the direct result of user action the chat should not be focused.
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
- Assert.ok(isTabFocused(), "the tab should remain focused.");
- Assert.ok(!isChatFocused(chat), "the chat should not be focused.");
-});
-
-// Test default focus via user input.
-add_chat_task(function* testDefaultFocusUserInput() {
- todo(false, "BrowserTestUtils.synthesizeMouseAtCenter doesn't move the user " +
- "focus to the chat window, even though we're recording a click correctly.");
- return;
-
- yield setUp();
- let browser = gBrowser.selectedTab.linkedBrowser;
- let mm = browser.messageManager;
-
- 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* () {
- let button = content.document.getElementById("chat-opener");
- button.addEventListener("click", function onclick() {
- button.removeEventListener("click", onclick);
- sendAsyncMessage("ChatOpenerClicked");
- });
- });
- // Note we must use synthesizeMouseAtCenter() rather than calling
- // .click() directly as this causes nsIDOMWindowUtils.isHandlingUserInput
- // to be true.
- yield BrowserTestUtils.synthesizeMouseAtCenter("#chat-opener", {}, browser);
- let chat = yield promise;
-
- // we use the default focus behaviour but the chat was opened via user input,
- // so the chat should be focused.
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
- yield promiseWaitForCondition(() => !isTabFocused());
- Assert.ok(!isTabFocused(), "the tab should have lost focus.");
- Assert.ok(isChatFocused(chat), "the chat should have got focus.");
-});
-
-// We explicitly ask for the chat to be focused.
-add_chat_task(function* testExplicitFocus() {
- yield setUp();
- let chat = yield promiseOpenChat("http://example.com", undefined, true);
- // we use the default focus behaviour, which means that because this was
- // not the direct result of user action the chat should not be focused.
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
- yield promiseWaitForCondition(() => !isTabFocused());
- Assert.ok(!isTabFocused(), "the tab should have lost focus.");
- Assert.ok(isChatFocused(chat), "the chat should have got focus.");
-});
-
-// Open a minimized chat via default focus behaviour - it will open and not
-// have focus. Then open the same chat without 'minimized' - it will be
-// restored but should still not have grabbed focus.
-add_chat_task(function* testNoFocusOnAutoRestore() {
- yield setUp();
- let chat = yield promiseOpenChat("http://example.com", "minimized");
- Assert.ok(chat.minimized, "chat is minimized");
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
- Assert.ok(isTabFocused(), "the tab should remain focused.");
- Assert.ok(!isChatFocused(chat), "the chat should not be focused.");
- yield promiseOpenChat("http://example.com");
- Assert.ok(!chat.minimized, "chat should be restored");
- Assert.ok(isTabFocused(), "the tab should remain focused.");
- Assert.ok(!isChatFocused(chat), "the chat should not be focused.");
-});
-
-// Here we open a chat, which will not be focused. Then we minimize it and
-// restore it via a titlebar clock - it should get focus at that point.
-add_chat_task(function* testFocusOnExplicitRestore() {
- yield setUp();
- let chat = yield promiseOpenChat("http://example.com");
- Assert.ok(!chat.minimized, "chat should have been opened restored");
- Assert.ok(isTabFocused(), "the tab should remain focused.");
- Assert.ok(!isChatFocused(chat), "the chat should not be focused.");
- chat.minimized = true;
- Assert.ok(isTabFocused(), "tab should still be focused");
- Assert.ok(!isChatFocused(chat), "the chat should not be focused.");
-
- let promise = promiseOneMessage(chat.content, "Social:FocusEnsured");
- // pretend we clicked on the titlebar
- chat.onTitlebarClick({button: 0});
- yield promise; // wait for focus event.
- Assert.ok(!chat.minimized, "chat should have been restored");
- Assert.ok(isChatFocused(chat), "chat should be focused");
- Assert.strictEqual(chat, chatbar.selectedChat, "chat is marked selected");
-});
-
-// Open 2 chats and give 1 focus. Minimize the focused one - the second
-// should get focus.
-add_chat_task(function* testMinimizeFocused() {
- yield setUp();
- let chat1 = yield promiseOpenChat("http://example.com#1");
- let chat2 = yield promiseOpenChat("http://example.com#2");
- Assert.equal(numChatsInWindow(window), 2, "2 chats open");
- Assert.strictEqual(chatbar.selectedChat, chat2, "chat2 is selected");
- let promise = promiseOneMessage(chat1.content, "Social:FocusEnsured");
- chatbar.selectedChat = chat1;
- chatbar.focus();
- yield promise; // wait for chat1 to get focus.
- Assert.strictEqual(chat1, chatbar.selectedChat, "chat1 is marked selected");
- Assert.notStrictEqual(chat2, chatbar.selectedChat, "chat2 is not marked selected");
-
- todo(false, "Bug 1245803 should re-enable the test below to have a chat window " +
- "re-gain focus when another chat window is minimized.");
- return;
-
- promise = promiseOneMessage(chat2.content, "Social:FocusEnsured");
- chat1.minimized = true;
- yield promise; // wait for chat2 to get focus.
- Assert.notStrictEqual(chat1, chatbar.selectedChat, "chat1 is not marked selected");
- Assert.strictEqual(chat2, chatbar.selectedChat, "chat2 is marked selected");
-});
-
-// Open 2 chats, select and focus the second. Pressing the TAB key should
-// cause focus to move between all elements in our chat window before moving
-// to the next chat window.
-add_chat_task(function* testTab() {
- yield setUp();
-
- function sendTabAndWaitForFocus(chat, eltid) {
- EventUtils.sendKey("tab");
-
- return ContentTask.spawn(chat.content, { eltid: eltid }, function* (args) {
- let doc = content.document;
-
- // ideally we would use the 'focus' event here, but that doesn't work
- // as expected for the iframe - the iframe itself never gets the focus
- // event (apparently the sub-document etc does.)
- // So just poll for the correct element getting focus...
- yield new Promise(function(resolve, reject) {
- let tries = 0;
- let interval = content.setInterval(function() {
- if (tries >= 30) {
- clearInterval(interval);
- reject("never got focus");
- return;
- }
- tries++;
- let elt = args.eltid ? doc.getElementById(args.eltid) : doc.documentElement;
- if (doc.activeElement == elt) {
- content.clearInterval(interval);
- resolve();
- }
- info("retrying wait for focus: " + tries);
- info("(the active element is " + doc.activeElement + "/" +
- doc.activeElement.getAttribute("id") + ")");
- }, 100);
- info("waiting for element " + args.eltid + " to get focus");
- });
- });
- }
-
- let chat1 = yield promiseOpenChat(CHAT_URL + "#1");
- let chat2 = yield promiseOpenChat(CHAT_URL + "#2");
- chatbar.selectedChat = chat2;
- let promise = promiseOneMessage(chat2.content, "Social:FocusEnsured");
- chatbar.focus();
- info("waiting for second chat to get focus");
- yield promise;
-
- // Our chats have 3 focusable elements, so it takes 4 TABs to move
- // to the new chat.
- yield sendTabAndWaitForFocus(chat2, "input1");
- Assert.ok(isChatFocused(chat2), "new chat still focused after first tab");
-
- yield sendTabAndWaitForFocus(chat2, "input2");
- Assert.ok(isChatFocused(chat2), "new chat still focused after tab");
-
- yield sendTabAndWaitForFocus(chat2, "iframe");
- Assert.ok(isChatFocused(chat2), "new chat still focused after tab");
-
- // this tab now should move to the next chat, but focus the
- // document element itself (hence the null eltid)
- yield sendTabAndWaitForFocus(chat1, null);
- Assert.ok(isChatFocused(chat1), "first chat is focused");
-});
-
-// Open a chat and focus an element other than the first. Move focus to some
-// other item (the tab itself in this case), then focus the chatbar - the
-// same element that was previously focused should still have focus.
-add_chat_task(function* testFocusedElement() {
- yield setUp();
-
- // open a chat with focus requested.
- let chat = yield promiseOpenChat(CHAT_URL, undefined, true);
-
- yield ContentTask.spawn(chat.content, null, function* () {
- content.document.getElementById("input2").focus();
- });
-
- // set focus to the main window.
- let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab);
- let promise = promiseOneEvent(window, "focus");
- Services.focus.moveFocus(window, null, Services.focus.MOVEFOCUS_ROOT, 0);
- yield promise;
-
- promise = promiseOneMessage(chat.content, "Social:FocusEnsured");
- chatbar.focus();
- yield promise;
-
- yield ContentTask.spawn(chat.content, null, function* () {
- Assert.equal(content.document.activeElement.getAttribute("id"), "input2",
- "correct input field still has focus");
- });
-});
deleted file mode 100644
--- a/browser/base/content/test/chat/browser_tearoff.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-var chatbar = document.getElementById("pinnedchats");
-
-function promiseNewWindowLoaded() {
- 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);
- });
- },
- });
- });
-}
-
-add_chat_task(function* testTearoffChat() {
- let chatbox = yield promiseOpenChat("http://example.com");
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
-
- let chatTitle = yield ContentTask.spawn(chatbox.content, null, function* () {
- let chatDoc = content.document;
-
- // Mutate the chat document a bit before we tear it off.
- let div = chatDoc.createElement("div");
- div.setAttribute("id", "testdiv");
- div.setAttribute("test", "1");
- chatDoc.body.appendChild(div);
-
- return chatDoc.title;
- });
-
- Assert.equal(chatbox.getAttribute("label"), chatTitle,
- "the new chatbox should show the title of the chat window");
-
- // chatbox is open, lets detach. The new chat window will be caught in
- // the window watcher below
- let promise = promiseNewWindowLoaded();
-
- let swap = document.getAnonymousElementByAttribute(chatbox, "anonid", "swap");
- swap.click();
-
- // and wait for the new window.
- let domwindow = yield promise;
-
- Assert.equal(domwindow.document.documentElement.getAttribute("windowtype"), "Social:Chat", "Social:Chat window opened");
- Assert.equal(numChatsInWindow(window), 0, "should be no chats in the chat bar");
-
- // get the chatbox from the new window.
- chatbox = domwindow.document.getElementById("chatter")
- Assert.equal(chatbox.getAttribute("label"), chatTitle, "window should have same title as chat");
-
- yield ContentTask.spawn(chatbox.content, null, function* () {
- let div = content.document.getElementById("testdiv");
- Assert.equal(div.getAttribute("test"), "1", "docshell should have been swapped");
- div.setAttribute("test", "2");
- });
-
- // swap the window back to the chatbar
- promise = promiseOneEvent(domwindow, "unload");
- swap = domwindow.document.getAnonymousElementByAttribute(chatbox, "anonid", "swap");
- swap.click();
-
- yield promise;
-
- Assert.equal(numChatsInWindow(window), 1, "chat should be docked back in the window");
- chatbox = chatbar.selectedChat;
- Assert.equal(chatbox.getAttribute("label"), chatTitle,
- "the new chatbox should show the title of the chat window again");
-
- yield ContentTask.spawn(chatbox.content, null, function* () {
- let div = content.document.getElementById("testdiv");
- Assert.equal(div.getAttribute("test"), "2", "docshell should have been swapped");
- });
-});
-
-// Similar test but with 2 chats.
-add_chat_task(function* testReattachTwice() {
- let chatbox1 = yield promiseOpenChat("http://example.com#1");
- let chatbox2 = yield promiseOpenChat("http://example.com#2");
- Assert.equal(numChatsInWindow(window), 2, "both chats should be docked in the window");
-
- info("chatboxes are open, detach from window");
- let promise = promiseNewWindowLoaded();
- document.getAnonymousElementByAttribute(chatbox1, "anonid", "swap").click();
- let domwindow1 = yield promise;
- chatbox1 = domwindow1.document.getElementById("chatter");
- Assert.equal(numChatsInWindow(window), 1, "only second chat should be docked in the window");
-
- promise = promiseNewWindowLoaded();
- document.getAnonymousElementByAttribute(chatbox2, "anonid", "swap").click();
- let domwindow2 = yield promise;
- chatbox2 = domwindow2.document.getElementById("chatter");
- Assert.equal(numChatsInWindow(window), 0, "should be no docked chats");
-
- promise = promiseOneEvent(domwindow2, "unload");
- domwindow2.document.getAnonymousElementByAttribute(chatbox2, "anonid", "swap").click();
- yield promise;
- Assert.equal(numChatsInWindow(window), 1, "one chat should be docked back in the window");
-
- promise = promiseOneEvent(domwindow1, "unload");
- domwindow1.document.getAnonymousElementByAttribute(chatbox1, "anonid", "swap").click();
- yield promise;
- Assert.equal(numChatsInWindow(window), 2, "both chats should be docked back in the window");
-});
-
-// Check that Chat.closeAll() also closes detached windows.
-add_chat_task(function* testCloseAll() {
- let chatbox1 = yield promiseOpenChat("http://example.com#1");
- let chatbox2 = yield promiseOpenChat("http://example.com#2");
-
- let promise = promiseNewWindowLoaded();
- document.getAnonymousElementByAttribute(chatbox1, "anonid", "swap").click();
- let domwindow = yield promise;
- chatbox1 = domwindow.document.getElementById("chatter");
-
- let promiseWindowUnload = promiseOneEvent(domwindow, "unload");
-
- Assert.equal(numChatsInWindow(window), 1, "second chat should still be docked");
- Chat.closeAll("http://example.com");
- yield promiseWindowUnload;
- Assert.equal(numChatsInWindow(window), 0, "should be no chats left");
-});
deleted file mode 100644
--- a/browser/base/content/test/chat/chat.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
- <head>
- <meta charset="utf-8">
- <title>test chat window</title>
- </head>
- <body>
- <p>This is a test chat window.</p>
- <!-- a couple of input fields to help with focus testing -->
- <input id="input1"/>
- <input id="input2"/>
- <!-- an iframe here so this one page generates multiple load events -->
- <iframe id="iframe" src="data:text/plain:this is an iframe"></iframe>
- </body>
-</html>
deleted file mode 100644
--- a/browser/base/content/test/chat/head.js
+++ /dev/null
@@ -1,130 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-// Utility functions for Chat tests.
-
-var Chat = Cu.import("resource:///modules/Chat.jsm", {}).Chat;
-const kDefaultButtonSet = new Set(["minimize", "swap", "close"]);
-
-function promiseOpenChat(url, mode, focus, buttonSet = null) {
- let uri = Services.io.newURI(url, null, null);
- let origin = uri.prePath;
- let title = origin;
- 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.
-function promiseOpenChatCallback(url, mode) {
- let uri = Services.io.newURI(url, null, null);
- let origin = uri.prePath;
- let title = origin;
- 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) {
- return new Promise(resolve => {
- target.addEventListener(eventName, function handler(event) {
- target.removeEventListener(eventName, handler, capture);
- resolve();
- }, capture);
- });
-}
-
-function promiseOneMessage(target, messageName) {
- return new Promise(resolve => {
- let mm = target.messageManager;
- mm.addMessageListener(messageName, function handler() {
- mm.removeMessageListener(messageName, handler);
- resolve();
- });
- });
-}
-
-// Return the number of chats in a browser window.
-function numChatsInWindow(win) {
- let chatbar = win.document.getElementById("pinnedchats");
- return chatbar.childElementCount;
-}
-
-function promiseWaitForFocus() {
- return new Promise(resolve => waitForFocus(resolve));
-}
-
-// A simple way to clean up after each test.
-function add_chat_task(genFunction) {
- add_task(function* () {
- info("Starting chat test " + genFunction.name);
- try {
- yield genFunction();
- } finally {
- info("Finished chat test " + genFunction.name + " - cleaning up.");
- // close all docked chats.
- while (chatbar.childNodes.length) {
- chatbar.childNodes[0].close();
- }
- // and non-docked chats.
- let winEnum = Services.wm.getEnumerator("Social:Chat");
- while (winEnum.hasMoreElements()) {
- let win = winEnum.getNext();
- if (win.closed) {
- continue;
- }
- win.close();
- }
- }
- });
-}
-
-function waitForCondition(condition, nextTest, errorMsg) {
- var tries = 0;
- var interval = setInterval(function() {
- if (tries >= 100) {
- ok(false, errorMsg);
- moveOn();
- }
- var conditionPassed;
- try {
- conditionPassed = condition();
- } catch (e) {
- ok(false, e + "\n" + e.stack);
- conditionPassed = false;
- }
- if (conditionPassed) {
- moveOn();
- }
- tries++;
- }, 100);
- var moveOn = function() { clearInterval(interval); nextTest(); };
-}
-
-function promiseWaitForCondition(aConditionFn) {
- return new Promise((resolve, reject) => {
- waitForCondition(aConditionFn, resolve, "Condition didn't pass.");
- });
-}
--- a/browser/base/moz.build
+++ b/browser/base/moz.build
@@ -11,17 +11,16 @@ MOCHITEST_MANIFESTS += [
]
MOCHITEST_CHROME_MANIFESTS += [
'content/test/chrome/chrome.ini',
]
BROWSER_CHROME_MANIFESTS += [
'content/test/alerts/browser.ini',
- 'content/test/chat/browser.ini',
'content/test/general/browser.ini',
'content/test/newtab/browser.ini',
'content/test/plugins/browser.ini',
'content/test/popupNotifications/browser.ini',
'content/test/referrer/browser.ini',
'content/test/social/browser.ini',
'content/test/tabPrompts/browser.ini',
'content/test/urlbar/browser.ini',