tor-browser

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

audioparam-large-endtime.html (2557B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      AudioParam with Huge End Time
      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/audit.js"></script>
     11  </head>
     12  <body>
     13    <script id="layout-test-code">
     14      let sampleRate = 48000;
     15      // Render for some small (but fairly arbitrary) time.
     16      let renderDuration = 0.125;
     17      // Any huge time value that won't fit in a size_t (2^64 on a 64-bit
     18      // machine).
     19      let largeTime = 1e300;
     20 
     21      let audit = Audit.createTaskRunner();
     22 
     23      // See crbug.com/582701.  Create an audioparam with a huge end time and
     24      // verify that to automation is run.  We don't care about the actual
     25      // results, just that it runs.
     26 
     27      // Test linear ramp with huge end time
     28      audit.define('linearRamp', (task, should) => {
     29        let graph = createGraph();
     30        graph.gain.gain.linearRampToValueAtTime(0.1, largeTime);
     31 
     32        graph.source.start();
     33        graph.context.startRendering()
     34            .then(function(buffer) {
     35              should(true, 'linearRampToValue(0.1, ' + largeTime + ')')
     36                  .message('successfully rendered', 'unsuccessfully rendered');
     37            })
     38            .then(() => task.done());
     39      });
     40 
     41      // Test exponential ramp with huge end time
     42      audit.define('exponentialRamp', (task, should) => {
     43        let graph = createGraph();
     44        graph.gain.gain.exponentialRampToValueAtTime(.1, largeTime);
     45 
     46        graph.source.start();
     47        graph.context.startRendering()
     48            .then(function(buffer) {
     49              should(true, 'exponentialRampToValue(0.1, ' + largeTime + ')')
     50                  .message('successfully rendered', 'unsuccessfully rendered');
     51            })
     52            .then(() => task.done());
     53      });
     54 
     55      audit.run();
     56 
     57      // Create the graph and return the context, the source, and the gain node.
     58      function createGraph() {
     59        let context =
     60            new OfflineAudioContext(1, renderDuration * sampleRate, sampleRate);
     61        let src = context.createBufferSource();
     62        src.buffer = createConstantBuffer(context, 1, 1);
     63        src.loop = true;
     64        let gain = context.createGain();
     65        src.connect(gain);
     66        gain.connect(context.destination);
     67        gain.gain.setValueAtTime(1, 0.1 / sampleRate);
     68 
     69        return {context: context, gain: gain, source: src};
     70      }
     71    </script>
     72  </body>
     73 </html>