Bug 1266475 - don't re-load about:blank when we're remoteness-switching anyway, r?mconley draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 21 Apr 2016 17:55:42 +0100
changeset 354864 0526ffa60cc63cad9aaaa16b0f0bf2faa69234f2
parent 354236 e9088179190a3129cc705ea795e40669c97327d0
child 519092 db60c4fbd979ae5da1e22705db35c410d7cc57ad
push id16176
push usergijskruitbosch@gmail.com
push dateThu, 21 Apr 2016 17:09:05 +0000
reviewersmconley
bugs1266475
milestone48.0a1
Bug 1266475 - don't re-load about:blank when we're remoteness-switching anyway, r?mconley MozReview-Commit-ID: HwPrmjzCxHq
browser/base/content/test/urlbar/browser.ini
browser/base/content/test/urlbar/browser_urlbar_remoteness_switch.js
browser/components/sessionstore/ContentRestore.jsm
browser/components/sessionstore/content/content-sessionStore.js
--- a/browser/base/content/test/urlbar/browser.ini
+++ b/browser/base/content/test/urlbar/browser.ini
@@ -3,8 +3,11 @@
 support-files =
   file_blank_but_not_blank.html
 [browser_urlbar_locationchange_urlbar_edit_dos.js]
 support-files =
   file_urlbar_edit_dos.html
 [browser_urlbar_stop_pending.js]
 support-files =
   slow-page.sjs
+[browser_urlbar_remoteness_switch.js]
+run-if = e10s
+
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/urlbar/browser_urlbar_remoteness_switch.js
@@ -0,0 +1,34 @@
+"use strict";
+
+add_task(function*() {
+  let url = "http://www.example.com/foo.html";
+  yield BrowserTestUtils.withNewTab({gBrowser, url}, function*(browser) {
+    let wpl = {
+      onLocationChange(wpl, request, location, flags) {
+        if (location.schemeIs("about")) {
+          is(location.spec, "about:config", "Only about: location change should be for about:preferences");
+        } else {
+          is(location.spec, url, "Only non-about: location change should be for the http URL we're dealing with.");
+        }
+      },
+    };
+    gBrowser.addProgressListener(wpl);
+
+    let didLoad = BrowserTestUtils.browserLoaded(browser, null, function(url) {
+      return url = "about:config";
+    });
+    yield BrowserTestUtils.loadURI(browser, "about:config");
+    yield didLoad;
+
+    gBrowser.goBack();
+    yield BrowserTestUtils.browserLoaded(browser, null, function(loadedURL) {
+      return url == loadedURL;
+    });
+    gBrowser.goForward();
+    yield BrowserTestUtils.browserLoaded(browser, null, function(url) {
+      return url = "about:config";
+    });
+    gBrowser.removeProgressListener(wpl);
+  });
+});
+
--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -133,17 +133,17 @@ ContentRestoreInternal.prototype = {
       webNavigation.setCurrentURI(Utils.makeURI(uri));
     }
 
     SessionHistory.restore(this.docShell, tabData);
 
     // Add a listener to watch for reloads.
     let listener = new HistoryListener(this.docShell, () => {
       // On reload, restore tab contents.
-      this.restoreTabContent(null, callbacks.onLoadFinished);
+      this.restoreTabContent(null, false, callbacks.onLoadFinished);
     });
 
     webNavigation.sessionHistory.addSHistoryListener(listener);
     this._historyListener = listener;
 
     // Make sure to reset the capabilities and attributes in case this tab gets
     // reused.
     let disallow = new Set(tabData.disallow && tabData.disallow.split(","));
@@ -170,31 +170,31 @@ ContentRestoreInternal.prototype = {
       }
     });
   },
 
   /**
    * Start loading the current page. When the data has finished loading from the
    * network, finishCallback is called. Returns true if the load was successful.
    */
-  restoreTabContent: function (loadArguments, finishCallback) {
+  restoreTabContent: function (loadArguments, isRemotenessUpdate, finishCallback) {
     let tabData = this._tabData;
     this._tabData = null;
 
     let webNavigation = this.docShell.QueryInterface(Ci.nsIWebNavigation);
     let history = webNavigation.sessionHistory;
 
     // Listen for the tab to finish loading.
     this.restoreTabContentStarted(finishCallback);
 
     // Reset the current URI to about:blank. We changed it above for
     // switch-to-tab, but now it must go back to the correct value before the
     // load happens. Don't bother doing this if we're restoring immediately
     // due to a process switch.
-    if (!loadArguments) {
+    if (!isRemotenessUpdate) {
       webNavigation.setCurrentURI(Utils.makeURI("about:blank"));
     }
 
     try {
       if (loadArguments) {
         // A load has been redirected to a new process so get history into the
         // same state it was before the load started then trigger the load.
         let referrer = loadArguments.referrer ?
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -166,17 +166,17 @@ var MessageListener = {
     // to temporarily synchronize them.
     sendSyncMessage("SessionStore:restoreHistoryComplete", {epoch});
   },
 
   restoreTabContent({loadArguments, isRemotenessUpdate}) {
     let epoch = gCurrentEpoch;
 
     // We need to pass the value of didStartLoad back to SessionStore.jsm.
-    let didStartLoad = gContentRestore.restoreTabContent(loadArguments, () => {
+    let didStartLoad = gContentRestore.restoreTabContent(loadArguments, isRemotenessUpdate, () => {
       // Tell SessionStore.jsm that it may want to restore some more tabs,
       // since it restores a max of MAX_CONCURRENT_TAB_RESTORES at a time.
       sendAsyncMessage("SessionStore:restoreTabContentComplete", {epoch, isRemotenessUpdate});
     });
 
     sendAsyncMessage("SessionStore:restoreTabContentStarted", {epoch});
 
     if (!didStartLoad) {