Backed out changeset 4cc80402cf1c (bug 1345990)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 06 May 2017 11:27:33 +0200
changeset 356882 d5cc139abcfdf2b785fe68ee54afdd9283ccfbc2
parent 356881 80d2096d675684e6d06787660069b35f1b6ac7fc
child 356883 e3bceb6eb287275e123cb92c487696c6c7325096
push id31775
push userihsiao@mozilla.com
push dateMon, 08 May 2017 03:10:38 +0000
treeherdermozilla-central@22aaf8bad4df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1345990
milestone55.0a1
backs out4cc80402cf1cd907de1d7d124e620f07171d402f
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 4cc80402cf1c (bug 1345990)
dom/base/test/browser.ini
dom/base/test/browser_force_process_selector.js
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
--- a/dom/base/test/browser.ini
+++ b/dom/base/test/browser.ini
@@ -23,18 +23,16 @@ support-files =
   file_webaudioLoop.html
   plugin.js
 
 [browser_bug593387.js]
 [browser_bug902350.js]
 tags = mcb
 [browser_bug1011748.js]
 [browser_bug1058164.js]
-[browser_force_process_selector.js]
-skip-if = !e10s # this only makes sense with e10s-multi
 [browser_messagemanager_loadprocessscript.js]
 [browser_messagemanager_targetframeloader.js]
 [browser_messagemanager_unload.js]
 [browser_pagehide_on_tab_close.js]
 skip-if = e10s # this tests non-e10s behavior. it's not expected to work in e10s.
 [browser_state_notifications.js]
 skip-if = true # Bug 1271028
 [browser_use_counters.js]
deleted file mode 100644
--- a/dom/base/test/browser_force_process_selector.js
+++ /dev/null
@@ -1,36 +0,0 @@
-"use strict";
-
-// Make sure that BTU.withNewTab({ ..., forceNewProcess: true }) loads
-// new tabs in their own process.
-async function spawnNewAndTest(recur, pids) {
-  await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank", forceNewProcess: true },
-                                    function* (browser) {
-      // Make sure our new browser is in its own process.
-      let newPid = browser.frameLoader.tabParent.osPid;
-      ok(!pids.has(newPid), "new tab is in its own process");
-      pids.add(newPid);
-
-      if (recur) {
-        yield spawnNewAndTest(recur - 1, pids);
-      } else {
-        yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
-          // This browser should share a PID with one of the existing tabs.
-          // This is a todo because the process we end up using is actually
-          // an extra process that gets started early in startup and not one
-          // of the ones we use for the tabs.
-          todo(pids.has(browser.frameLoader.tabParent.osPid),
-               "we should be reusing processes if not asked to force the " +
-               "tab into its own process");
-        });
-      }
-  });
-}
-
-add_task(async function test() {
-  let curPid = gBrowser.selectedBrowser.frameLoader.tabParent.osPid;
-  let maxCount = Services.prefs.getIntPref("dom.ipc.processCount");
-
-  // Use at least one more tab than max processes or at least 5 to make this
-  // test interesting.
-  await spawnNewAndTest(Math.max(maxCount + 1, 5), new Set([ curPid ]));
-});
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -28,39 +28,16 @@ Cu.import("resource://testing-common/Con
 Cc["@mozilla.org/globalmessagemanager;1"]
   .getService(Ci.nsIMessageListenerManager)
   .loadFrameScript(
     "chrome://mochikit/content/tests/BrowserTestUtils/content-utils.js", true);
 
 XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
   "resource:///modules/E10SUtils.jsm");
 
-const PROCESSSELECTOR_CONTRACTID = "@mozilla.org/ipc/processselector;1";
-const DEFAULT_PROCESSSELECTOR_CID =
-  Components.ID(Cc[PROCESSSELECTOR_CONTRACTID].number);
-const OUR_PROCESSSELECTOR_CID =
-  Components.ID("{f9746211-3d53-4465-9aeb-ca0d96de0253}");
-
-// A process selector that always asks for a new process.
-function NewProcessSelector() {
-}
-
-NewProcessSelector.prototype = {
-  classID: OUR_PROCESSSELECTOR_CID,
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentProcessProvider]),
-
-  provideProcess() {
-    return Ci.nsIContentProcessProvider.NEW_PROCESS;
-  }
-};
-
-let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
-let selectorFactory = XPCOMUtils._getFactory(NewProcessSelector);
-registrar.registerFactory(OUR_PROCESSSELECTOR_CID, "", null, selectorFactory);
-
 // For now, we'll allow tests to use CPOWs in this module for
 // some cases.
 Cu.permitCPOWsInScope(this);
 
 var gSendCharCount = 0;
 var gSynthesizeKeyCount = 0;
 var gSynthesizeCompositionCount = 0;
 var gSynthesizeCompositionChangeCount = 0;
