OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="resources/compatibility.js"></script> | |
5 <script src="../resources/js-test.js"></script> | |
6 </head> | |
7 | |
8 <body> | |
9 <script> | |
10 description("Test exceptional arguments for AudioParam timeline events"); | |
11 | |
12 var context; | |
13 var gain; | |
14 | |
15 // For these values, AudioParam methods should throw an error because they
are invalid; only | |
16 // finite values are allowed. | |
17 var targetValues = [Infinity, -Infinity, NaN]; | |
18 | |
19 // For these time values, AudioParam methods should throw an error because
they are | |
20 // invalid. Only finite non-negative values are allowed for any time or ti
me-like parameter. | |
21 var timeValues = [-1, Infinity, -Infinity, NaN]; | |
22 | |
23 // For these duration values, AudioParam methods should throw an error bec
ause they are | |
24 // invalid. Only finite values are allowed for any duration parameter. | |
25 var durationValues = [-1, Infinity, -Infinity, NaN, 0]; | |
26 | |
27 // For these timeConstant values for setTargetAtTime an error must be thro
wn because they are | |
28 // invalid. | |
29 var timeConstantValues = [-1, Infinity, -Infinity, NaN]; | |
30 | |
31 // Just an array for use by setValueCurveAtTime. The length and contents o
f the array are not | |
32 // important. | |
33 var curve = new Float32Array(10); | |
34 | |
35 function runTest() { | |
36 if (window.testRunner) { | |
37 testRunner.dumpAsText(); | |
38 testRunner.waitUntilDone(); | |
39 } | |
40 window.jsTestIsAsync = true; | |
41 | |
42 context = new AudioContext(); | |
43 gain = context.createGain(); | |
44 | |
45 // Test the value parameter | |
46 for (value of targetValues) { | |
47 shouldThrow("gain.gain.setValueAtTime(" + value + ", 1)"); | |
48 shouldThrow("gain.gain.linearRampToValueAtTime(" + value + ", 1)"); | |
49 shouldThrow("gain.gain.exponentialRampToValueAtTime(" + value + ", 1)"
); | |
50 shouldThrow("gain.gain.setTargetAtTime(" + value + ", 1, 1)"); | |
51 } | |
52 | |
53 // Test the time parameter | |
54 for (startTime of timeValues) { | |
55 shouldThrow("gain.gain.setValueAtTime(1, " + startTime + ")"); | |
56 shouldThrow("gain.gain.linearRampToValueAtTime(1, " + startTime + ")")
; | |
57 shouldThrow("gain.gain.exponentialRampToValueAtTime(1, " + startTime +
")"); | |
58 shouldThrow("gain.gain.setTargetAtTime(1, " + startTime + ", 1)"); | |
59 } | |
60 | |
61 // Test time constant | |
62 for (value of timeConstantValues) { | |
63 shouldThrow("gain.gain.setTargetAtTime(1, 1, " + value + ")"); | |
64 } | |
65 | |
66 // Test startTime and duration for setValueCurveAtTime | |
67 for (startTime of timeValues) { | |
68 shouldThrow("gain.gain.setValueCurveAtTime(curve, " + startTime + ", 1
)"); | |
69 } | |
70 for (duration of durationValues) { | |
71 shouldThrow("gain.gain.setValueCurveAtTime(curve, 1, " + duration + ")
"); | |
72 } | |
73 | |
74 finishJSTest(); | |
75 } | |
76 | |
77 runTest(); | |
78 successfullyParsed = true; | |
79 </script> | |
80 </body> | |
81 </html> | |
OLD | NEW |