tor-browser

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

audioworkletnode-construction.https.html (1931B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      Test the construction of AudioWorkletNode with real-time context
      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      let realtimeContext = new AudioContext();
     16 
     17      let filePath = 'processors/dummy-processor.js';
     18 
     19      // Test if an exception is thrown correctly when AWN constructor is
     20      // invoked before resolving |.addModule()| promise.
     21      audit.define(
     22          {label: 'construction-before-module-loading'},
     23          (task, should) => {
     24            should(() => new AudioWorkletNode(realtimeContext, 'dummy'),
     25                   'Creating a node before loading a module should throw.')
     26                .throw(DOMException, 'InvalidStateError');
     27 
     28            task.done();
     29          });
     30 
     31      // Test the construction of AudioWorkletNode after the resolution of
     32      // |.addModule()|. Also the constructor must throw an exception when
     33      // a unregistered node name was given.
     34      audit.define(
     35          {label: 'construction-after-module-loading'},
     36          (task, should) => {
     37            realtimeContext.audioWorklet.addModule(filePath).then(() => {
     38              let dummyWorkletNode =
     39                  new AudioWorkletNode(realtimeContext, 'dummy');
     40              should(dummyWorkletNode instanceof AudioWorkletNode,
     41                     '"dummyWorkletNode" is an instance of AudioWorkletNode')
     42                  .beTrue();
     43              should(() => new AudioWorkletNode(realtimeContext, 'foobar'),
     44                     'Unregistered name "foobar" must throw an exception.')
     45                  .throw();
     46              task.done();
     47            });
     48          });
     49 
     50      audit.run();
     51    </script>
     52  </body>
     53 </html>