Bug 1330079 - Collect window data one more time if a new tab arrives before application-quit. r?sebastian draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 11 Jan 2017 22:26:30 +0100
changeset 462093 d7d3018c2c78974400f79cfc80e779b980996771
parent 462092 122c1af8928d4428794c3cc1f41c7102ecfda6a1
child 542319 7f6b29889c46acffd149dc326255912886d672f8
push id41674
push usermozilla@buttercookie.de
push dateMon, 16 Jan 2017 19:33:21 +0000
reviewerssebastian
bugs1330079, 1266594
milestone53.0a1
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
mobile/android/components/SessionStore.js
--- 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);