summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-destinationnode-interface/destination.html
blob: 1af0e0f010b3c83c36e705c537510ee91159fb38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
  <head>
    <title>
      AudioDestinationNode
    </title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
    <script>
      function assert_doesnt_throw(f, desc) {
        try {
          f();
        } catch (e) {
          assert_true(false, desc);
          return;
        }
        assert_true(true, desc);
      }

      test(function() {
          var ac = new AudioContext();

          assert_equals(ac.destination.channelCount, 2,
              "A DestinationNode should have two channels by default");

          assert_greater_than_equal(ac.destination.maxChannelCount, 2,
            "maxChannelCount should be >= 2");

          assert_throws_dom("IndexSizeError", function() {
              ac.destination.channelCount = ac.destination.maxChannelCount + 1
              }, `Setting the channelCount to something greater than
                  the maxChannelCount should throw IndexSizeError`);

          assert_throws_dom("NotSupportedError", function() {
              ac.destination.channelCount = 0;
          }, "Setting the channelCount to 0 should throw NotSupportedError");

          assert_doesnt_throw(function() {
              ac.destination.channelCount = ac.destination.maxChannelCount;
          }, "Setting the channelCount to maxChannelCount should not throw");

          assert_doesnt_throw(function() {
              ac.destination.channelCount = 1;
          }, "Setting the channelCount to 1 should not throw");
      });

    </script>
  </body>
</html>