dom/media/webaudio/test/test_retrospective-linearRampToValueAtTime.html
author owlishDeveloper <bugzeeeeee@gmail.com>
Thu, 23 Mar 2023 17:05:27 +0000
changeset 657741 75b3c6c4437624f59fcaff278bb8f5b88358e3a6
parent 431954 f35a649bd10f9ec29afb6391926dc833e3e3245d
permissions -rw-r--r--
Bug 1806179 - Add tests for the cookie banner events API r=geckoview-reviewers,m_kato,amejiamarmol Differential Revision: https://phabricator.services.mozilla.com/D172854

<!doctype html>
<meta charset=utf-8>
<title>Test linearRampToValue with end time in the past</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
function do_test(t, context) {
  var source = context.createConstantSource();
  source.start();

  var test = context.createGain();
  test.gain.linearRampToValueAtTime(0.1, 0.5*context.currentTime);
  test.gain.linearRampToValueAtTime(0.9, 2.0);

  var reference = context.createGain();
  reference.gain.linearRampToValueAtTime(0.1, context.currentTime);
  reference.gain.linearRampToValueAtTime(0.9, 2.0);

  source.connect(test);
  source.connect(reference);

  var merger = context.createChannelMerger();
  test.connect(merger, 0, 0);
  reference.connect(merger, 0, 1);

  var processor = context.createScriptProcessor(0, 2, 0);
  merger.connect(processor);
  processor.onaudioprocess =
    t.step_func_done((e) => {
      source.stop();
      processor.onaudioprocess = null;

      var testValue = e.inputBuffer.getChannelData(0)[0];
      var referenceValue = e.inputBuffer.getChannelData(1)[0];

      assert_equals(testValue, referenceValue,
                        "value matches expected");
    });
}

async_test(function(t) {
  var context = new AudioContext;
  (function waitForTimeAdvance() {
    if (context.currentTime == 0) {
      t.step_timeout(waitForTimeAdvance, 0);
    } else {
      do_test(t, context);
    }
  })();
});
</script>