tor-browser

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

shared-worker-name-via-options.html (1294B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test the name property of shared workers mixing constructor options and constructor strings</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#concept-workerglobalscope-name">
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-sharedworker">
      6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-sharedworkerglobalscope-name">
      7 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 
     11 <script>
     12 "use strict";
     13 setup({ single_test: true });
     14 
     15 const name = "my name";
     16 
     17 const worker1 = new SharedWorker("support/shared-name.js", { name });
     18 worker1.port.onmessage = receiveMessage;
     19 
     20 const worker2 = new SharedWorker("support/shared-name.js", { name });
     21 worker2.port.onmessage = receiveMessage;
     22 
     23 const worker3 = new SharedWorker("support/shared-name.js", name);
     24 worker3.port.onmessage = receiveMessage;
     25 
     26 let nextCounterExpected = 1;
     27 function receiveMessage(e) {
     28  const { counter, name: receivedName } = e.data;
     29 
     30  assert_equals(receivedName, name);
     31  assert_equals(counter, nextCounterExpected);
     32 
     33  ++nextCounterExpected;
     34  if (nextCounterExpected === 4) {
     35    done();
     36  }
     37 }
     38 </script>