tor-browser

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

test_retrospective-setValueCurveAtTime.html (1402B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>Test SetValueCurve with start 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.setValueCurveAtTime(new Float32Array([1.0, 0.1]), 0.0, 1.0);
     13 
     14  var reference = context.createGain();
     15  reference.gain.setValueCurveAtTime(new Float32Array([1.0, 0.1]), 0.5*context.currentTime, 1.0);
     16 
     17  source.connect(test);
     18  source.connect(reference);
     19 
     20  var merger = context.createChannelMerger();
     21  test.connect(merger, 0, 0);
     22  reference.connect(merger, 0, 1);
     23 
     24  var processor = context.createScriptProcessor(0, 2, 0);
     25  merger.connect(processor);
     26  processor.onaudioprocess =
     27    t.step_func_done((e) => {
     28      source.stop();
     29      processor.onaudioprocess = null;
     30 
     31      var testValue = e.inputBuffer.getChannelData(0)[0];
     32      var referenceValue = e.inputBuffer.getChannelData(1)[0];
     33 
     34      assert_equals(testValue, referenceValue,
     35                        "value matches expected");
     36    });
     37 }
     38 
     39 async_test(function(t) {
     40  var context = new AudioContext;
     41  (function waitForTimeAdvance() {
     42    if (context.currentTime == 0) {
     43      t.step_timeout(waitForTimeAdvance, 0);
     44    } else {
     45      do_test(t, context);
     46    }
     47  })();
     48 });
     49 </script>