blob: f7833b6a90071dafc7e8a0ed1ae3b9e35835e1af [file] [log] [blame]
[email protected]2da6ffa2013-10-01 00:31:351<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
[email protected]2da6ffa2013-10-01 00:31:354<script src="resources/audio-testing.js"></script>
[email protected]efb086342013-11-05 00:56:215<script src="../resources/js-test.js"></script>
[email protected]2da6ffa2013-10-01 00:31:356<script src="resources/biquad-testing.js"></script>
7</head>
8
9<body>
10
11<div id="description"></div>
12<div id="console"></div>
13<script>
14description("Tests DOM exception messages");
15
16var context;
17var otherContext;
18var node;
19var node2;
20var mode;
21
22function runTest() {
23 if (window.testRunner) {
24 testRunner.dumpAsText();
25 }
26
27 context = new webkitAudioContext();
28 otherContext = new webkitAudioContext();
29
[email protected]154cd082013-10-04 19:40:0830 // Test creation of various objects
[email protected]2da6ffa2013-10-01 00:31:3531
[email protected]154cd082013-10-04 19:40:0832 // Invalid number of channels: NotSupportedError
[email protected]2da6ffa2013-10-01 00:31:3533 shouldThrow("context.createBuffer(99, 1, context.sampleRate)");
[email protected]154cd082013-10-04 19:40:0834 // Invalid sample rate: NotSupportedError
[email protected]2da6ffa2013-10-01 00:31:3535 shouldThrow("context.createBuffer(1, 1, 1)");
36 shouldThrow("context.createBuffer(1, 1, 1e6)");
[email protected]154cd082013-10-04 19:40:0837 // Invalid number of frames: NotSupportedError
38 shouldThrow("context.createBuffer(1, 0, context.sampleRate)");
39 // Invalid ArrayBuffer (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:3540 shouldThrow("context.createBuffer(new ArrayBuffer(100), true)");
[email protected]154cd082013-10-04 19:40:0841 // Invalid ArrayBuffer (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:3542 shouldThrow("context.decodeAudioData(null, function() {}, function () {})");
[email protected]154cd082013-10-04 19:40:0843 // Invalid sources (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:3544 shouldThrow("context.createMediaElementSource(null)");
45 shouldThrow("context.createMediaStreamSource(null)");
[email protected]154cd082013-10-04 19:40:0846 // Invalid buffer size: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3547 shouldThrow("context.createScriptProcessor(1, 1, 1)");
[email protected]154cd082013-10-04 19:40:0848 // Invalid number of inputs and outputs: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3549 shouldThrow("context.createScriptProcessor(4096, 100, 1)");
50 shouldThrow("context.createScriptProcessor(4096, 1, 100)");
[email protected]ad2e0e32013-10-04 05:16:2051 shouldNotThrow("context.createScriptProcessor()");
52 shouldNotThrow("context.createScriptProcessor(0)");
53
[email protected]154cd082013-10-04 19:40:0854 // Invalid number of channels: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3555 shouldThrow("context.createChannelSplitter(0)");
56 shouldThrow("context.createChannelSplitter(99)");
57 shouldThrow("context.createChannelMerger(0)");
58 shouldThrow("context.createChannelMerger(99)");
[email protected]154cd082013-10-04 19:40:0859 // Invalid real/imag arrays: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3560 shouldThrow("context.createPeriodicWave(null, null)");
61 shouldThrow("context.createPeriodicWave(new Float32Array(10), null)");
[email protected]154cd082013-10-04 19:40:0862 shouldThrow("context.createPeriodicWave(new Float32Array(4100), new Float32Array(4100))");
63 // Real and imaginary arrays must have the same size: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3564 shouldThrow("context.createPeriodicWave(new Float32Array(10), new Float32Array(7))");
[email protected]154cd082013-10-04 19:40:0865
[email protected]2da6ffa2013-10-01 00:31:3566
67 // Analysers
68 node = context.createAnalyser();
[email protected]154cd082013-10-04 19:40:0869 // Invalid fftSize: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3570 shouldThrow("node.fftSize = 42");
[email protected]154cd082013-10-04 19:40:0871 shouldThrow("node.fftSize = 16");
72 shouldThrow("node.fftSize = 4096");
[email protected]2da6ffa2013-10-01 00:31:3573
[email protected]db30267b2013-10-03 18:43:2674 shouldThrow("node.minDecibels = -10");
75 shouldThrow("node.maxDecibels = -150");
76 shouldThrow("node.smoothingTimeConstant = -0.1");
77 shouldThrow("node.smoothingTimeConstant = 1.5");
78
[email protected]2da6ffa2013-10-01 00:31:3579 // AudioBuffers
80 node = context.createBuffer(1,1, context.sampleRate);
[email protected]154cd082013-10-04 19:40:0881 // Invalid channel index: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3582 shouldThrow("node.getChannelData(2)");
83
84 // AudioNode connections
85 node = context.createGain();
86 node2 = context.createGain();
[email protected]154cd082013-10-04 19:40:0887 // Invalid destination node (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:3588 shouldThrow("node.connect(null, 0, 0)");
[email protected]154cd082013-10-04 19:40:0889 // Invalid input or output index: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:3590 shouldThrow("node.connect(context.destination, 100, 0)");
91 shouldThrow("node.connect(context.destination, 0, 100)");
92 shouldThrow("node.connect(node2.gain, 100)");
93 shouldThrow("node.disconnect(99)");
[email protected]154cd082013-10-04 19:40:0894 // Can't connect to a different context (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:3595 shouldThrow("node.connect(otherContext.destination)");
96
[email protected]154cd082013-10-04 19:40:0897 // Invalid channel count: NotSupportedError
[email protected]2da6ffa2013-10-01 00:31:3598 shouldThrow("node.channelCount = 99");
[email protected]154cd082013-10-04 19:40:0899 // Invalid mode or interpretation (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:35100 mode = "fancy";
101 shouldThrow("node.channelCountMode = mode");
102 shouldThrow("node.channelInterpretation = mode");
103
[email protected]154cd082013-10-04 19:40:08104 // Destination: IndexSizeError
[email protected]2da6ffa2013-10-01 00:31:35105 shouldThrow("context.destination.channelCount = 99");
106
107 // Delay nodes are tested elsewhere, so don't duplicate that work here.
108
109 // OfflineAudioContext
[email protected]154cd082013-10-04 19:40:08110 // Invalid number of channels (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:35111 shouldThrow("new webkitOfflineAudioContext(99, 100, context.sampleRate)");
[email protected]154cd082013-10-04 19:40:08112 // Invalid sample rate. (unspecified error)
[email protected]2da6ffa2013-10-01 00:31:35113 shouldThrow("new webkitOfflineAudioContext(1, 100, 1)");
114 shouldThrow("new webkitOfflineAudioContext(1, 100, 1e6)");
115
[email protected]4e10d032013-10-02 21:48:00116 // WaveShaper types
117 node = context.createWaveShaper();
118 shouldThrow("node.oversample = '9x'");
[email protected]ffd785f2013-10-29 17:19:58119
120 // Start/stop for AudioBufferSourceNodes
121 buffer = context.createBuffer(1,1, context.sampleRate);
122 shouldNotThrow("source = context.createBufferSource()");
[email protected]eed4fa202013-10-31 02:13:29123 shouldNotThrow("source.buffer = buffer");
124 shouldNotThrow("source.start()");
125 shouldNotThrow("source.stop()");
126
[email protected]20b3e8332013-11-01 00:14:05127 // It's not clear from the spec, but I think it's valid to call start(). The spec is silent on
128 // what happens if we call stop() afterwards, so don't call it.
[email protected]eed4fa202013-10-31 02:13:29129 shouldNotThrow("source = context.createBufferSource()");
[email protected]ffd785f2013-10-29 17:19:58130 shouldNotThrow("source.start()");
[email protected]ffd785f2013-10-29 17:19:58131
[email protected]20b3e8332013-11-01 00:14:05132 buffer = context.createBuffer(1,1, context.sampleRate);
133 shouldNotThrow("source = context.createBufferSource()");
134 shouldNotThrow("source.buffer = buffer");
135 shouldThrow("source.stop()");
136
137 buffer = context.createBuffer(1,1, context.sampleRate);
138 shouldNotThrow("source = context.createBufferSource()");
139 shouldNotThrow("source.buffer = buffer");
140 shouldNotThrow("source.start()");
141 shouldThrow("source.start()");
142
143 buffer = context.createBuffer(1,1, context.sampleRate);
144 shouldNotThrow("source = context.createBufferSource()");
145 shouldNotThrow("source.buffer = buffer");
146 shouldNotThrow("source.start()");
147 shouldNotThrow("source.stop()");
[email protected]20b3e8332013-11-01 00:14:05148
149
[email protected]ffd785f2013-10-29 17:19:58150 // Start/stop for OscillatorNodes
151 shouldNotThrow("source = context.createOscillator()");
152 shouldNotThrow("source.start()");
153 shouldNotThrow("source.stop()");
[email protected]20b3e8332013-11-01 00:14:05154
155 shouldNotThrow("osc = context.createOscillator()");
156 shouldThrow("osc.stop()");
157 shouldNotThrow("osc1 = context.createOscillator()");
158 shouldNotThrow("osc1.start()");
159 shouldNotThrow("osc1.stop()");
[email protected]5ab469f2014-02-12 05:59:26160
161 // exponentialRampToValue should throw on non-positive target values.
162 node = context.createGain();
163 node.connect(context.destination);
164 shouldThrow("node.gain.exponentialRampToValueAtTime(-1, 0.1)");
165 shouldThrow("node.gain.exponentialRampToValueAtTime(0, 0.1)");
[email protected]2da6ffa2013-10-01 00:31:35166}
167
168runTest();
169successfullyParsed = true;
170
171</script>
[email protected]2da6ffa2013-10-01 00:31:35172</body>
173</html>