tor-browser

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

test_omt_eager_baseline.html (2445B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test for eager omt baseline compilation</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8  <script type="application/javascript">
      9    SimpleTest.requestLongerTimeout(2);
     10    SimpleTest.waitForExplicitFinish();
     11 
     12    // - A value of 4 for offthread_compilation_strategy will aggressively
     13    //   compile all JS functions omt with bytecode eagerly.
     14    // - 255 for delazification strategy will full parse all functions.
     15    SpecialPowers.pushPrefEnv({set: [
     16      ["dom.expose_test_interfaces", true],
     17      ["javascript.options.baselinejit", true],
     18      ["javascript.options.baselinejit.offthread_compilation_strategy", 4],
     19      ["dom.script_loader.delazification.strategy", 255],
     20      ["dom.script_loader.delazification.max_size", -1],
     21      ["dom.script_loader.delazification.min_mem", 0]
     22    ]});
     23 
     24    async function doTest() {
     25      var iframe = document.getElementById("ifr");
     26      
     27      var dispatchReceived = false;
     28      var compiledFunctions = new Set();
     29      
     30      window.addEventListener("message", function(event) {
     31        if (event.data && event.data.type) {
     32          // Check for function-specific events
     33          if (event.data.type.startsWith("omt_eager_baseline_function: ")) {
     34            const functionName = event.data.type.substring("omt_eager_baseline_function: ".length);
     35            compiledFunctions.add(functionName);
     36          } else if (event.data.type === "omt_eager_baseline_dispatch") {
     37            dispatchReceived = true;
     38          }
     39        }
     40      });
     41      
     42      // Load iframe
     43      iframe.src = "file_omt_eager_baseline.html";
     44 
     45      // Need a long timeout here since this test can take a long time
     46      // on some platforms.
     47      await SimpleTest.promiseWaitForCondition(
     48        () => compiledFunctions.has("fun1") && compiledFunctions.has("fun2") && compiledFunctions.has("fun3"),
     49        "Failed to eagerly compile functions.",
     50        100,
     51        100
     52      );
     53      await SimpleTest.promiseWaitForCondition(
     54        () => dispatchReceived,
     55        "Did not recieve eager baseline compilation dispatch.",
     56        100,
     57        10
     58      );
     59 
     60      ok(true, "All functions were eagerly compiled successfully.");
     61      SimpleTest.finish();
     62    }
     63  </script>
     64 </head>
     65 <body onload="doTest()">
     66  <iframe id="ifr" allowfullscreen></iframe>
     67 </body>
     68 </html>