diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/media/webaudio/test/test_retrospective-setTargetAtTime.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webaudio/test/test_retrospective-setTargetAtTime.html')
-rw-r--r-- | dom/media/webaudio/test/test_retrospective-setTargetAtTime.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_retrospective-setTargetAtTime.html b/dom/media/webaudio/test/test_retrospective-setTargetAtTime.html new file mode 100644 index 0000000000..9b04fe22bb --- /dev/null +++ b/dom/media/webaudio/test/test_retrospective-setTargetAtTime.html @@ -0,0 +1,51 @@ +<!doctype html> +<meta charset=utf-8> +<title>Test setTargetAtTime with start 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.setTargetAtTime(0.1, 0.5*context.currentTime, 0.1); + test.gain.linearRampToValueAtTime(0.9, 2.0); + + var reference = context.createGain(); + reference.gain.setTargetAtTime(0.1, context.currentTime, 0.1); + 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> |