tor-browser

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

test_bug966247.html (1223B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test whether an audio file played with a volume set to 0 plays silence</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body>
      9 <audio preload=none src="ting-48k-1ch.ogg" controls> </audio>
     10 <script>
     11  SimpleTest.waitForExplicitFinish();
     12 
     13  var count = 20;
     14 
     15  function isSilent(b) {
     16    for (var i = 0; i < b.length; i++) {
     17      if (b[i] != 0.0) {
     18        return false;
     19      }
     20    }
     21    return true;
     22  }
     23 
     24  var a = document.getElementsByTagName("audio")[0];
     25  a.volume = 0.0;
     26  var ac = new AudioContext();
     27  var measn = ac.createMediaElementSource(a);
     28  var sp = ac.createScriptProcessor();
     29 
     30  sp.onaudioprocess = function(e) {
     31    var inputBuffer = e.inputBuffer.getChannelData(0);
     32    ok(isSilent(inputBuffer), "The volume is set to 0, so all the elements of the buffer are supposed to be equal to 0.0");
     33  }
     34  // Connect the MediaElementAudioSourceNode to the ScriptProcessorNode to check
     35  // the audio volume.
     36  measn.connect(sp);
     37  a.play();
     38 
     39  a.addEventListener("ended", function() {
     40    sp.onaudioprocess = null;
     41    SimpleTest.finish();
     42  });
     43 
     44 </script>
     45 </body>
     46 </html>