diff --git a/browser/base/content/browser-sets.inc b/browser/base/content/browser-sets.inc
index 9fa8c57df79d..89e6cb5b69df 100644
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -119,8 +119,8 @@
+
-
@@ -380,15 +380,7 @@
#endif
-
+
diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js
index 4d3a932a3803..bdfcec2cf4b5 100644
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -4,6 +4,7 @@
// the "exported" symbols
let SocialUI,
+ SocialChatBar,
SocialFlyout,
SocialMarks,
SocialShare,
@@ -172,6 +173,7 @@ SocialUI = {
_providersChanged: function() {
SocialSidebar.clearProviderMenus();
SocialSidebar.update();
+ SocialChatBar.update();
SocialShare.populateProviderMenu();
SocialStatus.populateToolbarPalette();
SocialMarks.populateToolbarPalette();
@@ -295,6 +297,45 @@ SocialUI = {
}
}
+SocialChatBar = {
+ get chatbar() {
+ return document.getElementById("pinnedchats");
+ },
+ // Whether the chatbar is available for this window. Note that in full-screen
+ // mode chats are available, but not shown.
+ get isAvailable() {
+ return SocialUI.enabled;
+ },
+ // Does this chatbar have any chats (whether minimized, collapsed or normal)
+ get hasChats() {
+ return !!this.chatbar.firstElementChild;
+ },
+ openChat: function(aProvider, aURL, aCallback, aMode) {
+ this.update();
+ if (!this.isAvailable)
+ return false;
+ this.chatbar.openChat(aProvider, aURL, aCallback, aMode);
+ // We only want to focus the chat if it is as a result of user input.
+ let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindowUtils);
+ if (dwu.isHandlingUserInput)
+ this.chatbar.focus();
+ return true;
+ },
+ update: function() {
+ let command = document.getElementById("Social:FocusChat");
+ if (!this.isAvailable) {
+ this.chatbar.hidden = command.hidden = true;
+ } else {
+ this.chatbar.hidden = command.hidden = false;
+ }
+ command.setAttribute("disabled", command.hidden ? "true" : "false");
+ },
+ focus: function SocialChatBar_focus() {
+ this.chatbar.focus();
+ }
+}
+
SocialFlyout = {
get panel() {
return document.getElementById("social-flyout-panel");
diff --git a/browser/base/content/socialchat.xml b/browser/base/content/socialchat.xml
index 409c86d43b4e..85537db8f0a0 100644
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -30,43 +30,50 @@
document.getAnonymousElementByAttribute(this, "anonid", "notification-icon"));
-
+ Social.setErrorListener(this.content, function(aBrowser) {
+ aBrowser.webNavigation.loadURI("about:socialerror?mode=compactInfo&origin=" +
+ encodeURIComponent(aBrowser.getAttribute("origin")),
+ null, null, null, null);
+ });
if (!this.chatbar) {
document.getAnonymousElementByAttribute(this, "anonid", "minimize").hidden = true;
document.getAnonymousElementByAttribute(this, "anonid", "close").hidden = true;
}
let contentWindow = this.contentWindow;
- // process this._callbacks, then set to null so the chatbox creator
- // knows to make new callbacks immediately.
- if (this._callbacks) {
- for (let callback of this._callbacks) {
- callback(this);
- }
- this._callbacks = null;
- }
this.addEventListener("DOMContentLoaded", function DOMContentLoaded(event) {
if (event.target != this.contentDocument)
return;
this.removeEventListener("DOMContentLoaded", DOMContentLoaded, true);
this.isActive = !this.minimized;
- this._deferredChatLoaded.resolve(this);
+ // process this._callbacks, then set to null so the chatbox creator
+ // knows to make new callbacks immediately.
+ if (this._callbacks) {
+ for (let callback of this._callbacks) {
+ if (callback)
+ callback(contentWindow);
+ }
+ this._callbacks = null;
+ }
+
+ // content can send a socialChatActivity event to have the UI update.
+ let chatActivity = function() {
+ this.setAttribute("activity", true);
+ if (this.chatbar)
+ this.chatbar.updateTitlebar(this);
+ }.bind(this);
+ contentWindow.addEventListener("socialChatActivity", chatActivity);
+ contentWindow.addEventListener("unload", function unload() {
+ contentWindow.removeEventListener("unload", unload);
+ contentWindow.removeEventListener("socialChatActivity", chatActivity);
+ });
}, true);
if (this.src)
this.setAttribute("src", this.src);
]]>
-
- Promise.defer();
-
-
-
-
- return this._deferredChatLoaded.promise;
-
-
-
document.getAnonymousElementByAttribute(this, "anonid", "content");
@@ -126,7 +133,7 @@
this.contentDocument.documentElement.dispatchEvent(evt);
-
+
@@ -171,40 +186,31 @@
{
- chatbox.contentWindow.document.title = title;
- deferred.resolve(chatbox);
- }
- );
+ this.chatbar.detachChatbox(this, { "centerscreen": "yes" }, win => {
+ win.document.title = provider.name;
+ });
} else {
// attach this chatbox to the topmost browser window
- let Chat = Cu.import("resource:///modules/Chat.jsm").Chat;
- let win = Chat.findChromeWindowForChats();
- let chatbar = win.document.getElementById("pinnedchats");
- let origin = this.content.getAttribute("origin");
- let cb = chatbar.openChat(origin, title, "about:blank");
- cb.promiseChatLoaded.then(
- () => {
- this.swapDocShells(cb);
+ let findChromeWindowForChats = Cu.import("resource://gre/modules/MozSocialAPI.jsm").findChromeWindowForChats;
+ let win = findChromeWindowForChats();
+ let chatbar = win.SocialChatBar.chatbar;
+ chatbar.openChat(provider, "about:blank", win => {
+ let cb = chatbar.selectedChat;
+ this.swapDocShells(cb);
- // chatboxForURL is a map of URL -> chatbox used to avoid opening
- // duplicate chat windows. Ensure reattached chat windows aren't
- // registered with about:blank as their URL, otherwise reattaching
- // more than one chat window isn't possible.
- chatbar.chatboxForURL.delete("about:blank");
- chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb));
+ // chatboxForURL is a map of URL -> chatbox used to avoid opening
+ // duplicate chat windows. Ensure reattached chat windows aren't
+ // registered with about:blank as their URL, otherwise reattaching
+ // more than one chat window isn't possible.
+ chatbar.chatboxForURL.delete("about:blank");
+ chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb));
- chatbar.focus();
- this.close();
- deferred.resolve(cb);
- }
- );
+ chatbar.focus();
+ this.close();
+ });
}
- return deferred.promise;
]]>
@@ -504,6 +510,7 @@
+
+
+
+
-
-
+
-
+
as it
- // must exist before the (possibly delayed) bindings are created.
- cb._callbacks.push(aCallback);
- }
+ // _callbacks is a javascript property instead of a as it
+ // must exist before the (possibly delayed) bindings are created.
+ cb._callbacks = [aCallback];
// src also a javascript property; the src attribute is set in the ctor.
cb.src = aURL;
if (aMode == "minimized")
cb.setAttribute("minimized", "true");
- cb.setAttribute("origin", aOrigin);
- cb.setAttribute("label", aTitle);
+ cb.setAttribute("origin", aProvider.origin);
this.insertBefore(cb, this.firstChild);
this.selectedChat = cb;
this.chatboxForURL.set(aURL, Cu.getWeakReference(cb));
this.resize();
- return cb;
]]>
@@ -636,14 +648,12 @@
]]>
-
This is a test chat window.
-
-
-
-
-
-
-
+
+
@@ -740,12 +750,11 @@
let top = Math.min(Math.max(eY, sY.value),
sY.value + sHeight.value - winHeight);
- let title = draggedChat.content.getAttribute("title");
- this.detachChatbox(draggedChat, { screenX: left, screenY: top }).then(
- chatbox => {
- chatbox.contentWindow.document.title = title;
- }
- );
+ let provider = Social._getProviderFromOrigin(draggedChat.content.getAttribute("origin"));
+ this.detachChatbox(draggedChat, { screenX: left, screenY: top }, win => {
+ win.document.title = provider.name;
+ });
+
event.stopPropagation();
]]>
diff --git a/browser/base/content/test/chat/browser.ini b/browser/base/content/test/chat/browser.ini
deleted file mode 100644
index b5ef3f7d85c9..000000000000
--- a/browser/base/content/test/chat/browser.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[DEFAULT]
-support-files =
- head.js
- chat.html
-
-[browser_chatwindow.js]
-[browser_focus.js]
-[browser_tearoff.js]
diff --git a/browser/base/content/test/chat/browser_chatwindow.js b/browser/base/content/test/chat/browser_chatwindow.js
deleted file mode 100644
index 57339fc14867..000000000000
--- a/browser/base/content/test/chat/browser_chatwindow.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/. */
-
-let 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.
- let promiseClosed = promiseOneEvent(chatbox.content, "unload", true);
- chatbox.close();
- yield promiseClosed;
-});
-
-// 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 secondWindow = OpenBrowserWindow();
- yield promiseOneEvent(secondWindow, "load");
- 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 chats are created in the correct 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(numChatsInWindow(secondWindow), 0, "second window starts with no chats");
- yield promiseOpenChat("http://example.com#2");
- Assert.equal(numChatsInWindow(secondWindow), 1, "second window now has chats");
- Assert.equal(numChatsInWindow(window), 1, "first window still has 1 chat");
- chat.close();
- Assert.equal(numChatsInWindow(window), 0, "first window now has no chats");
- // now open another chat - it should still open in the second.
- yield promiseOpenChat("http://example.com#3");
- Assert.equal(numChatsInWindow(window), 0, "first window still has no chats");
- Assert.equal(numChatsInWindow(secondWindow), 2, "second window has both chats");
-
- // focus the first window, and open yet another chat - it
- // should open in the first window.
- window.focus();
- yield promiseWaitForFocus();
- chat = yield promiseOpenChat("http://example.com#4");
- Assert.equal(numChatsInWindow(window), 1, "first window got new chat");
- chat.close();
- Assert.equal(numChatsInWindow(window), 0, "first window has no chats");
-
- let privateWindow = OpenBrowserWindow({private: true});
- yield promiseOneEvent(privateWindow, "load")
-
- // open a last chat - 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 is known
- // to be broken on Linux.
- chat = yield promiseOpenChat("http://example.com#5");
- let os = Services.appinfo.OS;
- const BROKEN_WM_Z_ORDER = os != "WINNT" && os != "Darwin";
- let fn = BROKEN_WM_Z_ORDER ? todo : ok;
- fn(numChatsInWindow(window) == 1, "first window got the chat");
- chat.close();
- privateWindow.close();
- secondWindow.close();
-});
diff --git a/browser/base/content/test/chat/browser_focus.js b/browser/base/content/test/chat/browser_focus.js
deleted file mode 100644
index 0aa094553c37..000000000000
--- a/browser/base/content/test/chat/browser_focus.js
+++ /dev/null
@@ -1,226 +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.
-
-const CHAT_URL = "https://example.com/browser/browser/base/content/test/chat/chat.html";
-
-// Is the currently opened tab focused?
-function isTabFocused() {
- let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab);
- return Services.focus.focusedWindow == tabb.contentWindow;
-}
-
-// Is the specified chat focused?
-function isChatFocused(chat) {
- return chat.chatbar._isChatFocused(chat);
-}
-
-let 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 field and focus that before testing.
- let html = '';
- 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();
- 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* testDefaultFocus() {
- yield setUp();
- let tab = gBrowser.selectedTab;
- let deferred = Promise.defer();
- let button = tab.linkedBrowser.contentDocument.getElementById("chat-opener");
- button.addEventListener("click", function onclick() {
- button.removeEventListener("click", onclick);
- promiseOpenChat("http://example.com").then(
- chat => deferred.resolve(chat)
- );
- })
- // Note we must use synthesizeMouseAtCenter() rather than calling
- // .click() directly as this causes nsIDOMWindowUtils.isHandlingUserInput
- // to be true.
- EventUtils.synthesizeMouseAtCenter(button, {}, button.ownerDocument.defaultView);
- let chat = yield deferred.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");
- 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");
- 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 = promiseOneEvent(chat.contentWindow, "focus");
- // 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 = promiseOneEvent(chat1.contentWindow, "focus");
- 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");
- promise = promiseOneEvent(chat2.contentWindow, "focus");
- 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) {
- let doc = chat.contentDocument;
- EventUtils.sendKey("tab");
- // 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...
- let deferred = Promise.defer();
- let tries = 0;
- let interval = setInterval(function() {
- if (tries >= 30) {
- clearInterval(interval);
- deferred.reject("never got focus");
- return;
- }
- tries ++;
- let elt = eltid ? doc.getElementById(eltid) : doc.documentElement;
- if (doc.activeElement == elt) {
- clearInterval(interval);
- deferred.resolve();
- }
- });
- return deferred.promise;
- }
-
- let chat1 = yield promiseOpenChat(CHAT_URL + "#1");
- let chat2 = yield promiseOpenChat(CHAT_URL + "#2");
- chatbar.selectedChat = chat2;
- let promise = promiseOneEvent(chat2.contentWindow, "focus");
- chatbar.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.equal(chat2.contentDocument.activeElement.getAttribute("id"), "input1",
- "first input field has focus");
- 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");
- Assert.equal(chat2.contentDocument.activeElement.getAttribute("id"), "input2",
- "second input field has focus");
-
- yield sendTabAndWaitForFocus(chat2, "iframe");
- Assert.ok(isChatFocused(chat2), "new chat still focused after tab");
- Assert.equal(chat2.contentDocument.activeElement.getAttribute("id"), "iframe",
- "iframe has focus");
-
- // 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);
-
- chat.contentDocument.getElementById("input2").focus();
-
- // set focus to the tab.
- let tabb = gBrowser.getBrowserForTab(gBrowser.selectedTab);
- let promise = promiseOneEvent(tabb.contentWindow, "focus");
- Services.focus.moveFocus(tabb.contentWindow, null, Services.focus.MOVEFOCUS_ROOT, 0);
- yield promise;
-
- promise = promiseOneEvent(chat.contentWindow, "focus");
- chatbar.focus();
- yield promise;
-
- Assert.equal(chat.contentDocument.activeElement.getAttribute("id"), "input2",
- "correct input field still has focus");
-});
diff --git a/browser/base/content/test/chat/browser_tearoff.js b/browser/base/content/test/chat/browser_tearoff.js
deleted file mode 100644
index c9ba855767cd..000000000000
--- a/browser/base/content/test/chat/browser_tearoff.js
+++ /dev/null
@@ -1,128 +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/. */
-
-let 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 deferred.promise;
-}
-
-add_chat_task(function* testTearoffChat() {
- let chatbox = yield promiseOpenChat("http://example.com");
- Assert.equal(numChatsInWindow(window), 1, "should be 1 chat open");
-
- let chatDoc = chatbox.contentDocument;
- let chatTitle = chatDoc.title;
-
- Assert.equal(chatbox.getAttribute("label"), chatTitle,
- "the new chatbox should show the title of the chat window");
-
- // 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);
-
- // 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");
-
- div = chatbox.contentDocument.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");
-
- div = chatbox.contentDocument.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");
-});
diff --git a/browser/base/content/test/chat/chat.html b/browser/base/content/test/chat/chat.html
deleted file mode 100644
index c4c06f039d3d..000000000000
--- a/browser/base/content/test/chat/chat.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
-