tor-browser

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

audioworkletprocessor-promises.https.html (1558B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      Test micro task checkpoints in AudioWorkletGlobalScope
      6    </title>
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9    <script src="/webaudio/resources/audit.js"></script>
     10    <meta charset=utf-8>
     11  </head>
     12  <body>
     13    <script id="layout-test-code">
     14        promise_test(async () => {
     15          const context = new AudioContext();
     16 
     17          let filePath = 'processors/promise-processor.js';
     18 
     19          await context.audioWorklet.addModule(filePath);
     20          await context.suspend();
     21          let node1 = new AudioWorkletNode(context, 'promise-processor');
     22          let node2 = new AudioWorkletNode(context, 'promise-processor');
     23 
     24          // Connecting to the destination is not strictly necessary in theory,
     25          // but see
     26          // https://bugs.chromium.org/p/chromium/issues/detail?id=1045926
     27          // for why it is in practice.
     28          node1.connect(node2).connect(context.destination);
     29 
     30          await context.resume();
     31 
     32          // The second node is the one that is going to receive the message,
     33          // per spec: it is the second that will be processed, each time.
     34          const e = await new Promise((resolve) => {
     35            node2.port.onmessage = resolve;
     36          });
     37          context.close();
     38          assert_equals(e.data, "ok",
     39                      `Microtask checkpoints are performed
     40                       in between render quantum`);
     41        }, "test");
     42    </script>
     43  </body>
     44 </html>