Bug 1323987 - Keep saving about:blank and about:newtab to disk. r=mikedeboer, a=ritu
authorMatheus Longaray <mlongaray@hp.com>
Mon, 09 Jan 2017 19:35:31 +0100
changeset 378969 f8fb0f5e4063476e83c26e0f67ea9228bd4ed963
parent 378968 87b31a7e567ddd80b64d95ec12d21b1543d9c65c
child 378970 7784a12de64b726a6c4681028540287966b423a9
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, ritu
bugs1323987
milestone53.0
Bug 1323987 - Keep saving about:blank and about:newtab to disk. r=mikedeboer, a=ritu 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.
    *