tor-browser

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

broadcastchannel-iframe.html (563B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>A test page that messes with a given SharedArrayBuffer sent from a BroadcastChannel</title>
      4 
      5 <script>
      6 "use strict";
      7 const query = new URLSearchParams(location.search);
      8 const channel = new BroadcastChannel(query.get("channel"));
      9 const i = Number(query.get("index"));
     10 
     11 channel.onmessage = e => {
     12  const sab = e.data.sab;
     13  if (sab === undefined) {
     14    // We only care about "broadcasts" from the window
     15    return;
     16  }
     17 
     18  const view = new Uint8Array(sab);
     19  view[i] = i + 1;
     20  channel.postMessage({ i });
     21 };
     22 </script>