@@ -95,122 +72,101 @@ this.BrowserTestUtils = {
    */
   withNewTab: Task.async(function* (options, taskFn) {
     if (typeof(options) == "string") {
       options = {
         gBrowser: Services.wm.getMostRecentWindow("navigator:browser").gBrowser,
         url: options
       }
     }
-    let tab = yield BrowserTestUtils.openNewForegroundTab(options);
+    let tab = yield BrowserTestUtils.openNewForegroundTab(options.gBrowser, options.url);
     let originalWindow = tab.ownerGlobal;
     let result = yield taskFn(tab.linkedBrowser);
     let finalWindow = tab.ownerGlobal;
     if (originalWindow == finalWindow && !tab.closing && tab.linkedBrowser) {
       yield BrowserTestUtils.removeTab(tab);
     } else {
       Services.console.logStringMessage(
         "BrowserTestUtils.withNewTab: Tab was already closed before " +
         "removeTab would have been called");
     }
     return Promise.resolve(result);
   }),
 
   /**
    * Opens a new tab in the foreground.
    *
-   * This function takes an options object (which is preferred) or actual
-   * parameters. The names of the options must correspond to the names below.
-   * gBrowser is required and all other options are optional.
-   *
-   * @param {tabbrowser} gBrowser
+   * @param {tabbrowser} tabbrowser
    *        The tabbrowser to open the tab new in.
    * @param {string} opening (or url)
    *        May be either a string URL to load in the tab, or a function that
    *        will be called to open a foreground tab. Defaults to "about:blank".
    * @param {boolean} waitForLoad
    *        True to wait for the page in the new tab to load. Defaults to true.
    * @param {boolean} waitForStateStop
    *        True to wait for the web progress listener to send STATE_STOP for the
    *        document in the tab. Defaults to false.
    * @param {boolean} forceNewProcess
    *        True to force the new tab to load in a new process. Defaults to
    *        false.
+   * NB: tabbrowser may be an options object containing the rest of the
+   *     parameters.
    *
    * @return {Promise}
    *         Resolves when the tab is ready and loaded as necessary.
    * @resolves The new tab.
    */
   openNewForegroundTab(tabbrowser, ...args) {
     let options;
     if (tabbrowser instanceof Ci.nsIDOMXULElement) {
       // tabbrowser is a tabbrowser, read the rest of the arguments from args.
       let [
         opening = "about:blank",
         waitForLoad = true,
         waitForStateStop = false,
-        forceNewProcess = false,
       ] = args;
 
-      options = { opening, waitForLoad, waitForStateStop, forceNewProcess };
+      options = { opening, waitForLoad, waitForStateStop };
     } else {
       if ("url" in tabbrowser && !("opening" in tabbrowser)) {
         tabbrowser.opening = tabbrowser.url;
       }
 
       let {
         opening = "about:blank",
         waitForLoad = true,
         waitForStateStop = false,
-        forceNewProcess = false,
       } = tabbrowser;
 
       tabbrowser = tabbrowser.gBrowser;
-      options = { opening, waitForLoad, waitForStateStop, forceNewProcess };
+      options = { opening, waitForLoad, waitForStateStop };
     }
 
-    let { opening: opening,
-          waitForLoad: aWaitForLoad,
-          waitForStateStop: aWaitForStateStop
-    } = options;
-
-    let promises, tab;
-    try {
-      // If we're asked to force a new process, replace the normal process
-      // selector with one that always asks for a new process.
-      if (options.forceNewProcess) {
-        registrar.registerFactory(OUR_PROCESSSELECTOR_CID, "",
-                                  PROCESSSELECTOR_CONTRACTID, null);
-      }
+    let { opening: opening, waitForLoad: aWaitForLoad, waitForStateStop: aWaitForStateStop } = options;
 
-      promises = [
-        BrowserTestUtils.switchTab(tabbrowser, function () {
-          if (typeof opening == "function") {
-            opening();
-            tab = tabbrowser.selectedTab;
-          }
-          else {
-            tabbrowser.selectedTab = tab = tabbrowser.addTab(opening);
-          }
-        })
-      ];
+    let tab;
+    let promises = [
+      BrowserTestUtils.switchTab(tabbrowser, function () {
+        if (typeof opening == "function") {
+          opening();
+          tab = tabbrowser.selectedTab;
+        }
+        else {
+          tabbrowser.selectedTab = tab = tabbrowser.addTab(opening);
+        }
+      })
+    ];
 
-      if (aWaitForLoad) {
-        promises.push(BrowserTestUtils.browserLoaded(tab.linkedBrowser));
-      }
-      if (aWaitForStateStop) {
-        promises.push(BrowserTestUtils.browserStopped(tab.linkedBrowser));
-      }
-    } finally {
-      // Restore the original process selector, if needed.
-      if (options.forceNewProcess) {
-        registrar.registerFactory(DEFAULT_PROCESSSELECTOR_CID, "",
-                                  PROCESSSELECTOR_CONTRACTID, null);
-      }
+    if (aWaitForLoad) {
+      promises.push(BrowserTestUtils.browserLoaded(tab.linkedBrowser));
     }
+    if (aWaitForStateStop) {
+      promises.push(BrowserTestUtils.browserStopped(tab.linkedBrowser));
+    }
+
     return Promise.all(promises).then(() => tab);
   },
 
   /**
    * Switches to a tab and resolves when it is ready.
    *
    * @param {tabbrowser} tabbrowser
    *        The tabbrowser.