Merge mozilla-central and fx-team

This commit is contained in:
Ed Morley 2013-08-28 12:23:55 +01:00
commit ff88e9e1ec
6 changed files with 75 additions and 90 deletions

View File

@ -5,6 +5,9 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
'use strict';
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {}).Promise;
/**
* B2G-specific actors.
*/
@ -56,7 +59,7 @@ ContentTabList.prototype = Object.create(BrowserTabList.prototype);
ContentTabList.prototype.constructor = ContentTabList;
ContentTabList.prototype.iterator = function() {
ContentTabList.prototype.getList = function() {
let browser = Services.wm.getMostRecentWindow('navigator:browser');
// Do we have an existing actor for this browser? If not, create one.
let actor = this._actorByBrowser.get(browser);
@ -66,7 +69,7 @@ ContentTabList.prototype.iterator = function() {
actor.selected = true;
}
yield actor;
return promise.resolve([actor]);
};
ContentTabList.prototype.onCloseWindow = makeInfallible(function(aWindow) {

View File

@ -479,8 +479,38 @@ var tests = {
openChat(Social.provider, function() {
ok(!window.SocialChatBar.hasChats, "first window has no chats");
ok(secondWindow.SocialChatBar.hasChats, "second window has a chat");
secondWindow.close();
next();
// focus the first window, and open yet another chat - it
// should open in the first window.
waitForFocus(function() {
openChat(Social.provider, function() {
ok(window.SocialChatBar.hasChats, "first window has chats");
window.SocialChatBar.chatbar.removeAll();
ok(!window.SocialChatBar.hasChats, "first window has no chats");
let privateWindow = OpenBrowserWindow({private: true});
privateWindow.addEventListener("load", function loadListener() {
privateWindow.removeEventListener("load", loadListener);
// 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.
openChat(Social.provider, function() {
let os = Services.appinfo.OS;
const BROKEN_WM_Z_ORDER = os != "WINNT" && os != "Darwin";
let fn = BROKEN_WM_Z_ORDER ? todo : ok;
fn(window.SocialChatBar.hasChats, "first window has a chat");
window.SocialChatBar.chatbar.removeAll();
privateWindow.close();
secondWindow.close();
next();
});
});
});
});
window.focus();
});
});
})

View File

