Bug 1472212 - Rename E10SUtils.canLoadURIInProcess to E10SUtils.canLoadURIInRemoteType and modify it to accept an E10SUtils process type instead of a nsIXULRuntime process type. r=Gijs
☠☠ backed out by 9a4b8f268757 ☠ ☠
authorJay Lim <jlim@mozilla.com>
Fri, 20 Jul 2018 18:02:45 -0400
changeset 499437 a8bba29ad2cb20239b87081f77cdf34249d3337b
parent 499436 e1cafd30a69afeef3e2ecbb557cd87c77e52b3f6
child 499438 55c2a8d227dc91f965718aa09da9811cff0969a7
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1472212
milestone64.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 1472212 - Rename E10SUtils.canLoadURIInProcess to E10SUtils.canLoadURIInRemoteType and modify it to accept an E10SUtils process type instead of a nsIXULRuntime process type. r=Gijs See next commit for more info. The idea is to use E10SUtils.canLoadURIInRemoteType to detect if a URI can load in a given E10SUtils process type. Having it to accept a nsIXULRuntime process type, which will be mapped back to an E10SUtils process type, is unnecessary. MozReview-Commit-ID: KeYkuRDyqXO
browser/base/content/test/general/browser_e10s_about_process.js
browser/base/content/test/general/browser_e10s_chrome_process.js
browser/base/content/test/general/browser_e10s_javascript.js
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
toolkit/content/tests/browser/browser_findbar.js
toolkit/modules/E10SUtils.jsm
toolkit/mozapps/extensions/content/extensions.js
--- a/browser/base/content/test/general/browser_e10s_about_process.js
+++ b/browser/base/content/test/general/browser_e10s_about_process.js
@@ -1,10 +1,10 @@
-const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
+const CHROME_PROCESS = E10SUtils.NOT_REMOTE;
+const WEB_CONTENT_PROCESS = E10SUtils.WEB_REMOTE_TYPE;
 
 const CHROME = {
   id: "cb34538a-d9da-40f3-b61a-069f0b2cb9fb",
   path: "test-chrome",
   flags: 0,
 };
 const CANREMOTE = {
   id: "2480d3e1-9ce4-4b84-8ae3-910b9a95cbb3",
@@ -74,36 +74,36 @@ add_task(async function init() {
 
 registerCleanupFunction(() => {
   let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
   for (let module of TEST_MODULES) {
     registrar.unregisterFactory(Components.ID(module.id), AboutModuleFactory);
   }
 });
 
-function test_url(url, chromeResult, contentResult) {
-  is(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS),
+function test_url(url, chromeResult, webContentResult) {
+  is(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS),
      chromeResult, "Check URL in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url, CONTENT_PROCESS),
-     contentResult, "Check URL in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS),
+     webContentResult, "Check URL in web content process.");
 
-  is(E10SUtils.canLoadURIInProcess(url + "#foo", CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url + "#foo", CHROME_PROCESS),
      chromeResult, "Check URL with ref in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url + "#foo", CONTENT_PROCESS),
-     contentResult, "Check URL with ref in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url + "#foo", WEB_CONTENT_PROCESS),
+     webContentResult, "Check URL with ref in web content process.");
 
-  is(E10SUtils.canLoadURIInProcess(url + "?foo", CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo", CHROME_PROCESS),
      chromeResult, "Check URL with query in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url + "?foo", CONTENT_PROCESS),
-     contentResult, "Check URL with query in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo", WEB_CONTENT_PROCESS),
+     webContentResult, "Check URL with query in web content process.");
 
-  is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", CHROME_PROCESS),
      chromeResult, "Check URL with query and ref in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CONTENT_PROCESS),
-     contentResult, "Check URL with query and ref in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", WEB_CONTENT_PROCESS),
+     webContentResult, "Check URL with query and ref in web content process.");
 }
 
 add_task(async function test_chrome() {
   test_url("about:" + CHROME.path, true, false);
 });
 
 add_task(async function test_any() {
   test_url("about:" + CANREMOTE.path, true, true);
--- a/browser/base/content/test/general/browser_e10s_chrome_process.js
+++ b/browser/base/content/test/general/browser_e10s_chrome_process.js
@@ -27,52 +27,52 @@ function makeTest(name, startURL, startP
     }
     await docLoadedPromise;
 
     is(browser.currentURI.spec, endURL, "Should have made it to the final URL");
     is(browser.isRemoteBrowser, endProcessIsRemote, "Should be displayed in the right process");
   };
 }
 
-const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
+const CHROME_PROCESS = E10SUtils.NOT_REMOTE;
+const WEB_CONTENT_PROCESS = E10SUtils.WEB_REMOTE_TYPE;
 const PATH = (getRootDirectory(gTestPath) + "test_process_flags_chrome.html").replace("chrome://mochitests", "");
 
 const CHROME = "chrome://mochitests" + PATH;
 const CANREMOTE = "chrome://mochitests-any" + PATH;
 const MUSTREMOTE = "chrome://mochitests-content" + PATH;
 
 add_task(async function init() {
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {forceNotRemote: true});
 });
 
 registerCleanupFunction(() => {
   gBrowser.removeCurrentTab();
 });
 
 function test_url(url, chromeResult, contentResult) {
-  is(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS),
      chromeResult, "Check URL in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url, CONTENT_PROCESS),
-     contentResult, "Check URL in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS),
+     contentResult, "Check URL in web content process.");
 
