tor-browser

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

Worker-postMessage-happens-in-parallel.https.html (860B)


      1 <!DOCTYPE html>
      2 <title>Test that calling "worker.postMessage()" will occur truly in parallel to the main JS thread performing other computation.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6 promise_test(t => {
      7  return new Promise(resolve => {
      8    let worker = new Worker("support/Worker-postMessage-happens-in-parallel.js");
      9    worker.postMessage('init');
     10    worker.onmessage = () => {
     11      let sab = new Uint8Array(new SharedArrayBuffer(16));
     12      worker.postMessage(sab);
     13      let end = performance.now() + 30*1000;
     14      while(sab[0] != 1 && performance.now() < end) /*wait to join with the result*/;
     15      assert_true(sab[0] == 1);
     16      resolve();
     17    };
     18  });
     19 }, 'Tests that calling "worker.postMessage()" will occur truly in parallel to the main JS thread');
     20 </script>