Bug 1330079 - Collect window data one more time if a new tab arrives before application-quit. r=sebastian
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 11 Jan 2017 22:26:30 +0100
changeset 357849 c8754bb4f8c14e9bcb239a681f4dda10842c1fcd
parent 357848 544ad41d3dcf9059a70aeae55a9dcce031f22b1c
child 357850 5d4f34a2196cc9d6ec26941cd3886ba3088d263a
push id10621
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 16:02:43 +0000
treeherdermozilla-aurora@dca7b42e6c67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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);