tor-browser

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

retrospective-linearRampToValueAtTime.html (2568B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <html>
      4  <head>
      5    <title>Test linearRampToValue with end time in the past</title>
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <script src="/webaudio/resources/audit-util.js"></script>
      9    <script src="/webaudio/resources/audit.js"></script>
     10    <script src="retrospective-test.js"></script>
     11  </head>
     12  <body>
     13    <script>
     14      let audit = Audit.createTaskRunner();
     15 
     16      audit.define(
     17          {
     18            label: 'test',
     19            description: 'Test linearRampToValue with end time in the past'
     20          },
     21          (task, should) => {
     22            let {context, source, test, reference} = setupRetrospectiveGraph();
     23 
     24            // Suspend the context at this frame so we can synchronously set up
     25            // automations.
     26            const suspendFrame = 128;
     27 
     28            context.suspend(suspendFrame / context.sampleRate)
     29                .then(() => {
     30                  // Call setTargetAtTime with a time in the past
     31                  test.gain.linearRampToValueAtTime(
     32                      0.1, 0.5 * context.currentTime);
     33                  test.gain.linearRampToValueAtTime(0.9, 1.0);
     34 
     35                  reference.gain.linearRampToValueAtTime(
     36                      0.1, context.currentTime);
     37                  reference.gain.linearRampToValueAtTime(0.9, 1.0);
     38                })
     39                .then(() => context.resume());
     40 
     41            source.start();
     42 
     43            context.startRendering()
     44                .then(resultBuffer => {
     45                  let testValue = resultBuffer.getChannelData(0);
     46                  let referenceValue = resultBuffer.getChannelData(1);
     47 
     48                  // Until the suspendFrame, both should be exactly equal to 1.
     49                  should(
     50                      testValue.slice(0, suspendFrame),
     51                      `Test[0:${suspendFrame - 1}]`)
     52                      .beConstantValueOf(1);
     53                  should(
     54                      referenceValue.slice(0, suspendFrame),
     55                      `Reference[0:${suspendFrame - 1}]`)
     56                      .beConstantValueOf(1);
     57 
     58                  // After the suspendFrame, both should be equal (and not
     59                  // constant)
     60                  should(
     61                      testValue.slice(suspendFrame), `Test[${suspendFrame}:]`)
     62                      .beEqualToArray(referenceValue.slice(suspendFrame));
     63                })
     64                .then(() => task.done());
     65          });
     66 
     67      audit.run();
     68    </script>
     69  </body>
     70 </html>