tor-browser

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

test_Preallocated.html (1584B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 Test that the preallocated process starts up.
      5 -->
      6 <head>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 
     13 <script type="application/javascript">
     14 "use strict";
     15 
     16 SimpleTest.waitForExplicitFinish();
     17 
     18 function expectProcessCreated() {
     19  /* eslint-env mozilla/chrome-script */
     20  return new Promise(resolve => {
     21    function parentExpectProcessCreated() {
     22      let topic = "ipc:content-initializing";
     23      let obs = { observe() {
     24        Services.obs.removeObserver(obs, topic);
     25        sendAsyncMessage("process-created");
     26      }};
     27      Services.obs.addObserver(obs, topic);
     28    }
     29 
     30    let helper = SpecialPowers.loadChromeScript(parentExpectProcessCreated);
     31    SimpleTest.registerCleanupFunction(function() { helper.destroy(); });
     32    helper.addMessageListener("process-created", resolve);
     33  });
     34 }
     35 
     36 expectProcessCreated().then(() => {
     37  ok(true, "Process creation detected.");
     38  SimpleTest.finish();
     39 });
     40 
     41 // Kill existing preallocated process.
     42 SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processPrelaunch.enabled", false]]}).then(() => {
     43  // Make sure we have the capacity to launch preallocated process.
     44  SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 100]]}).then(() => {
     45    // Enable preallocated process and run the test.
     46    SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processPrelaunch.enabled", true]]});
     47  });
     48 });
     49 </script>
     50 </body>
     51 </html>