diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webaudio/test/test_retrospective-setValueAtTime.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webaudio/test/test_retrospective-setValueAtTime.html')
-rw-r--r-- | dom/media/webaudio/test/test_retrospective-setValueAtTime.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_retrospective-setValueAtTime.html b/dom/media/webaudio/test/test_retrospective-setValueAtTime.html new file mode 100644 index 0000000000..b9657ef211 --- /dev/null +++ b/dom/media/webaudio/test/test_retrospective-setValueAtTime.html @@ -0,0 +1,54 @@ +<!DOCTYPE html> +<title>Test setValueAtTime with startTime 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(); + + // Use a ramp of slope 1/sample to measure time. + // The end value is the extent of exact precision in single precision float. + const rampEnd = Math.pow(2, 24); + const rampEndSeconds = rampEnd / context.sampleRate; + var test = context.createGain(); + test.gain.setValueAtTime(0.0, 0.5*context.currentTime); + test.gain.linearRampToValueAtTime(rampEnd, rampEndSeconds); + + var reference = context.createGain(); + reference.gain.setValueAtTime(0.0, context.currentTime); + reference.gain.linearRampToValueAtTime(rampEnd, rampEndSeconds); + + 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, + "ramp 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> |