tor-browser

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

audioworkletprocessor-no-process-function.https.html (1508B)


      1 <!doctype html>
      2 <title>Test consistency of processing after resume()</title>
      3 <script src=/resources/testharness.js></script>
      4 <script src=/resources/testharnessreport.js></script>
      5 <script>
      6 
      7 const modulePath = 'audioworkletprocessor-no-process.js';
      8 
      9 // Verifies that an AudioWorkletProcessor without a defined process function
     10 // will throw an error when process() is called during the rendering quantum,
     11 // rather than during registration or construction.
     12 // https://webaudio.github.io/web-audio-api/#rendering-loop.
     13 promise_test(async () => {
     14  // Ensures that no error occurs during registration (.addModule) or
     15  // construction (new AudioWorkletNode), but in during processing
     16  // after context.resume().
     17  const context = new AudioContext();
     18  await context.suspend();
     19 
     20  // Registers the processor.
     21  await context.audioWorklet.addModule(modulePath);
     22 
     23  // Calls the constructor of the processor.
     24  const node =
     25      new AudioWorkletNode(context, 'audioworkletprocessor-no-process');
     26  await new Promise((resolve) => {
     27    node.port.onmessage = (event) => {
     28      assert_equals(event.data.state, 'created');
     29      resolve();
     30    }
     31  });
     32 
     33  // `context.resume()` should trigger the processor to start processing,
     34  // which will throw an error for an undefined process() method.
     35  return new Promise(async (resolve) => {
     36    node.onprocessorerror = (event) => {
     37      resolve();
     38    };
     39 
     40    await context.resume();
     41  });
     42 }, 'Test an AudioWorkletProcessor with undefined process function.');
     43 
     44 </script>