@ -27,40 +27,11 @@ function MetroTabList(aConnection) {
MetroTabList.prototype = Object.create(BrowserTabList.prototype);
MetroTabList.prototype.constructor = MetroTabList;
/**
* We want to avoid mysterious behavior if tabs are closed or opened mid-iteration.
* We want at the end, a list of the actors that were live when we began the iteration.
* So, we update the map first, iterate over it again to yield the actors.
*/
MetroTabList.prototype.iterator = function() {
let initialMapSize = this._actorByBrowser.size;
let foundCount = 0;
for (let win of allAppShellDOMWindows("navigator:browser")) {
let selectedTab = win.Browser.selectedBrowser;
for (let browser of win.Browser.browsers) {
let actor = this._actorByBrowser.get(browser);
if (actor) {
foundCount++;
} else {
actor = new BrowserTabActor(this._connection, browser);
this._actorByBrowser.set(browser, actor);
}
// Set the 'selected' properties on all actors correctly.
actor.selected = (browser === selectedTab);
}
}
if (this._testing && initialMapSize !== foundCount) {
throw error("_actorByBrowser map contained actors for dead tabs");
}
this._mustNotify = true;
this._checkListening();
for (let [browser, actor] of this._actorByBrowser) {
yield actor;
}
MetroTabList.prototype._getSelectedBrowser = function(aWindow) {
return aWindow.Browser.selectedBrowser;
};
MetroTabList.prototype._getChildren = function(aWindow) {
return aWindow.Browser.browsers;
};

View File

@ -54,49 +54,10 @@ MobileTabList.prototype = Object.create(BrowserTabList.prototype);
MobileTabList.prototype.constructor = MobileTabList;
MobileTabList.prototype.iterator = function() {
// As a sanity check, make sure all the actors presently in our map get
// picked up when we iterate over all windows' tabs.
let initialMapSize = this._actorByBrowser.size;
let foundCount = 0;
// To avoid mysterious behavior if tabs are closed or opened mid-iteration,
// we update the map first, and then make a second pass over it to yield
// the actors. Thus, the sequence yielded is always a snapshot of the
// actors that were live when we began the iteration.
// Iterate over all navigator:browser XUL windows.
for (let win of allAppShellDOMWindows("navigator:browser")) {
let selectedTab = win.BrowserApp.selectedBrowser;
// For each tab in this XUL window, ensure that we have an actor for
// it, reusing existing actors where possible. We actually iterate
// over 'browser' XUL elements, and BrowserTabActor uses
// browser.contentWindow.wrappedJSObject as the debuggee global.
for (let tab of win.BrowserApp.tabs) {
let browser = tab.browser;
// Do we have an existing actor for this browser? If not, create one.
let actor = this._actorByBrowser.get(browser);
if (actor) {
foundCount++;
} else {
actor = new BrowserTabActor(this._connection, browser);
this._actorByBrowser.set(browser, actor);
}
// Set the 'selected' properties on all actors correctly.
actor.selected = (browser === selectedTab);
}
}
if (this._testing && initialMapSize !== foundCount)
throw Error("_actorByBrowser map contained actors for dead tabs");
this._mustNotify = true;
this._checkListening();
/* Yield the values. */
for (let [browser, actor] of this._actorByBrowser) {
yield actor;
}
MobileTabList.prototype._getSelectedBrowser = function(aWindow) {
return aWindow.BrowserApp.selectedBrowser;
};
MobileTabList.prototype._getChildren = function(aWindow) {
return aWindow.BrowserApp.tabs.map(tab => tab.browser);
};

View File

@ -275,12 +275,23 @@ function findChromeWindowForChats(preferredWindow) {
// 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
// Try first the most recent window as getMostRecentWindow works
// even on platforms where getZOrderDOMWindowEnumerator is broken
// (ie. Linux). This will handle most cases, but won't work if the
// foreground window is a popup.
let mostRecent = Services.wm.getMostRecentWindow("navigator:browser");
if (isWindowGoodForChats(mostRecent))
return mostRecent;
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
// *sigh* - getZOrderDOMWindowEnumerator is broken except on Mac and
// Windows. We use BROKEN_WM_Z_ORDER as that is what some other code uses
// and a few bugs recommend searching mxr for this symbol to identify the
// workarounds - we want this code to be hit in such searches.
const BROKEN_WM_Z_ORDER = Services.appinfo.OS != "WINNT";
let os = Services.appinfo.OS;
const BROKEN_WM_Z_ORDER = os != "WINNT" && os != "Darwin";
if (BROKEN_WM_Z_ORDER) {
// this is oldest to newest and no way to change the order.
enumerator = Services.wm.getEnumerator("navigator:browser");

View File

@ -186,6 +186,15 @@ function BrowserTabList(aConnection)
BrowserTabList.prototype.constructor = BrowserTabList;
BrowserTabList.prototype._getSelectedBrowser = function(aWindow) {
return aWindow.gBrowser.selectedBrowser;
};
BrowserTabList.prototype._getChildren = function(aWindow) {
return aWindow.gBrowser.browsers;
};
BrowserTabList.prototype.getList = function() {
let topXULWindow = windowMediator.getMostRecentWindow("navigator:browser");
@ -201,13 +210,13 @@ BrowserTabList.prototype.getList = function() {
// Iterate over all navigator:browser XUL windows.
for (let win of allAppShellDOMWindows("navigator:browser")) {
let selectedTab = win.gBrowser.selectedBrowser;
let selectedBrowser = this._getSelectedBrowser(win);
// For each tab in this XUL window, ensure that we have an actor for
// it, reusing existing actors where possible. We actually iterate
// over 'browser' XUL elements, and BrowserTabActor uses
// browser.contentWindow.wrappedJSObject as the debuggee global.
for (let browser of win.gBrowser.browsers) {
for (let browser of this._getChildren(win)) {
// Do we have an existing actor for this browser? If not, create one.
let actor = this._actorByBrowser.get(browser);
if (actor) {
@ -218,7 +227,7 @@ BrowserTabList.prototype.getList = function() {
}
// Set the 'selected' properties on all actors correctly.
actor.selected = (win === topXULWindow && browser === selectedTab);
actor.selected = (win === topXULWindow && browser === selectedBrowser);
}
}