Bug 1081135 - Don't put private windows in the 'revivable windows' bucket and put normal windows there only *after* we checked RevivableWindows.isEmpty to not regress
bug 495123 r=yoric
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -1012,20 +1012,16 @@ let SessionStoreInternal = {
if (isFullyLoaded) {
winData.title = tabbrowser.selectedBrowser.contentTitle || tabbrowser.selectedTab.label;
winData.title = this._replaceLoadingTitle(winData.title, tabbrowser,
tabbrowser.selectedTab);
SessionCookies.update([winData]);
}
- // Until we decide otherwise elsewhere, this window is part of a series
- // of closing windows to quit.
- RevivableWindows.add(winData);
-
// Store the window's close date to figure out when each individual tab
// was closed. This timestamp should allow re-arranging data based on how
// recently something was closed.
winData.closedAt = Date.now();
// Save non-private windows if they have at
// least one saveable tab or are the last window.
if (!winData.isPrivate) {
@@ -1046,16 +1042,20 @@ let SessionStoreInternal = {
if (hasSaveableTabs || isLastWindow) {
// we don't want to save the busy state
delete winData.busy;
this._closedWindows.unshift(winData);
this._capClosedWindows();
}
+
+ // Until we decide otherwise elsewhere, this window
+ // is part of a series of closing windows to quit.
+ RevivableWindows.add(winData);
}
// clear this window from the list
delete this._windows[aWindow.__SSi];
// save the state without this window to disk
this.saveStateDelayed();
}
--- a/browser/components/sessionstore/test/browser_revive_windows.js
+++ b/browser/components/sessionstore/test/browser_revive_windows.js
@@ -34,16 +34,26 @@ add_task(function* test_revive_windows()
for (let i = 0; i < 3; i++) {
let win = yield promiseNewWindow();
windows.push(win);
let tab = win.gBrowser.addTab("about:mozilla");
yield promiseBrowserLoaded(tab.linkedBrowser);
}
+ // Create a private window.
+ // This window must not be revived.
+ {
+ let win = yield promiseNewWindow({private: true});
+ windows.push(win);
+
+ let tab = win.gBrowser.addTab("about:mozilla");
+ yield promiseBrowserLoaded(tab.linkedBrowser);
+ }
+
// Close all windows.
for (let win of windows) {
yield promiseWindowClosed(win);
}
is(ss.getClosedWindowCount(), 1, "one window restorable");
// Save to disk and read.
@@ -134,17 +144,17 @@ add_task(function* test_revive_windows_o
ok(JSON.stringify(windows[1]).contains(URL_ADD_WINDOW2),
"correct second additional window");
ok(JSON.stringify(windows[2]).contains(URL_MAIN_WINDOW),
"correct main window");
}
}
});
-function promiseNewWindow() {
- return new Promise(resolve => whenNewWindowLoaded({private: false}, resolve));
+function promiseNewWindow(opts = {private: false}) {
+ return new Promise(resolve => whenNewWindowLoaded(opts, resolve));
}
function forgetClosedWindows() {
while (ss.getClosedWindowCount()) {
ss.forgetClosedWindow(0);
}
}