diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html b/dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html new file mode 100644 index 0000000000..28829e1ec2 --- /dev/null +++ b/dom/media/webaudio/test/test_setValueCurveWithNonFiniteElements.html @@ -0,0 +1,60 @@ +<!DOCTYPE HTML> +<html> +<meta charset=utf-8> +<head> + <title>Bug 1308437 - setValueCurve should throw on non-finite elements</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> +SimpleTest.waitForExplicitFinish(); + +function testInfiniteElement(audioContext, audioParam) { + // create value curve with infinite element + var arr = new Float32Array(5); + arr[0] = 0.5; + arr[1] = 1; + arr[2] = Infinity; + arr[3] = 1; + arr[4] = 0.5; + + try { + audioParam.setValueCurveAtTime(arr, audioContext.currentTime(), 2); + ok(false, "We shouldn't be able to call setValueCurve with Infinity but we can"); + } catch(e) { + ok(e instanceof TypeError, "TypeError is thrown"); + } +}; + +function testNanElement(audioContext, audioParam) { + // create value curve with infinite element + var arr = new Float32Array(5); + arr[0] = 0.5; + arr[1] = 1; + arr[2] = NaN; + arr[3] = 1; + arr[4] = 0.5; + + try { + audioParam.setValueCurveAtTime(arr, audioContext.currentTime(), 2); + ok(false, "We shouldn't be able to call setValueCurve with NaN but we can"); + } catch(e) { + ok(e instanceof TypeError, "TypeError is thrown"); + } +}; + +addLoadEvent(function() { + var audioContext = new AudioContext(); + var gainNode = audioContext.createGain(); + + testInfiniteElement(audioContext, gainNode.gain); + testNanElement(audioContext, gainNode.gain); + + SimpleTest.finish(); +}); +</script> +</pre> +</body> +</html>
\ No newline at end of file |