tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_force_process_selector.js (1293B)


      1 "use strict";
      2 
      3 const CONTENT_CREATED = "ipc:content-created";
      4 
      5 // Make sure that BTU.withNewTab({ ..., forceNewProcess: true }) loads
      6 // new tabs in their own process.
      7 async function spawnNewAndTest(recur, pids) {
      8  await BrowserTestUtils.withNewTab(
      9    { gBrowser, url: "about:blank", forceNewProcess: true },
     10    async function (browser) {
     11      // Make sure our new browser is in its own process.
     12      let newPid = browser.frameLoader.remoteTab.osPid;
     13      ok(!pids.has(newPid), "new tab is in its own process: " + recur);
     14      pids.add(newPid);
     15 
     16      if (recur) {
     17        await spawnNewAndTest(recur - 1, pids);
     18      } else {
     19        await BrowserTestUtils.withNewTab(
     20          { gBrowser, url: "about:blank" },
     21          function (lastBrowser) {
     22            let lastPid = lastBrowser.frameLoader.remoteTab.osPid;
     23            ok(pids.has(lastPid), "final tab cannot be in its own process");
     24          }
     25        );
     26      }
     27    }
     28  );
     29 }
     30 
     31 add_task(async function test() {
     32  let curPid = gBrowser.selectedBrowser.frameLoader.remoteTab.osPid;
     33  let maxCount = Services.prefs.getIntPref("dom.ipc.processCount");
     34 
     35  // Use at least one more tab than max processes or at least 5 to make this
     36  // test interesting.
     37  await spawnNewAndTest(Math.max(maxCount + 1, 5), new Set([curPid]));
     38 });