1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
4 <script src=
"resources/compatibility.js"></script>
5 <script src=
"../resources/js-test.js"></script>
10 description("Test exceptional arguments for AudioParam timeline events");
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
];
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 time-like parameter.
21 var timeValues
= [-1, Infinity
, -Infinity
, NaN
];
23 // For these duration values, AudioParam methods should throw an error because they are
24 // invalid. Only finite values are allowed for any duration parameter.
25 var durationValues
= [-1, Infinity
, -Infinity
, NaN
, 0];
27 // Just an array for use by setValueCurveAtTime. The length and contents of the array are not
29 var curve
= new Float32Array(10);
32 if (window
.testRunner
) {
33 testRunner
.dumpAsText();
34 testRunner
.waitUntilDone();
36 window
.jsTestIsAsync
= true;
38 context
= new AudioContext();
39 gain
= context
.createGain();
41 // Test the value parameter
42 for (value
of targetValues
) {
43 shouldThrow("gain.gain.setValueAtTime(" + value
+ ", 1)");
44 shouldThrow("gain.gain.linearRampToValueAtTime(" + value
+ ", 1)");
45 shouldThrow("gain.gain.exponentialRampToValueAtTime(" + value
+ ", 1)");
46 shouldThrow("gain.gain.setTargetAtTime(" + value
+ ", 1, 1)");
49 // Test the time parameter
50 for (startTime
of timeValues
) {
51 shouldThrow("gain.gain.setValueAtTime(1, " + startTime
+ ")");
52 shouldThrow("gain.gain.linearRampToValueAtTime(1, " + startTime
+ ")");
53 shouldThrow("gain.gain.exponentialRampToValueAtTime(1, " + startTime
+ ")");
54 shouldThrow("gain.gain.setTargetAtTime(1, " + startTime
+ ", 1)");
58 for (value
of targetValues
) {
59 shouldThrow("gain.gain.setTargetAtTime(1, 1, " + value
+ ")");
62 // Test startTime and duration for setValueCurveAtTime
63 for (startTime
of timeValues
) {
64 shouldThrow("gain.gain.setValueCurveAtTime(curve, " + startTime
+ ", 1)");
66 for (duration
of durationValues
) {
67 shouldThrow("gain.gain.setValueCurveAtTime(curve, 1, " + duration
+ ")");
74 successfullyParsed
= true;