tor-browser

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

audionode.html (2526B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      AudioNode: Basic Interface Tests
      6    </title>
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9  </head>
     10  <body>
     11    <script>
     12      test(() => {
     13        let context = new AudioContext();
     14 
     15        let audioNode = new AudioBufferSourceNode(context);
     16 
     17        // Check input and output numbers of AudioSourceNode.
     18        assert_equals(
     19            audioNode.numberOfInputs, 0,
     20            'AudioBufferSource.numberOfInputs');
     21        assert_equals(
     22            audioNode.numberOfOutputs, 1,
     23            'AudioBufferSource.numberOfOutputs');
     24 
     25        // Check input and output numbers of AudioDestinationNode
     26        assert_equals(
     27            context.destination.numberOfInputs, 1,
     28            'AudioContext.destination.numberOfInputs');
     29        assert_equals(
     30            context.destination.numberOfOutputs, 1,
     31            'AudioContext.destination.numberOfOutputs');
     32 
     33        // Try calling connect() method with illegal values.
     34        assert_throws_js(
     35            TypeError, () => audioNode.connect(0, 0, 0),
     36            'audioNode.connect(0, 0, 0)');
     37        assert_throws_js(
     38            TypeError, () => audioNode.connect(null, 0, 0),
     39            'audioNode.connect(null, 0, 0)');
     40        assert_throws_dom(
     41            'IndexSizeError',
     42            () => audioNode.connect(context.destination, 5, 0),
     43            'audioNode.connect(context.destination, 5, 0)');
     44        assert_throws_dom(
     45            'IndexSizeError',
     46            () => audioNode.connect(context.destination, 0, 5),
     47            'audioNode.connect(context.destination, 0, 5)');
     48 
     49        audioNode.connect(context.destination, 0, 0);
     50 
     51        // Create a new context and try to connect the other context's node
     52        // to this one.
     53        let context2 = new AudioContext();
     54        assert_throws_dom(
     55            'InvalidAccessError',
     56            () => audioNode.connect(context2.destination),
     57            'Connecting a node to a different context');
     58 
     59        // 3-arg AudioContext doesn't create an offline context anymore.
     60        assert_throws_js(
     61            TypeError,
     62            () => {let context3 = new AudioContext(1, 44100, 44100);},
     63            'context3 = new AudioContext(1, 44100, 44100)');
     64 
     65        // Ensure it is an EventTarget
     66        assert_true(
     67            audioNode instanceof EventTarget,
     68            'AudioNode is an EventTarget');
     69      }, 'Basic tests for AudioNode API.');
     70    </script>
     71  </body>
     72 </html>