diff options
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 |