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
authorTim Taubert <ttaubert@mozilla.com>
Sat, 11 Oct 2014 19:09:26 +0200
changeset 233198 44cb72be622dc5581a944eab309738232ab104c3
parent 233197 4cf592b066efc4a56977a181d6aa4d81f78d3155
child 233199 bdba65a0ead7241c34a19fd6fb44d518755cb8f9
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyoric
bugs1081135, 495123
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_revive_windows.js
--- 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);
   }
 }