tor-browser

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

ctor-mediastreamaudiodestination.html (2162B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>MediaStreamAudioDestinationNode Constructor</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7  </head>
      8  <body>
      9    <script>
     10      let context;
     11 
     12      test(t => {
     13        assert_not_equals(
     14            typeof AudioContext, "undefined",
     15            "AudioContext should be defined");
     16        // Need AudioContext, not OfflineAudioContext, for these tests.
     17        context = new AudioContext();
     18      }, 'AudioContext can be created without throwing');
     19 
     20      test(t => {
     21        assert_throws_js(
     22            TypeError,
     23            () => {
     24              new MediaStreamAudioDestinationNode();
     25            },
     26            'no arguments throws TypeError');
     27 
     28          assert_throws_js(TypeError, () => {
     29            new MediaStreamAudioDestinationNode(1);
     30          }, 'invalid context argument throws');
     31 
     32          assert_throws_js(TypeError, () => {
     33            new MediaStreamAudioDestinationNode(context, 42);
     34          }, 'invalid options argument throws');
     35 
     36      }, 'MediaStreamAudioDestinationNode: invalid constructor cases');
     37 
     38      test(t => {
     39        const node = new MediaStreamAudioDestinationNode(context);
     40 
     41        assert_true(node instanceof MediaStreamAudioDestinationNode);
     42        assert_equals(node.numberOfInputs, 1);
     43        assert_equals(node.numberOfOutputs, 0);
     44        assert_equals(node.channelCount, 2);
     45        assert_equals(node.channelCountMode, 'explicit');
     46        assert_equals(node.channelInterpretation, 'speakers');
     47      }, 'MediaStreamAudioDestinationNode: default constructor behavior');
     48 
     49      test(t => {
     50        const node = new MediaStreamAudioDestinationNode(context, {
     51          // An arbitrary but valid, non-default count for this node.
     52          channelCount: 7
     53        });
     54 
     55        assert_equals(
     56            node.channelCount, 7, 'channelCount should be set to 7');
     57        assert_equals(node.channelCountMode, 'explicit');
     58        assert_equals(node.channelInterpretation, 'speakers');
     59      }, 'MediaStreamAudioDestinationNode applies channelCount from options');
     60    </script>
     61  </body>
     62 </html>