tor-browser

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

audioworklet-addmodule-resolution.https.html (2261B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      Test the invocation order of AudioWorklet.addModule() and BaseAudioContext
      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  </head>
     11  <body>
     12    <script id="layout-test-code">
     13      let audit = Audit.createTaskRunner();
     14 
     15      setup(() => {
     16        let sampleRate = 48000;
     17        let realtimeContext = new AudioContext();
     18        let offlineContext = new OfflineAudioContext(1, sampleRate, sampleRate);
     19 
     20        let filePath = 'processors/dummy-processor.js';
     21 
     22        // Test if the browser does not crash upon addModule() call after the
     23        // realtime context construction.
     24        audit.define(
     25            {label: 'module-loading-after-realtime-context-creation'},
     26            (task, should) => {
     27              let dummyWorkletNode =
     28                  new AudioWorkletNode(realtimeContext, 'dummy');
     29              dummyWorkletNode.connect(realtimeContext.destination);
     30              should(dummyWorkletNode instanceof AudioWorkletNode,
     31                     '"dummyWorkletNode" is an instance of AudioWorkletNode ' +
     32                     'from realtime context')
     33                  .beTrue();
     34              task.done();
     35            });
     36 
     37        // Test if the browser does not crash upon addModule() call after the
     38        // offline context construction.
     39        audit.define(
     40            {label: 'module-loading-after-offline-context-creation'},
     41            (task, should) => {
     42              let dummyWorkletNode =
     43                  new AudioWorkletNode(offlineContext, 'dummy');
     44              dummyWorkletNode.connect(offlineContext.destination);
     45              should(dummyWorkletNode instanceof AudioWorkletNode,
     46                     '"dummyWorkletNode" is an instance of AudioWorkletNode ' +
     47                     'from offline context')
     48                  .beTrue();
     49              task.done();
     50            });
     51 
     52        Promise.all([
     53            realtimeContext.audioWorklet.addModule(filePath),
     54            offlineContext.audioWorklet.addModule(filePath)
     55          ]).then(() => {
     56            audit.run();
     57          });
     58      });
     59    </script>
     60  </body>
     61 </html>