Bug 581937 - "Recently closed tabs" list keep blank tabs [r=dietrich, a=blocking2.0:final+]
authorPaul O’Shannessy <paul@oshannessy.com>
Sat, 29 Jan 2011 12:15:57 -0800
changeset 61591 8e99b3137026617564fc7da45a2b3f8914ffeed2
parent 61590 30d746c939326dbd29fff864f869abb886d0f570
child 61592 cf073a3eafdfe4c38260b50d2d87b86a05f5f771
push id18402
push userposhannessy@mozilla.com
push dateSat, 29 Jan 2011 20:40:37 +0000
treeherdermozilla-central@a76570899a34 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich, blocking2.0
bugs581937
milestone2.0b11pre
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 581937 - "Recently closed tabs" list keep blank tabs [r=dietrich, a=blocking2.0:final+]
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -872,19 +872,19 @@ SessionStoreService.prototype = {
       
       if (isFullyLoaded) {
         winData.title = aWindow.content.document.title || tabbrowser.selectedTab.label;
         winData.title = this._replaceLoadingTitle(winData.title, tabbrowser,
                                                   tabbrowser.selectedTab);
         this._updateCookies([winData]);
       }
       
-      // save the window if it has multiple tabs or a single tab with entries
+      // save the window if it has multiple tabs or a single saveable tab
       if (winData.tabs.length > 1 ||
-          (winData.tabs.length == 1 && winData.tabs[0].entries.length > 0)) {
+          (winData.tabs.length == 1 && this._shouldSaveTabState(winData.tabs[0]))) {
         this._closedWindows.unshift(winData);
         this._capClosedWindows();
       }
       
       // clear this window from the list
       delete this._windows[aWindow.__SSi];
       
       // save the state without this window to disk
@@ -979,17 +979,17 @@ SessionStoreService.prototype = {
       return;
     }
     
     // make sure that the tab related data is up-to-date
     var tabState = this._collectTabData(aTab);
     this._updateTextAndScrollDataForTab(aWindow, aTab.linkedBrowser, tabState);
 
     // store closed-tab data for undo
-    if (tabState.entries.length > 0) {
+    if (this._shouldSaveTabState(tabState)) {
       let tabTitle = aTab.label;
       let tabbrowser = aWindow.gBrowser;
       tabTitle = this._replaceLoadingTitle(tabTitle, tabbrowser, aTab);
       
       this._windows[aWindow.__SSi]._closedTabs.unshift({
         state: tabState,
         title: tabTitle,
         image: aTab.getAttribute("image"),
@@ -3537,16 +3537,34 @@ SessionStoreService.prototype = {
                      (Date.now() - aState.session.lastUpdate);
     
     return max_resumed_crashes != -1 &&
            (aRecentCrashes > max_resumed_crashes ||
             sessionAge && sessionAge >= SIX_HOURS_IN_MS);
   },
 
   /**
+   * Determine if the tab state we're passed is something we should save. This
+   * is used when closing a tab or closing a window with a single tab
+   *
+   * @param aTabState
+   *        The current tab state
+   * @returns boolean
+   */
+  _shouldSaveTabState: function sss__shouldSaveTabState(aTabState) {
+    // If the tab has only the transient about:blank history entry, no other
+    // session history, and no userTypedValue, then we don't actually want to
+    // store this tab's data.
+    return aTabState.entries.length &&
+           !(aTabState.entries.length == 1 &&
+             aTabState.entries[0].url == "about:blank" &&
+             !aTabState.userTypedValue);
+  },
+
+  /**
    * This is going to take a state as provided at startup (via
    * nsISessionStartup.state) and split it into 2 parts. The first part
    * (defaultState) will be a state that should still be restored at startup,
    * while the second part (state) is a state that should be saved for later.
    * defaultState will be comprised of windows with only pinned tabs, extracted
    * from state. It will contain the cookies that go along with the history
    * entries in those tabs. It will also contain window position information.
    *