tor-browser

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

test_mediaStreamAudioSourceNodePassThrough.html (1690B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <meta charset="utf-8">
      4 <head>
      5  <title>Test MediaStreamAudioSourceNode passthrough</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <script type="text/javascript" src="webaudio.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <pre id="test">
     12 <script class="testbody" type="text/javascript">
     13 
     14 function createBuffer(context, delay) {
     15  var buffer = context.createBuffer(2, 2048, context.sampleRate);
     16  for (var i = 0; i < 2048 - delay; ++i) {
     17    buffer.getChannelData(0)[i + delay] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
     18    buffer.getChannelData(1)[i + delay] = -buffer.getChannelData(0)[i + delay];
     19  }
     20  return buffer;
     21 }
     22 
     23 var gTest = {
     24  length: 2048,
     25  skipOfflineContextTests: true,
     26  createGraph(context) {
     27    var sourceGraph = new AudioContext();
     28    var source = sourceGraph.createBufferSource();
     29    source.buffer = createBuffer(context, 0);
     30    var dest = sourceGraph.createMediaStreamDestination();
     31    source.connect(dest);
     32    source.start(0);
     33 
     34    var mediaStreamSource = context.createMediaStreamSource(dest.stream);
     35    // channelCount and channelCountMode should have no effect
     36    mediaStreamSource.channelCount = 1;
     37    mediaStreamSource.channelCountMode = "explicit";
     38 
     39    var srcWrapped = SpecialPowers.wrap(mediaStreamSource);
     40    ok("passThrough" in srcWrapped, "MediaStreamAudioSourceNode should support the passThrough API");
     41    srcWrapped.passThrough = true;
     42 
     43    return mediaStreamSource;
     44  },
     45  createExpectedBuffers(context) {
     46    return context.createBuffer(2, 2048, context.sampleRate);
     47  },
     48 };
     49 
     50 runTest();
     51 
     52 </script>
     53 </pre>
     54 </body>
     55 </html>