Bug 1114040 - Handle redirects and errors correctly in session store. r=ttaubert, a=sledru
authorTim Taubert <ttaubert@mozilla.com>
Fri, 23 Jan 2015 10:49:10 +0100
changeset 243093 aa4a0caf1dae
parent 243092 9f89c4328e49
child 243094 a6f725c23d30
push id4402
push userryanvm@gmail.com
push date2015-01-29 16:16 +0000
treeherdermozilla-beta@e25b169e456b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert, sledru
bugs1114040
milestone36.0
Bug 1114040 - Handle redirects and errors correctly in session store. r=ttaubert, a=sledru
browser/components/sessionstore/ContentRestore.jsm
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/content/content-sessionStore.js
--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -415,18 +415,18 @@ ProgressListener.prototype = {
     Ci.nsISupportsWeakReference
   ]),
 
   uninstall: function() {
     this.webProgress.removeProgressListener(this);
   },
 
   onStateChange: function(webProgress, request, stateFlags, status) {
-    if (stateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
-        stateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
+    if (webProgress.isTopLevel &&
+        stateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
         stateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
       this.callback();
     }
   },
 
   onLocationChange: function() {},
   onProgressChange: function() {},
   onStatusChange: function() {},
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -56,24 +56,22 @@ const FMM_MESSAGES = [
 
   // 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
-  // restoring another tab in the queue.
+  // All network loads for a restoring tab are done, so we should
+  // consider restoring another tab in the queue. The document has
+  // been restored, and forms have been filled. We trigger
+  // SSTabRestored at this time.
   "SessionStore:restoreTabContentComplete",
 
-  // The document has been restored, so the restore is done. We trigger
-  // SSTabRestored at this time.
-  "SessionStore:restoreDocumentComplete",
-
   // A tab that is being restored was reloaded. We call restoreTabContent to
   // finish restoring it right away.
   "SessionStore:reloadPendingTab",
 ];
 
 // The list of messages we accept from <xul:browser>s that have no tab
 // assigned. Those are for example the ones that preload about:newtab pages.
 const FMM_NOTAB_MESSAGES = new Set([
@@ -685,32 +683,25 @@ let SessionStoreInternal = {
       case "SessionStore:restoreTabContentComplete":
         if (this.isCurrentEpoch(browser, aMessage.data.epoch)) {
           // This callback is used exclusively by tests that want to
           // monitor the progress of network loads.
           if (gDebuggingEnabled) {
             Services.obs.notifyObservers(browser, NOTIFY_TAB_RESTORED, null);
           }
 
-          if (tab) {
-            SessionStoreInternal._resetLocalTabRestoringState(tab);
-            SessionStoreInternal.restoreNextTab();
-          }
-        }
-        break;
-      case "SessionStore:restoreDocumentComplete":
-        if (this.isCurrentEpoch(browser, aMessage.data.epoch)) {
-          // Document has been restored. Delete all the state associated
-          // with it and trigger SSTabRestored.
           let tab = browser.__SS_restore_tab;
 
           delete browser.__SS_restore_data;
           delete browser.__SS_restore_tab;
           delete browser.__SS_data;
 
+          SessionStoreInternal._resetLocalTabRestoringState(tab);
+          SessionStoreInternal.restoreNextTab();
+
           this._sendTabRestoredNotification(tab);
         }
         break;
       case "SessionStore:reloadPendingTab":
         if (this.isCurrentEpoch(browser, aMessage.data.epoch)) {
           if (tab && browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
             this.restoreTabContent(tab);
           }
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -92,19 +92,16 @@ let EventListener = {
     // the end of the restoration.
     let epoch = gContentRestore.getRestoreEpoch();
     if (!epoch) {
       return;
     }
 
     // Restore the form data and scroll position.
     gContentRestore.restoreDocument();
-
-    // Ask SessionStore.jsm to trigger SSTabRestored.
-    sendAsyncMessage("SessionStore:restoreDocumentComplete", {epoch: epoch});
   }
 };
 
 /**
  * Listens for and handles messages sent by the session store service.
  */
 let MessageListener = {
 
@@ -147,17 +144,16 @@ let MessageListener = {
         // We need to pass the value of didStartLoad back to SessionStore.jsm.
         let didStartLoad = gContentRestore.restoreTabContent(data.loadArguments, finishCallback);
 
         sendAsyncMessage("SessionStore:restoreTabContentStarted", {epoch: epoch});
 
         if (!didStartLoad) {
           // Pretend that the load succeeded so that event handlers fire correctly.
           sendAsyncMessage("SessionStore:restoreTabContentComplete", {epoch: epoch});
-          sendAsyncMessage("SessionStore:restoreDocumentComplete", {epoch: epoch});
         }
         break;
       case "SessionStore:resetRestore":
         gContentRestore.resetRestore();
         break;
       default:
         debug("received unknown message '" + name + "'");
         break;