tor-browser

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

test_oscillatorNode.html (1746B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test the OscillatorNode interface</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 addLoadEvent(function() {
     15 
     16  var context = new AudioContext();
     17  var osc = new OscillatorNode(context);
     18 
     19  is(osc.channelCount, 2, "Oscillator node has 2 input channels by default");
     20  is(osc.channelCountMode, "max", "Correct channelCountMode for the Oscillator node");
     21  is(osc.channelInterpretation, "speakers", "Correct channelCountInterpretation for the Oscillator node");
     22  is(osc.type, "sine", "Correct default type");
     23  expectException(function() {
     24    osc.type = "custom";
     25  }, DOMException.INVALID_STATE_ERR);
     26  is(osc.type, "sine", "Cannot set the type to custom");
     27  is(osc.frequency.value, 440, "Correct default frequency value");
     28  is(osc.detune.value, 0, "Correct default detine value");
     29 
     30  // Make sure that we can set all of the valid type values
     31  var types = [
     32    "sine",
     33    "square",
     34    "sawtooth",
     35    "triangle",
     36  ];
     37  for (var i = 0; i < types.length; ++i) {
     38    osc.type = types[i];
     39  }
     40 
     41  // Verify setPeriodicWave()
     42  var real = new Float32Array([1.0, 0.5, 0.25, 0.125]);
     43  var imag = new Float32Array([1.0, 0.7, -1.0, 0.5]);
     44  osc.setPeriodicWave(context.createPeriodicWave(real, imag));
     45  is(osc.type, "custom", "Failed to set custom waveform");
     46 
     47  expectNoException(function() {
     48    osc.start();
     49  });
     50  expectNoException(function() {
     51    osc.stop();
     52  });
     53 
     54  SimpleTest.finish();
     55 });
     56 
     57 </script>
     58 </pre>
     59 </body>
     60 </html>