blob: 28829e1ec2d5191315833c2b1b02b15f6d540120 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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>
|