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
--- 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) {