diff options
Diffstat (limited to 'dom/media/webaudio/test/test_retrospective-linearRampToValueAtTime.html')
-rw-r--r-- | dom/media/webaudio/test/test_retrospective-linearRampToValueAtTime.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_retrospective-linearRampToValueAtTime.html b/dom/media/webaudio/test/test_retrospective-linearRampToValueAtTime.html new file mode 100644 index 0000000000..1594a30bd1 --- /dev/null +++ b/dom/media/webaudio/test/test_retrospective-linearRampToValueAtTime.html @@ -0,0 +1,51 @@ +<!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> |