tor-browser

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

test_broadcastchannel_worker_alive.html (1161B)


      1 <!--
      2  Any copyright is dedicated to the Public Domain.
      3  http://creativecommons.org/publicdomain/zero/1.0/
      4 -->
      5 <!DOCTYPE HTML>
      6 <html>
      7 <!--
      8 Tests of DOM BroadcastChannel in workers
      9 -->
     10 <head>
     11  <title>Test for BroadcastChannel in workers</title>
     12  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     13  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     14 </head>
     15 <body>
     16 <p id="display"></p>
     17 <div id="content" style="display: none">
     18 
     19 </div>
     20 <pre id="test">
     21 <script class="testbody" language="javascript">
     22 
     23 function runTests() {
     24  var id = 0;
     25  (new BroadcastChannel("foobar")).onmessage = function(event) {
     26    info("MSG: " + event.data);
     27 
     28    if (event.data == "READY") {
     29      ok(true, "Worker is ready!");
     30    } else {
     31      is(id, event.data, "The message is correct: " + id);
     32    }
     33 
     34    for (var i = 0; i < 3; ++i) {
     35      SpecialPowers.forceCC();
     36      SpecialPowers.forceGC();
     37    }
     38 
     39    if (id == 5) {
     40      SimpleTest.finish();
     41      return;
     42    }
     43 
     44    event.target.postMessage(++id);
     45  };
     46 
     47  new Worker("broadcastchannel_worker_alive.js");
     48 }
     49 
     50 SimpleTest.waitForExplicitFinish();
     51 runTests();
     52 
     53 </script>
     54 </pre>
     55 </body>
     56 </html>