tor-browser

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

test_waveShaperInvalidLengthCurve.html (1648B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test WaveShaperNode with an invalid 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 var gTest = {
     14  length: 2048,
     15  numberOfChannels: 1,
     16  createGraph(context) {
     17    var source = context.createBufferSource();
     18    source.buffer = this.buffer;
     19 
     20    var shaper = context.createWaveShaper();
     21 
     22    expectException(() => {
     23        shaper.curve = new Float32Array(0);
     24    }, DOMException.INVALID_STATE_ERR);
     25 
     26    is(shaper.curve, null, "The curve mustn't have been set");
     27 
     28    expectException(() => {
     29        shaper.curve = new Float32Array(1);
     30    }, DOMException.INVALID_STATE_ERR);
     31 
     32    is(shaper.curve, null, "The curve mustn't have been set");
     33 
     34    expectNoException(() => {
     35        shaper.curve = new Float32Array(2);
     36    });
     37 
     38    isnot(shaper.curve, null, "The curve must have been set");
     39 
     40    expectNoException(() => {
     41        shaper.curve = null;
     42    });
     43 
     44    is(shaper.curve, null, "The curve must be null by default");
     45 
     46    source.connect(shaper);
     47 
     48    source.start(0);
     49    return shaper;
     50  },
     51  createExpectedBuffers(context) {
     52    var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
     53    for (var i = 0; i < 2048; ++i) {
     54      expectedBuffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
     55    }
     56    this.buffer = expectedBuffer;
     57    return expectedBuffer;
     58  },
     59 };
     60 
     61 runTest();
     62 
     63 </script>
     64 </pre>
     65 </body>
     66 </html>