Bug 852267 - Part 1 - Always attach session store data to restored tabs. r=margaret draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 31 Mar 2016 20:53:06 +0200
changeset 346789 aa736257b6103ae9f12e4a9de85740adcc6b491d
parent 346007 e14db462d31d566570e3bece66d5380f7b1ad400
child 346790 8ee123f82a0bef297df60799eceade350edc2e8b
child 347273 ad09950144312e6a0e40a9158a620737c26944ec
child 347351 f5cec589e03f3ef32365ae1cde1137b46545d03b
push id14444
push usermozilla@buttercookie.de
push dateFri, 01 Apr 2016 16:35:24 +0000
reviewersmargaret
bugs852267, 1044556
milestone48.0a1
Bug 852267 - Part 1 - Always attach session store data to restored tabs. r=margaret Up till now, when restoring tabs, the previous session store data was only attached to the tab object where necessary to make delay loaded tabs work. In all other cases, the session store data was left empty and recreated only once page loading had progressed sufficiently far to fire the DOMTitleChanged event. This means that a tab could get lost if the session was saved before this point and Firefox then subsequently killed. In conjunction with bug 1044556, a memory pressure event could also prevent the session store data from being recreated for a tab, because the session store wouldn't recieve any new events for tabs that had been zombified. Therefore, with this patch we always attach the previous session store data to a freshly restored tab, so it will always be included in a session save even if the save is triggered before tab loading has progressed far enough. MozReview-Commit-ID: GVupnXwuRDV
mobile/android/components/SessionStore.js
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -967,16 +967,18 @@ SessionStore.prototype = {
       let tabData = JSON.parse(aData.tabs[i]);
       let params = {
         selected: (i == aData.tabs.length - 1),
         isPrivate: tabData.isPrivate,
         desktopMode: tabData.desktopMode,
       };
 
       let tab = window.BrowserApp.addTab(tabData.entries[tabData.index - 1].url, params);
+      tab.browser.__SS_data = tabData;
+      tab.browser.__SS_extdata = tabData.extData;
       this._restoreTab(tabData, tab.browser);
     }
   },
 
   /**
    * Don't save sensitive data if the user doesn't want to
    * (distinguishes between encrypted and non-encrypted sites)
    */
@@ -1089,29 +1091,29 @@ SessionStore.prototype = {
         delete tabData.tabId;
 
         // Don't restore tab if user has closed it
         if (tab == null) {
           continue;
         }
       }
 
+      tab.browser.__SS_data = tabData;
+      tab.browser.__SS_extdata = tabData.extData;
+
       if (window.BrowserApp.selectedTab == tab) {
         this._restoreTab(tabData, tab.browser);
 
         delete tab.browser.__SS_restore;
         tab.browser.removeAttribute("pending");
       } else {
-        // Make sure the browser has its session data for the delay reload
-        tab.browser.__SS_data = tabData;
+        // Mark the browser for delay loading
         tab.browser.__SS_restore = true;
         tab.browser.setAttribute("pending", "true");
       }
-
-      tab.browser.__SS_extdata = tabData.extData;
     }
 
     // Restore the closed tabs array on the current window.
     if (state.windows[0].closedTabs) {
       this._windows[window.__SSID].closedTabs = state.windows[0].closedTabs;
     }
   },
 
@@ -1148,23 +1150,22 @@ SessionStore.prototype = {
     // create a new tab and bring to front
     let params = {
       selected: true,
       isPrivate: aCloseTabData.isPrivate,
       desktopMode: aCloseTabData.desktopMode,
       tabIndex: this._lastClosedTabIndex
     };
     let tab = aWindow.BrowserApp.addTab(aCloseTabData.entries[aCloseTabData.index - 1].url, params);
+    tab.browser.__SS_data = aCloseTabData;
+    tab.browser.__SS_extdata = aCloseTabData.extData;
     this._restoreTab(aCloseTabData, tab.browser);
 
     this._lastClosedTabIndex = -1;
 
-    // Put back the extra data
-    tab.browser.__SS_extdata = aCloseTabData.extData;
-
     if (this._notifyClosedTabs) {
       this._sendClosedTabsToJava(aWindow);
     }
 
     return tab.browser;
   },
 
   forgetClosedTab: function ss_forgetClosedTab(aWindow, aIndex) {