tor-browser

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

test_disconnectExceptions.html (2269B)


      1 <!DOCTYPE HTML>
      2 <html>
      3  <head>
      4    <title>Test whether we can disconnect an AudioNode</title>
      5    <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6    <script type="text/javascript" src="webaudio.js"></script>
      7    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8  </head>
      9  <body>
     10    <pre id="test">
     11      <script class="testbody" type="text/javascript">
     12      var ctx = new AudioContext();
     13      var sourceBuffer = ctx.createBuffer(2, 256, ctx.sampleRate);
     14      for (var i = 1; i <= 2; i++) {
     15        var data = sourceBuffer.getChannelData(i-1);
     16        for (var j = 0; j < data.length; j++) {
     17            data[j] = i;
     18        }
     19      }
     20 
     21      var source = ctx.createBufferSource();
     22      source.buffer = sourceBuffer;
     23 
     24      var gain1 = ctx.createGain();
     25      var splitter = ctx.createChannelSplitter(2);
     26      var merger = ctx.createChannelMerger(2);
     27      var gain2 = ctx.createGain();
     28      var gain3 = ctx.createGain();
     29 
     30      gain1.connect(splitter);
     31      splitter.connect(gain2, 0);
     32      splitter.connect(gain3, 1);
     33      splitter.connect(merger, 0, 0);
     34      splitter.connect(merger, 1, 1);
     35      gain2.connect(gain3);
     36      gain3.connect(ctx.destination);
     37      merger.connect(ctx.destination);
     38 
     39      expectException(function() {
     40          splitter.disconnect(2);
     41      }, DOMException.INDEX_SIZE_ERR);
     42 
     43      expectNoException(function() {
     44        splitter.disconnect(1);
     45        splitter.disconnect(1);
     46      });
     47 
     48      expectException(function() {
     49        gain1.disconnect(gain2);
     50      }, DOMException.INVALID_ACCESS_ERR);
     51 
     52      expectException(function() {
     53        gain1.disconnect(gain3);
     54        ok(false, 'Should get InvalidAccessError exception');
     55      }, DOMException.INVALID_ACCESS_ERR);
     56 
     57      expectException(function() {
     58        splitter.disconnect(gain2, 2);
     59      }, DOMException.INDEX_SIZE_ERR);
     60 
     61      expectException(function() {
     62        splitter.disconnect(gain1, 0);
     63      }, DOMException.INVALID_ACCESS_ERR);
     64 
     65      expectException(function() {
     66        splitter.disconnect(gain3, 0, 0);
     67      }, DOMException.INVALID_ACCESS_ERR);
     68 
     69      expectException(function() {
     70        splitter.disconnect(merger, 3, 0);
     71      }, DOMException.INDEX_SIZE_ERR);
     72      </script>
     73    </pre>
     74  </body>
     75 </html>