tor-browser

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

test-console-worklet.html (1143B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Worklet console generator</title>
      5  <!--
      6    Any copyright is dedicated to the Public Domain.
      7    http://creativecommons.org/publicdomain/zero/1.0/
      8  -->
      9 </head>
     10 
     11 <script type="worklet">
     12 registerProcessor('test-param', class param extends AudioWorkletProcessor {
     13  constructor() {
     14    super();
     15    this.port.onmessage = e => {
     16      console.log("worklet", "string");
     17      console.log("worklet", 42);
     18      console.log("worklet", { object: true });
     19      console.log("worklet", e.data.data); // Log the SharedArrayBuffer
     20    };
     21  }
     22  process(input, output, parameters) {
     23    return true;
     24  }
     25 });
     26 </script>
     27 
     28 <script>
     29 "use strict";
     30 const ac = new AudioContext();
     31 const e = document.querySelector("script[type=worklet]")
     32 const blob = new Blob([e.textContent], {type: "application/javascript"});
     33 const url = URL.createObjectURL(blob);
     34 ac.audioWorklet.addModule(url).then(() => {
     35  const nodea = new AudioWorkletNode(ac, 'test-param');
     36 
     37  // Instantiate and pass a SharedArrayBuffer to the Worklet
     38  const normal_sab = new SharedArrayBuffer(1024);
     39  nodea.port.postMessage({data: normal_sab });
     40 });
     41 </script>