Bug 1509906 - use the window's initial url to determine what remoteType the initial browser should have, r=dao,mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 27 Nov 2018 15:56:26 +0000
changeset 507536 d05c6310d573658af4a4f2cee332bb01732fcabf
parent 507535 26598a115edd552ce42fe28561d7b71158f06298
child 507537 11d6688b953f800e234162bc8ed5842954de087f
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao, mconley
bugs1509906
milestone65.0a1
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
Bug 1509906 - use the window's initial url to determine what remoteType the initial browser should have, r=dao,mconley Differential Revision: https://phabricator.services.mozilla.com/D13016
browser/base/content/browser.js
browser/base/content/tabbrowser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1685,17 +1685,17 @@ var gBrowserInit = {
         });
       } else {
         // If the initial browser is not remote, we can focus the browser
         // immediately with no paint performance impact.
         gBrowser.selectedBrowser.focus();
       }
     });
     // Delay removing the attribute using requestAnimationFrame to avoid
-    // invalidating styles multiple times in a row if _uriToLoadPromise
+    // invalidating styles multiple times in a row if uriToLoadPromise
     // resolves before first paint.
     if (shouldRemoveFocusedAttribute) {
       window.requestAnimationFrame(() => {
         if (shouldRemoveFocusedAttribute)
           gURLBar.removeAttribute("focused");
       });
     }
   },
@@ -1864,19 +1864,19 @@ var gBrowserInit = {
     scheduleIdleTask(() => {
       this.idleTasksFinished = true;
       Services.obs.notifyObservers(window, "browser-idle-startup-tasks-finished");
     });
   },
 
   // Returns the URI(s) to load at startup if it is immediately known, or a
   // promise resolving to the URI to load.
-  get _uriToLoadPromise() {
-    delete this._uriToLoadPromise;
-    return this._uriToLoadPromise = function() {
+  get uriToLoadPromise() {
+    delete this.uriToLoadPromise;
+    return this.uriToLoadPromise = function() {
       // window.arguments[0]: URI to load (string), or an nsIArray of
       //                      nsISupportsStrings to load, or a xul:tab of
       //                      a tabbrowser, which will be replaced by this
       //                      window (for this case, all other arguments are
       //                      ignored).
       if (!window.arguments || !window.arguments[0]) {
         return null;
       }
@@ -1898,23 +1898,24 @@ var gBrowserInit = {
         return willOverride ? null : uri;
       }
       return willOverride.then(willOverrideHomepage =>
                                  willOverrideHomepage ? null : uri);
     }();
   },
 
   // Calls the given callback with the URI to load at startup.
-  // Synchronously if possible, or after _uriToLoadPromise resolves otherwise.
+  // Synchronously if possible, or after uriToLoadPromise resolves otherwise.
   _callWithURIToLoad(callback) {
-    let uriToLoad = this._uriToLoadPromise;
-    if (!uriToLoad || !uriToLoad.then)
+    let uriToLoad = this.uriToLoadPromise;
+    if (uriToLoad && uriToLoad.then) {
+      uriToLoad.then(callback);
+    } else {
       callback(uriToLoad);
-    else
-      uriToLoad.then(callback);
+    }
   },
 
   onUnload() {
     gUIDensity.uninit();
 
     TabsInTitlebar.uninit();
 
     ToolbarIconColor.uninit();
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -280,44 +280,51 @@ window._gBrowser = {
     return this._selectedBrowser;
   },
 
   _setupInitialBrowserAndTab() {
     // See browser.js for the meaning of window.arguments.
     // Bug 1485961 covers making this more sane.
     let userContextId = window.arguments && window.arguments[6];
 
-    // We default to a remote content browser, except if:
-    // - e10s is disabled.
-    // - there's a parent process opener (e.g. parent process about: page) for
-    //   the content tab.
-    let remoteType;
-    if (gMultiProcessBrowser && !window.hasOpenerForInitialContentBrowser) {
-      remoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
-    } else {
-      remoteType = E10SUtils.NOT_REMOTE;
-    }
+    let tabArgument = gBrowserInit.getTabToAdopt();
 
     // We only need sameProcessAsFrameLoader in the case where we're passed a tab
     let sameProcessAsFrameLoader;
-    let tabArgument = gBrowserInit.getTabToAdopt();
-    if (tabArgument) {
+    // If we have a tab argument with browser, we use its remoteType. Otherwise,
+    // if e10s is disabled or there's a parent process opener (e.g. parent
+    // process about: page) for the content tab, we use a parent
+    // process remoteType. Otherwise, we check the URI to determine
+    // what to do - if there isn't one, we default to the default remote type.
+    let remoteType;
+    if (tabArgument && tabArgument.linkedBrowser) {
+      remoteType = tabArgument.linkedBrowser.remoteType;
+      sameProcessAsFrameLoader = tabArgument.linkedBrowser.frameLoader;
+    } else if (!gMultiProcessBrowser || window.hasOpenerForInitialContentBrowser) {
+      remoteType = E10SUtils.NOT_REMOTE;
+    } else {
+      let uriToLoad = gBrowserInit.uriToLoadPromise;
+      if (uriToLoad && typeof uriToLoad == "string") {
+        remoteType = E10SUtils.getRemoteTypeForURI(
+          uriToLoad,
+          gMultiProcessBrowser,
+          E10SUtils.DEFAULT_REMOTE_TYPE
+        );
+      } else {
+        remoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
+      }
+    }
+
+    if (tabArgument && tabArgument.hasAttribute("usercontextid")) {
       // The window's first argument is a tab if and only if we are swapping tabs.
       // We must set the browser's usercontextid so that the newly created remote
       // tab child has the correct usercontextid.
-      if (tabArgument.hasAttribute("usercontextid")) {
-        userContextId = parseInt(tabArgument.getAttribute("usercontextid"), 10);
-      }
-
-      let linkedBrowser = tabArgument.linkedBrowser;
-      if (linkedBrowser) {
-        remoteType = linkedBrowser.remoteType;
-        sameProcessAsFrameLoader = linkedBrowser.frameLoader;
-      }
-    }
+      userContextId = parseInt(tabArgument.getAttribute("usercontextid"), 10);
+    }
+
     let createOptions = {
       uriIsAboutBlank: false,
       userContextId,
       sameProcessAsFrameLoader,
       remoteType,
     };
     let browser = this._createBrowser(createOptions);
     browser.setAttribute("primary", "true");