tor-browser

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

audiosource-time-limits.html (2149B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      Test Scheduled Sources with Huge Time Limits
      6    </title>
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9    <script src="/webaudio/resources/audit-util.js"></script>
     10    <script src="/webaudio/resources/audioparam-testing.js"></script>
     11  </head>
     12  <body>
     13    <script>
     14      const sampleRate = 48000;
     15      const renderFrames = 1000;
     16 
     17      promise_test(async () => {
     18        // We only need to generate a small number of frames for this test.
     19        const context = new OfflineAudioContext(1, renderFrames, sampleRate);
     20        // Constant source of amplitude 1, looping.
     21        const src = new AudioBufferSourceNode(context, {
     22          buffer: createConstantBuffer(context, 1, 1),
     23          loop: true,
     24        });
     25 
     26        // Create the graph and go!
     27        const endTime = 1e300;
     28        src.connect(context.destination);
     29        src.start();
     30        src.stop(endTime);
     31 
     32        const resultBuffer = await context.startRendering();
     33        const result = resultBuffer.getChannelData(0);
     34        assert_array_equals(
     35            result,
     36            new Float32Array(result.length).fill(1),
     37            `Output from AudioBufferSource.stop(${endTime})`);
     38      }, 'buffersource: huge stop time');
     39 
     40      promise_test(async () => {
     41        // We only need to generate a small number of frames for this test.
     42        const context = new OfflineAudioContext(1, renderFrames, sampleRate);
     43        const src = new OscillatorNode(context);
     44 
     45        // Create the graph and go!
     46        const endTime = 1e300;
     47        src.connect(context.destination);
     48        src.start();
     49        src.stop(endTime);
     50 
     51        const resultBuffer = await context.startRendering();
     52        const result = resultBuffer.getChannelData(0);
     53        // The buffer should not be empty.  Just find the max and verify
     54        // that it's not zero.
     55        const max = Math.max(...result);
     56        assert_greater_than(
     57            max, 0, `Peak amplitude from oscillator.stop(${endTime})`);
     58      }, 'oscillator: huge stop time');
     59    </script>
     60  </body>
     61 </html>