tor-browser

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

test_broadcastchannel_sharedWorker.html (1197B)


      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 SharedWorkers
      9 -->
     10 <head>
     11  <title>Test for BroadcastChannel in SharedWorkers</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 worker = new SharedWorker("broadcastchannel_sharedWorker.js");
     25 
     26  var bc = new BroadcastChannel("foobar");
     27 
     28  worker.port.onmessage = function(event) {
     29    if (event.data == "READY") {
     30      ok(true, "SharedWorker is ready!");
     31      bc.postMessage("hello world from the window");
     32    } else {
     33      ok(false, "Something wrong happened");
     34    }
     35  };
     36 
     37  bc.onmessage = function(event) {
     38    is("hello world from the worker", event.data, "The message matches!");
     39    bc.close();
     40    SimpleTest.finish();
     41  };
     42 
     43  worker.port.postMessage("go");
     44 }
     45 
     46 SimpleTest.waitForExplicitFinish();
     47 runTests();
     48 
     49 </script>
     50 </pre>
     51 </body>
     52 </html>