Bug 1330079 - Collect window data one more time if a new tab arrives before application-quit. r?sebastian
This is relevant when a new tab is opened (e.g. through an intent from an external app) just as the user has pressed the Quit button (see
bug 1266594), in which case the TabOpen event might reach the session store after Gecko shutdown has already started. If we're still in the preliminary phase and the browser window hasn't yet been closed, we can persist this new tab by collecting the session store data from the browser window once more.
Additionally, we now reset the time of the last backup when clearing the session store data, so the backup file is recreated as soon as possible after a history/tabs sanitisation, especially for users who are cleaning private data on exiting Firefox.
MozReview-Commit-ID: 9BmqrSIUJ42
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -143,16 +143,17 @@ SessionStore.prototype = {
this._maxTabsUndo = Services.prefs.getIntPref(PREFS_MAX_TABS_UNDO);
if (this._maxTabsUndo == 0) {
this._forgetClosedTabs();
}
},
_clearDisk: function ss_clearDisk() {
this._sessionDataIsGood = false;
+ this._lastBackupTime = 0;
if (this._loadState > STATE_QUITTING) {
OS.File.remove(this._sessionFile.path);
OS.File.remove(this._sessionFileBackup.path);
OS.File.remove(this._sessionFilePrevious.path);
OS.File.remove(this._sessionFileTemp.path);
} else { // We're shutting down and must delete synchronously
if (this._sessionFile.exists()) { this._sessionFile.remove(false); }
@@ -592,16 +593,23 @@ SessionStore.prototype = {
// Record the current scroll position and zoom level.
aBrowser.addEventListener("scroll", this, true);
aBrowser.addEventListener("resize", this, true);
log("onTabAdd() ran for tab " + aWindow.BrowserApp.getTabForBrowser(aBrowser).id +
", aNoNotification = " + aNoNotification);
if (!aNoNotification) {
+ if (this._loadState == STATE_QUITTING) {
+ // A tab arrived just as were starting to shut down. Since we haven't yet received
+ // application-quit, we refresh the window data one more time before the window closes.
+ this._forEachBrowserWindow((aWindow) => {
+ this._collectWindowData(aWindow);
+ });
+ }
this.saveStateDelayed();
}
this._updateCrashReportURL(aWindow);
},
onTabRemove: function ss_onTabRemove(aWindow, aBrowser, aNoNotification) {
// Cleanup event listeners
aBrowser.removeEventListener("DOMTitleChanged", this, true);