tor-browser

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

test_retrospective-linearRampToValueAtTime.html (1467B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Test linearRampToValue with end time in the past</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <script>
      7 function do_test(t, context) {
      8  var source = context.createConstantSource();
      9  source.start();
     10 
     11  var test = context.createGain();
     12  test.gain.linearRampToValueAtTime(0.1, 0.5*context.currentTime);
     13  test.gain.linearRampToValueAtTime(0.9, 2.0);
     14 
     15  var reference = context.createGain();
     16  reference.gain.linearRampToValueAtTime(0.1, context.currentTime);
     17  reference.gain.linearRampToValueAtTime(0.9, 2.0);
     18 
     19  source.connect(test);
     20  source.connect(reference);
     21 
     22  var merger = context.createChannelMerger();
     23  test.connect(merger, 0, 0);
     24  reference.connect(merger, 0, 1);
     25 
     26  var processor = context.createScriptProcessor(0, 2, 0);
     27  merger.connect(processor);
     28  processor.onaudioprocess =
     29    t.step_func_done((e) => {
     30      source.stop();
     31      processor.onaudioprocess = null;
     32 
     33      var testValue = e.inputBuffer.getChannelData(0)[0];
     34      var referenceValue = e.inputBuffer.getChannelData(1)[0];
     35 
     36      assert_equals(testValue, referenceValue,
     37                        "value matches expected");
     38    });
     39 }
     40 
     41 async_test(function(t) {
     42  var context = new AudioContext;
     43  (function waitForTimeAdvance() {
     44    if (context.currentTime == 0) {
     45      t.step_timeout(waitForTimeAdvance, 0);
     46    } else {
     47      do_test(t, context);
     48    }
     49  })();
     50 });
     51 </script>