tor-browser

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

shared-workers.https.html (1517B)


      1 <!DOCTYPE html>
      2 <title>Test shared workers aren't shared across fenced frame boundaries.</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/utils.js"></script>
      6 <script src="/common/dispatcher/dispatcher.js"></script>
      7 <script src="resources/utils.js"></script>
      8 <body>
      9 <script>
     10 promise_test(async(t) => {
     11  const fencedframe = await attachFencedFrameContext();
     12  const worker = new SharedWorker(
     13      "/fenced-frame/resources/shared-worker.js");
     14 
     15  const messagePromise = new Promise((resolve, reject) => {
     16    worker.port.onmessage = evt => {
     17      // The main frame should not get a postMessage from the fenced frame's
     18      // SharedWorker, even though the main frame and fenced frame are
     19      // same-origin to each other.
     20      reject();
     21    };
     22  });
     23  await fencedframe.execute(async () => {
     24    // The worker will take anything postMessaged to it and postMessage it to
     25    // all registered ports.
     26    const worker = new SharedWorker(
     27        "/fenced-frame/resources/shared-worker.js");
     28    worker.port.postMessage("message");
     29    await new Promise((resolve) => {
     30      // Sanity check that the postMessage() is making to the fenced frame.
     31      worker.port.onmessage = evt => {
     32        resolve();
     33      };
     34    });
     35  });
     36  const timeout = new Promise(r => t.step_timeout(r, 1000));
     37  await Promise.race([messagePromise, timeout]);
     38 
     39 }, 'Shared workers should not be shared across fenced frame boundaries');
     40 </script>
     41 </body>