tor-browser

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

test_bug1118372.html (1210B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test WaveShaperNode with no curve</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 
     13 SimpleTest.waitForExplicitFinish();
     14 
     15 addLoadEvent(function() {
     16  var context = new OfflineAudioContext(1, 2048, 44100);
     17 
     18  var osc=context.createOscillator();
     19  var gain=context.createGain();
     20  var shaper=context.createWaveShaper();
     21  gain.gain.value=0.1;
     22  shaper.curve=new Float32Array([-0.5,-0.5,1,1]);
     23 
     24  osc.connect(gain);
     25  gain.connect(shaper);
     26  shaper.connect(context.destination);
     27  osc.start(0);
     28 
     29  context.startRendering().then(function(buffer) {
     30    var samples = buffer.getChannelData(0);
     31    // the signal should be scaled
     32    var failures = 0;
     33    for (var i = 0; i < 2048; ++i) {
     34      if (samples[i] > 0.5) {
     35        failures = failures + 1;
     36      }
     37    }
     38    ok(failures == 0, "signal should have been rescaled by gain: found " + failures + " points too loud.");
     39    SimpleTest.finish();
     40  });
     41 });
     42 
     43 </script>
     44 </pre>
     45 </body>
     46 </html>