Backed out changeset 392c8cf7a623 (bug 936271)
authorWes Kocher <wkocher@mozilla.com>
Thu, 30 Jan 2014 17:34:50 -0800
changeset 182224 d2c4e022d5acb3f1ba67f6f0529b58614dd116cf
parent 182223 3d0775f7bd0faba31a74991c95717ef498ef4712
child 182225 bd46860e441d85b6608d515386bb672f116b0f05
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs936271
milestone29.0a1
backs out392c8cf7a623a6275c40843caa2da916cae0c135
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 392c8cf7a623 (bug 936271)
browser/components/sessionstore/content/content-sessionStore.js
browser/components/sessionstore/src/SessionStore.jsm
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -82,25 +82,26 @@ let EventListener = {
     // Ignore load events from subframes.
     if (event.target != content.document) {
       return;
     }
 
     // If we're in the process of restoring, this load may signal
     // the end of the restoration.
     let epoch = gContentRestore.getRestoreEpoch();
-    if (!epoch) {
-      return;
+    if (epoch) {
+      // Restore the form data and scroll position.
+      gContentRestore.restoreDocument();
+
+      // Ask SessionStore.jsm to trigger SSTabRestored.
+      sendAsyncMessage("SessionStore:restoreDocumentComplete", {epoch: epoch});
     }
 
-    // Restore the form data and scroll position.
-    gContentRestore.restoreDocument();
-
-    // Ask SessionStore.jsm to trigger SSTabRestored.
-    sendAsyncMessage("SessionStore:restoreDocumentComplete", {epoch: epoch});
+    // Send a load message for all loads.
+    sendAsyncMessage("SessionStore:load");
   }
 };
 
 /**
  * Listens for and handles messages sent by the session store service.
  */
 let MessageListener = {
 
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -52,16 +52,19 @@ const MESSAGES = [
   // The content script gives us a reference to an object that performs
   // synchronous collection of session data.
   "SessionStore:setupSyncHandler",
 
   // The content script sends us data that has been invalidated and needs to
   // be saved to disk.
   "SessionStore:update",
 
+  // A "load" event happened.
+  "SessionStore:load",
+
   // The restoreHistory code has run. This is a good time to run SSTabRestoring.
   "SessionStore:restoreHistoryComplete",
 
   // The load for the restoring tab has begun. We update the URL bar at this
   // time; if we did it before, the load would overwrite it.
   "SessionStore:restoreTabContentStarted",
 
   // All network loads for a restoring tab are done, so we should consider
@@ -585,16 +588,19 @@ let SessionStoreInternal = {
       case "SessionStore:setupSyncHandler":
         TabState.setSyncHandler(browser, aMessage.objects.handler);
         break;
       case "SessionStore:update":
         this.recordTelemetry(aMessage.data.telemetry);
         TabState.update(browser, aMessage.data);
         this.saveStateDelayed(win);
         break;
+      case "SessionStore:load":
+        this.onTabLoad(win, browser);
+        break;
       case "SessionStore:restoreHistoryComplete":
         if (this.isCurrentEpoch(browser, aMessage.data.epoch)) {
           // Notify the tabbrowser that the tab chrome has been restored.
           let tab = this._getTabForBrowser(browser);
           let tabData = browser.__SS_data;
 
           // wall-paper fix for bug 439675: make sure that the URL to be loaded
           // is always visible in the address bar
@@ -1368,16 +1374,36 @@ let SessionStoreInternal = {
       });
       var length = this._windows[aWindow.__SSi]._closedTabs.length;
       if (length > this._max_tabs_undo)
         this._windows[aWindow.__SSi]._closedTabs.splice(this._max_tabs_undo, length - this._max_tabs_undo);
     }
   },
 
   /**
+   * When a tab loads, invalidate its cached state, trigger async save.
+   *
+   * @param aWindow
+   *        Window reference
+   * @param aBrowser
+   *        Browser reference
+   */
+  onTabLoad: function ssi_onTabLoad(aWindow, aBrowser) {
+    // It's possible to get a load event after calling stop on a browser (when
+    // overwriting tabs). We want to return early if the tab hasn't been restored yet.
+    if (aBrowser.__SS_restoreState &&
+        aBrowser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
+      return;
+    }
+
+    delete aBrowser.__SS_data;
+    this.saveStateDelayed(aWindow);
+  },
+
+  /**
    * When a tab is selected, save session data
    * @param aWindow
    *        Window reference
    */
   onTabSelect: function ssi_onTabSelect(aWindow) {
     if (this._loadState == STATE_RUNNING) {
       this._windows[aWindow.__SSi].selected = aWindow.gBrowser.tabContainer.selectedIndex;