Bug 1323987 - Keep saving about:blank and about:newtab to disk. r?mikedeboer draft
authorMatheus Longaray <mlongaray@hp.com>
Mon, 09 Jan 2017 19:35:31 +0100
changeset 485509 a21059e4e9e633560daba457404af9563c9f354a
parent 485508 b6437446766a64da1eb51fb9d58b84457f943e74
child 485510 6765c3feee5ba40662bbc5ae96264f17fb27afce
push id45752
push userbmo:mlongaray@hp.com
push dateThu, 16 Feb 2017 20:15:57 +0000
reviewersmikedeboer
bugs1323987
milestone54.0a1
Bug 1323987 - Keep saving about:blank and about:newtab to disk. r?mikedeboer This patch creates a new method that verifies if the tab state we're passed is something we should keep to be reopened at session restore. This is used when we are saving the current session state to disk. This method is very similar to _shouldSaveTabState, however, "about:blank" and "about:newtab" tabs will still be saved to disk. MozReview-Commit-ID: 70zKFeUG9uQ
browser/components/sessionstore/SessionStore.jsm
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -383,17 +383,17 @@ this.SessionStore = {
    *        The browser state for which we remove worth-saving tabs.
    *        The given object will be modified.
    */
   keepOnlyWorthSavingTabs: function (aState) {
     for (let i = aState.windows.length - 1; i >= 0; i--) {
       let win = aState.windows[i];
       for (let j = win.tabs.length - 1; j >= 0; j--) {
         let tab = win.tabs[j];
-        if (!SessionStoreInternal._shouldSaveTabState(tab)) {
+        if (!SessionStoreInternal._shouldSaveTab(tab)) {
           win.tabs.splice(j, 1);
           if (win.selected > j) {
             win.selected--;
           }
         }
       }
       if (!win.tabs.length) {
         aState.windows.splice(i, 1);
@@ -4193,21 +4193,40 @@ var SessionStoreInternal = {
   _shouldSaveTabState: function ssi_shouldSaveTabState(aTabState) {
     // If the tab has only a transient about: 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.entries[0].url == "about:newtab" ||
+                 aTabState.entries[0].url == "about:printpreview" ||
                  aTabState.entries[0].url == "about:privatebrowsing") &&
                  !aTabState.userTypedValue);
   },
 
   /**
+   * Determine if the tab state we're passed is something we should keep to be
+   * reopened at session restore. This is used when we are saving the current
+   * session state to disk. This method is very similar to _shouldSaveTabState,
+   * however, "about:blank" and "about:newtab" tabs will still be saved to disk.
+   *
+   * @param aTabState
+   *        The current tab state
+   * @returns boolean
+   */
+  _shouldSaveTab: function ssi_shouldSaveTab(aTabState) {
+    // If the tab has one of the following transient about: history entry,
+    // then we don't actually want to write this tab's data to disk.
+    return aTabState.entries.length &&
+           !(aTabState.entries[0].url == "about:printpreview" ||
+             aTabState.entries[0].url == "about:privatebrowsing");
+  },
+
+  /**
    * 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.
    *