-  is(E10SUtils.canLoadURIInProcess(url + "#foo", CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url + "#foo", CHROME_PROCESS),
      chromeResult, "Check URL with ref in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url + "#foo", CONTENT_PROCESS),
-     contentResult, "Check URL with ref in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url + "#foo", WEB_CONTENT_PROCESS),
+     contentResult, "Check URL with ref in web content process.");
 
-  is(E10SUtils.canLoadURIInProcess(url + "?foo", CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo", CHROME_PROCESS),
      chromeResult, "Check URL with query in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url + "?foo", CONTENT_PROCESS),
-     contentResult, "Check URL with query in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo", WEB_CONTENT_PROCESS),
+     contentResult, "Check URL with query in web content process.");
 
-  is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CHROME_PROCESS),
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", CHROME_PROCESS),
      chromeResult, "Check URL with query and ref in chrome process.");
-  is(E10SUtils.canLoadURIInProcess(url + "?foo#bar", CONTENT_PROCESS),
-     contentResult, "Check URL with query and ref in content process.");
+  is(E10SUtils.canLoadURIInRemoteType(url + "?foo#bar", WEB_CONTENT_PROCESS),
+     contentResult, "Check URL with query and ref in web content process.");
 }
 
 add_task(async function test_chrome() {
   test_url(CHROME, true, false);
 });
 
 add_task(async function test_any() {
   test_url(CANREMOTE, true, true);
--- a/browser/base/content/test/general/browser_e10s_javascript.js
+++ b/browser/base/content/test/general/browser_e10s_javascript.js
@@ -1,11 +1,11 @@
-const CHROME_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
+const CHROME_PROCESS = E10SUtils.NOT_REMOTE;
+const WEB_CONTENT_PROCESS = E10SUtils.WEB_REMOTE_TYPE;
 
 add_task(async function() {
   let url = "javascript:dosomething()";
 
-  ok(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS),
+  ok(E10SUtils.canLoadURIInRemoteType(url, CHROME_PROCESS),
      "Check URL in chrome process.");
-  ok(E10SUtils.canLoadURIInProcess(url, CONTENT_PROCESS),
-     "Check URL in content process.");
+  ok(E10SUtils.canLoadURIInRemoteType(url, WEB_CONTENT_PROCESS),
+     "Check URL in web content process.");
 });
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -589,22 +589,18 @@ var BrowserTestUtils = {
         let promises = [
           TestUtils.topicObserved("browser-delayed-startup-finished",
                                   subject => subject == win),
         ];
 
         if (url) {
           let browser = win.gBrowser.selectedBrowser;
 
-          // Retrieve the given browser's current process type.
-          let process =
-              browser.isRemoteBrowser ? Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
-              : Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
           if (win.gMultiProcessBrowser &&
-              !E10SUtils.canLoadURIInProcess(url, process)) {
+              !E10SUtils.canLoadURIInRemoteType(url, browser.remoteType)) {
             await this.waitForEvent(browser, "XULFrameLoaderCreated");
           }
 
           let loadPromise = this.browserLoaded(browser, false, url, maybeErrorPage);
           promises.push(loadPromise);
         }
 
         await Promise.all(promises);
@@ -637,24 +633,20 @@ var BrowserTestUtils = {
       triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
     });
 
     // Nothing to do in non-e10s mode.
     if (!browser.ownerGlobal.gMultiProcessBrowser) {
       return;
     }
 
-    // Retrieve the given browser's current process type.
-    let process = browser.isRemoteBrowser ? Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
-                                          : Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
-
     // If the new URI can't load in the browser's current process then we
     // should wait for the new frameLoader to be created. This will happen
     // asynchronously when the browser's remoteness changes.
-    if (!E10SUtils.canLoadURIInProcess(uri, process)) {
+    if (!E10SUtils.canLoadURIInRemoteType(uri, browser.remoteType)) {
       await this.waitForEvent(browser, "XULFrameLoaderCreated");
     }
   },
 
   /**
    * @param win (optional)
    *        The window we should wait to have "domwindowopened" sent through
    *        the observer service for. If this is not supplied, we'll just
--- a/toolkit/content/tests/browser/browser_findbar.js
+++ b/toolkit/content/tests/browser/browser_findbar.js
@@ -1,13 +1,13 @@
 /* eslint-disable mozilla/no-arbitrary-setTimeout */
 ChromeUtils.import("resource://gre/modules/Timer.jsm", this);
 
 const TEST_PAGE_URI = "data:text/html;charset=utf-8,The letter s.";
-// Using 'javascript' schema to bypass E10SUtils.canLoadURIInProcess, because
+// Using 'javascript' schema to bypass E10SUtils.canLoadURIInRemoteType, because
 // it does not allow 'data:' URI to be loaded in the parent process.
 const E10S_PARENT_TEST_PAGE_URI = "javascript:document.write('The letter s.');";
 
 /**
  * Makes sure that the findbar hotkeys (' and /) event listeners
  * are added to the system event group and do not get blocked
  * by calling stopPropagation on a keypress event on a page.
  */
--- a/toolkit/modules/E10SUtils.jsm
+++ b/toolkit/modules/E10SUtils.jsm
@@ -85,20 +85,24 @@ var E10SUtils = {
   DEFAULT_REMOTE_TYPE,
   NOT_REMOTE,
   WEB_REMOTE_TYPE,
   FILE_REMOTE_TYPE,
   EXTENSION_REMOTE_TYPE,
   PRIVILEGED_REMOTE_TYPE,
   LARGE_ALLOCATION_REMOTE_TYPE,
 
-  canLoadURIInProcess(aURL, aProcess) {
-    let remoteType = aProcess == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
-                     ? DEFAULT_REMOTE_TYPE : NOT_REMOTE;
-    return remoteType == this.getRemoteTypeForURI(aURL, true, remoteType);
+  canLoadURIInRemoteType(aURL, aRemoteType = DEFAULT_REMOTE_TYPE) {
+    // We need a strict equality here because the value of `NOT_REMOTE` is
+    // `null`, and there is a possibility that `undefined` is passed as the
+    // second argument, which might result a load in the parent process.
+    let preferredRemoteType = aRemoteType === NOT_REMOTE
+      ? NOT_REMOTE
+      : DEFAULT_REMOTE_TYPE;
+    return aRemoteType == this.getRemoteTypeForURI(aURL, true, preferredRemoteType);
   },
 
   getRemoteTypeForURI(aURL, aMultiProcess,
                       aPreferredRemoteType = DEFAULT_REMOTE_TYPE,
                       aCurrentUri) {
     if (!aMultiProcess) {
       return NOT_REMOTE;
     }
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -3056,20 +3056,19 @@ var gDetailView = {
       event.stopPropagation();
     });
 
     let {optionsURL, optionsBrowserStyle} = this._addon;
     if (this._addon.isWebExtension) {
       let policy = ExtensionParent.WebExtensionPolicy.getByID(this._addon.id);
       browser.sameProcessAsFrameLoader = policy.extension.groupFrameLoader;
     }
-    let remote = !E10SUtils.canLoadURIInProcess(optionsURL, Services.appinfo.PROCESS_TYPE_DEFAULT);
 
     let readyPromise;
-    if (remote) {
+    if (E10SUtils.canLoadURIInRemoteType(optionsURL, E10SUtils.EXTENSION_REMOTE_TYPE)) {
       browser.setAttribute("remote", "true");
       browser.setAttribute("remoteType", E10SUtils.EXTENSION_REMOTE_TYPE);
       readyPromise = promiseEvent("XULFrameLoaderCreated", browser);
     } else {
       readyPromise = promiseEvent("load", browser, true);
     }
 
     stack.appendChild(browser);