diff --git a/dom/base/test/browser.ini b/dom/base/test/browser.ini index bc6eadf73fed..e58334720713 100644 --- a/dom/base/test/browser.ini +++ b/dom/base/test/browser.ini @@ -28,8 +28,6 @@ support-files = 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] diff --git a/dom/base/test/browser_force_process_selector.js b/dom/base/test/browser_force_process_selector.js deleted file mode 100644 index ee179a036608..000000000000 --- 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 ])); -}); diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index 5653fd5ca779..1f3bf32dd521 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -33,29 +33,6 @@ Cc["@mozilla.org/globalmessagemanager;1"] 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); @@ -100,7 +77,7 @@ this.BrowserTestUtils = { 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; @@ -117,11 +94,7 @@ this.BrowserTestUtils = { /** * 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 @@ -134,6 +107,8 @@ this.BrowserTestUtils = { * @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. @@ -147,10 +122,9 @@ this.BrowserTestUtils = { 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; @@ -160,42 +134,26 @@ this.BrowserTestUtils = { 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; - 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 tab; - let promises = [ - BrowserTestUtils.switchTab(tabbrowser, function () { - if (typeof opening == "function") { - opening(); - tab = tabbrowser.selectedTab; - } - else { - tabbrowser.selectedTab = tab = tabbrowser.addTab(opening); - } - }) - ]; - } finally { - // Restore the original process selector, if needed. - if (options.forceNewProcess) { - registrar.registerFactory(DEFAULT_PROCESSSELECTOR_CID, "", - PROCESSSELECTOR_CONTRACTID, null); - } - } + 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));