tor-browser

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

worklet_audioWorklet_WASM_features.js (894B)


      1 class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
      2  constructor(...args) {
      3    super(...args);
      4    this.port.postMessage(testModules());
      5  }
      6 
      7  process() {
      8    // Do nothing, output silence
      9    return true;
     10  }
     11 }
     12 
     13 function testModule(binary) {
     14  try {
     15    new WebAssembly.Module(binary);
     16  } catch (error) {
     17    if (error instanceof WebAssembly.CompileError) {
     18      return error.message;
     19    }
     20    return "unknown error";
     21  }
     22  return true;
     23 }
     24 
     25 // TODO: test more features
     26 function testModules() {
     27  /*
     28    js -e '
     29      t = wasmTextToBinary(`
     30        (module
     31          (tag)
     32        )
     33      `);
     34      print(t)
     35    '
     36  */
     37  // eslint-disable-next-line
     38  const exceptionHandlingCode = new Uint8Array([
     39    0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 13, 3, 1, 0, 0,
     40  ]);
     41  return testModule(exceptionHandlingCode);
     42 }
     43 
     44 registerProcessor("wasm", WasmProcessWorkletProcessor);