Bug 835111 - always open new chat windows in the 'most recent' suitable browser window. r=gavin

This commit is contained in:
Mark Hammond 2013-02-06 15:06:35 +11:00
Родитель 29c1843e73
Коммит 22afd18258
2 изменённых файлов: 12 добавлений и 16 удалений

Просмотреть файл

@ -456,18 +456,17 @@ var tests = {
ok(!window.SocialChatBar.hasChats, "first window should start with no chats");
openChat(function() {
ok(window.SocialChatBar.hasChats, "first window has the chat");
// create a second window - although this will be the "most recent",
// the fact the first window has a chat open means the first will be targetted.
// 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();
secondWindow.addEventListener("load", function loadListener() {
secondWindow.removeEventListener("load", loadListener);
ok(!secondWindow.SocialChatBar.hasChats, "second window has no chats");
openChat(function() {
ok(!secondWindow.SocialChatBar.hasChats, "second window still has no chats");
is(window.SocialChatBar.chatbar.childElementCount, 2, "first window now has 2 chats");
ok(secondWindow.SocialChatBar.hasChats, "second window now has chats");
is(window.SocialChatBar.chatbar.childElementCount, 1, "first window still has 1 chat");
window.SocialChatBar.chatbar.removeAll();
// now open another chat - it should open in the second window (as
// it is the "most recent" and no other windows have chats)
// now open another chat - it should still open in the second.
openChat(function() {
ok(!window.SocialChatBar.hasChats, "first window has no chats");
ok(secondWindow.SocialChatBar.hasChats, "second window has a chat");

Просмотреть файл

@ -235,10 +235,10 @@ function isWindowGoodForChats(win) {
function findChromeWindowForChats(preferredWindow) {
if (preferredWindow && isWindowGoodForChats(preferredWindow))
return preferredWindow;
// no good - so let's go hunting. We are now looking for a navigator:browser
// window that is suitable and already has chats open, or failing that,
// any suitable navigator:browser window.
let first, best, enumerator;
// no good - we just use the "most recent" browser window which can host
// chats (we used to try and "group" all chats in the same browser window,
// but that didn't work out so well - see bug 835111
let topMost, enumerator;
// *sigh* - getZOrderDOMWindowEnumerator is broken everywhere other than
// Windows. We use BROKEN_WM_Z_ORDER as that is what the c++ code uses
// and a few bugs recommend searching mxr for this symbol to identify the
@ -254,13 +254,10 @@ function findChromeWindowForChats(preferredWindow) {
}
while (enumerator.hasMoreElements()) {
let win = enumerator.getNext();
if (win && isWindowGoodForChats(win)) {
first = win;
if (win.SocialChatBar.hasChats)
best = win;
}
if (win && isWindowGoodForChats(win))
topMost = win;
}
return best || first;
return topMost;
}
this.openChatWindow =