[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
hongchan | f908584 | 2016-08-05 00:33:17 | [diff] [blame] | 4 | <script src="../resources/js-test.js"></script> |
[email protected] | f846f5a | 2014-03-25 17:33:11 | [diff] [blame] | 5 | <script src="resources/compatibility.js"></script> |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 6 | <script src="resources/audio-testing.js"></script> |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 7 | <script src="resources/biquad-testing.js"></script> |
| 8 | </head> |
| 9 | |
| 10 | <body> |
| 11 | |
| 12 | <div id="description"></div> |
| 13 | <div id="console"></div> |
| 14 | <script> |
| 15 | description("Tests DOM exception messages"); |
| 16 | |
| 17 | var context; |
| 18 | var otherContext; |
| 19 | var node; |
| 20 | var node2; |
| 21 | var mode; |
[email protected] | 1d4178a | 2014-09-26 21:37:44 | [diff] [blame] | 22 | var panner; |
[email protected] | 7baad898 | 2014-09-29 22:11:48 | [diff] [blame] | 23 | var script; |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 24 | |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 25 | function shouldThrowAndBeUnchanged(attr, value) { |
| 26 | shouldThrow(attr + " = " + value); |
| 27 | shouldNotBe(attr, value); |
| 28 | } |
| 29 | |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 30 | function runTest() { |
| 31 | if (window.testRunner) { |
| 32 | testRunner.dumpAsText(); |
| 33 | } |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 34 | |
[email protected] | f846f5a | 2014-03-25 17:33:11 | [diff] [blame] | 35 | context = new AudioContext(); |
| 36 | otherContext = new AudioContext(); |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 37 | |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 38 | // Test creation of various objects |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 39 | |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 40 | // Invalid number of channels: NotSupportedError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 41 | shouldThrow("context.createBuffer(99, 1, context.sampleRate)"); |
[email protected] | ace011c | 2014-05-08 22:10:03 | [diff] [blame] | 42 | shouldThrow("context.createBuffer(0, 1, context.sampleRate)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 43 | // Invalid sample rate: NotSupportedError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 44 | shouldThrow("context.createBuffer(1, 1, 1)"); |
| 45 | shouldThrow("context.createBuffer(1, 1, 1e6)"); |
[email protected] | c867899 | 2014-03-25 23:51:18 | [diff] [blame] | 46 | // Check valid values from crbug.com/344375 |
| 47 | shouldNotThrow("context.createBuffer(1, 1, 3000)"); |
| 48 | shouldNotThrow("context.createBuffer(1, 1, 192000)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 49 | // Invalid number of frames: NotSupportedError |
| 50 | shouldThrow("context.createBuffer(1, 0, context.sampleRate)"); |
[email protected] | c5f32c5a8 | 2014-04-14 18:19:12 | [diff] [blame] | 51 | // 2-arg createBuffer not allowed. |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 52 | shouldThrow("context.createBuffer(new ArrayBuffer(100), true)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 53 | // Invalid sources (unspecified error) |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 54 | shouldThrow("context.createMediaElementSource(null)"); |
| 55 | shouldThrow("context.createMediaStreamSource(null)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 56 | // Invalid buffer size: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 57 | shouldThrow("context.createScriptProcessor(1, 1, 1)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 58 | // Invalid number of inputs and outputs: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 59 | shouldThrow("context.createScriptProcessor(4096, 100, 1)"); |
| 60 | shouldThrow("context.createScriptProcessor(4096, 1, 100)"); |
[email protected] | ad2e0e3 | 2013-10-04 05:16:20 | [diff] [blame] | 61 | shouldNotThrow("context.createScriptProcessor()"); |
| 62 | shouldNotThrow("context.createScriptProcessor(0)"); |
| 63 | |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 64 | // Invalid number of channels: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 65 | shouldThrow("context.createChannelSplitter(0)"); |
| 66 | shouldThrow("context.createChannelSplitter(99)"); |
| 67 | shouldThrow("context.createChannelMerger(0)"); |
| 68 | shouldThrow("context.createChannelMerger(99)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 69 | // Invalid real/imag arrays: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 70 | shouldThrow("context.createPeriodicWave(null, null)"); |
| 71 | shouldThrow("context.createPeriodicWave(new Float32Array(10), null)"); |
[email protected] | 6843aa4 | 2015-07-23 19:34:50 | [diff] [blame] | 72 | // Verify that we can use large arrays with no limit. Roughly. |
| 73 | shouldNotThrow("context.createPeriodicWave(new Float32Array(4100), new Float32Array(4100))"); |
| 74 | shouldNotThrow("context.createPeriodicWave(new Float32Array(8192), new Float32Array(8192))"); |
| 75 | shouldNotThrow("context.createPeriodicWave(new Float32Array(10000), new Float32Array(10000))"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 76 | // Real and imaginary arrays must have the same size: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 77 | shouldThrow("context.createPeriodicWave(new Float32Array(10), new Float32Array(7))"); |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 78 | |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 79 | |
| 80 | // Analysers |
| 81 | node = context.createAnalyser(); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 82 | // Invalid fftSize: IndexSizeError |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 83 | shouldThrowAndBeUnchanged("node.fftSize", "42"); |
| 84 | shouldThrowAndBeUnchanged("node.fftSize", "16"); |
[email protected] | 9a535ba | 2015-01-13 20:56:19 | [diff] [blame] | 85 | shouldNotThrow("node.fftSize = 32768"); |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 86 | shouldThrowAndBeUnchanged("node.fftSize", "65536"); |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 87 | |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 88 | shouldThrowAndBeUnchanged("node.minDecibels", "-10"); |
| 89 | shouldThrowAndBeUnchanged("node.maxDecibels", "-150"); |
| 90 | shouldThrowAndBeUnchanged("node.minDecibels", "-30"); |
| 91 | shouldThrowAndBeUnchanged("node.maxDecibels", "-100"); |
| 92 | |
| 93 | shouldThrowAndBeUnchanged("node.smoothingTimeConstant", "-0.1"); |
| 94 | shouldThrowAndBeUnchanged("node.smoothingTimeConstant", "1.5"); |
[email protected] | db30267b | 2013-10-03 18:43:26 | [diff] [blame] | 95 | |
philipj | eb44026 | 2015-12-04 21:20:39 | [diff] [blame] | 96 | shouldThrow("node.getFloatFrequencyData(null)"); |
| 97 | shouldThrow("node.getByteFrequencyData(null)"); |
| 98 | shouldThrow("node.getFloatTimeDomainData(null)"); |
| 99 | shouldThrow("node.getByteTimeDomainData(null)"); |
| 100 | |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 101 | // AudioBuffers |
| 102 | node = context.createBuffer(1,1, context.sampleRate); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 103 | // Invalid channel index: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 104 | shouldThrow("node.getChannelData(2)"); |
| 105 | |
| 106 | // AudioNode connections |
| 107 | node = context.createGain(); |
| 108 | node2 = context.createGain(); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 109 | // Invalid destination node (unspecified error) |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 110 | shouldThrow("node.connect(null, 0, 0)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 111 | // Invalid input or output index: IndexSizeError |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 112 | shouldThrow("node.connect(context.destination, 100, 0)"); |
| 113 | shouldThrow("node.connect(context.destination, 0, 100)"); |
| 114 | shouldThrow("node.connect(node2.gain, 100)"); |
| 115 | shouldThrow("node.disconnect(99)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 116 | // Can't connect to a different context (unspecified error) |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 117 | shouldThrow("node.connect(otherContext.destination)"); |
| 118 | |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 119 | // Invalid channel count: NotSupportedError |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 120 | shouldThrowAndBeUnchanged("node.channelCount", "99"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 121 | // Invalid mode or interpretation (unspecified error) |
[email protected] | e152e8ed | 2014-05-14 16:20:33 | [diff] [blame] | 122 | currentMode = node.channelCountMode; |
| 123 | currentInterpretation = node.channelInterpretation; |
| 124 | shouldNotThrow("node.channelCountMode = 'fancy'"); |
| 125 | if (node.channelCountMode == currentMode) |
| 126 | testPassed("Invalid channelCountMode value did not change mode"); |
| 127 | else |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 128 | testFailed("node.channelCountMode incorrectly changed to invalid value " + node.channelCountMode); |
[email protected] | e152e8ed | 2014-05-14 16:20:33 | [diff] [blame] | 129 | shouldNotThrow("node.channelInterpretation = mode"); |
| 130 | if (node.channelInterpretation == currentInterpretation) |
| 131 | testPassed("Invalid channelInterpration value did not change mode"); |
| 132 | else |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 133 | testFailed("node.channelInterpretation incorrectly changed to invalid value " + node.channelInterpreation); |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 134 | |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 135 | // Destination node channel count: should throw IndexSizeError on invalid |
| 136 | // channel count. shouldNotThrow() method cannot be used because the error |
| 137 | // message includes the number of channels, which can change depending on |
| 138 | // the actual attached hardware. |
| 139 | try { |
| 140 | eval("context.destination.channelCount = 99"); |
| 141 | } catch (e) { |
| 142 | if (e.message === "Failed to set the 'channelCount' property on 'AudioNode': The channel count provided (99) is outside the range [1, " + context.destination.maxChannelCount + "]." && e.name === "IndexSizeError") |
| 143 | testPassed("context.destination.channelCount = 99 threw IndexSizeError exception on invalid channel count."); |
| 144 | else |
| 145 | testFailed("context.destination.channelCount = 99 should throw IndexSizeError exception on invalid channel count."); |
| 146 | } |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 147 | |
philipj | eb44026 | 2015-12-04 21:20:39 | [diff] [blame] | 148 | // AudioParams |
| 149 | param = context.createGain().gain; |
| 150 | shouldThrow("param.setValueCurveAtTime(null, 0, 0)"); |
| 151 | |
| 152 | // BiquadFilterNode |
| 153 | node = context.createBiquadFilter(); |
| 154 | shouldNotThrow("node.getFrequencyResponse(new Float32Array(1), new Float32Array(1), new Float32Array(1))"); |
| 155 | shouldThrow("node.getFrequencyResponse(null, new Float32Array(1), new Float32Array(1))"); |
| 156 | shouldThrow("node.getFrequencyResponse(new Float32Array(1), null, new Float32Array(1))"); |
| 157 | shouldThrow("node.getFrequencyResponse(new Float32Array(1), new Float32Array(1), null)"); |
| 158 | |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 159 | // Delay nodes are tested elsewhere, so don't duplicate that work here. |
| 160 | |
| 161 | // OfflineAudioContext |
[email protected] | 84126a36 | 2014-04-14 16:55:48 | [diff] [blame] | 162 | // Max supported channels |
| 163 | shouldNotThrow("new OfflineAudioContext(32, 100, context.sampleRate)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 164 | // Invalid number of channels (unspecified error) |
[email protected] | f846f5a | 2014-03-25 17:33:11 | [diff] [blame] | 165 | shouldThrow("new OfflineAudioContext(99, 100, context.sampleRate)"); |
[email protected] | 154cd08 | 2013-10-04 19:40:08 | [diff] [blame] | 166 | // Invalid sample rate. (unspecified error) |
[email protected] | f846f5a | 2014-03-25 17:33:11 | [diff] [blame] | 167 | shouldThrow("new OfflineAudioContext(1, 100, 1)"); |
| 168 | shouldThrow("new OfflineAudioContext(1, 100, 1e6)"); |
[email protected] | a9b939e | 2014-03-12 18:34:27 | [diff] [blame] | 169 | // Invalid frame length (crbug.com/351277) |
[email protected] | f846f5a | 2014-03-25 17:33:11 | [diff] [blame] | 170 | shouldThrow("new OfflineAudioContext(1, -88200000000000, 44100)"); |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 171 | |
[email protected] | 4e10d03 | 2013-10-02 21:48:00 | [diff] [blame] | 172 | // WaveShaper types |
| 173 | node = context.createWaveShaper(); |
[email protected] | e152e8ed | 2014-05-14 16:20:33 | [diff] [blame] | 174 | currentOversample = node.oversample; |
| 175 | shouldNotThrow("node.oversample = '9x'"); |
| 176 | if (node.oversample == currentOversample) |
| 177 | testPassed("Invalid oversample value did not change node.oversample"); |
| 178 | else |
| 179 | testFailed("node.oversample incorrectly changed to invalid value " + node.oversample); |
philipj | eb44026 | 2015-12-04 21:20:39 | [diff] [blame] | 180 | shouldThrow("node.curve = {}"); |
[email protected] | 837dc8c | 2015-01-13 18:00:30 | [diff] [blame] | 181 | shouldThrow("node.curve = new Float32Array(1)"); |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 182 | shouldBeNull("node.curve"); |
[email protected] | 837dc8c | 2015-01-13 18:00:30 | [diff] [blame] | 183 | shouldNotThrow("node.curve = new Float32Array(2)"); |
[email protected] | 6eec933d | 2015-01-21 20:55:00 | [diff] [blame] | 184 | shouldNotThrow("node.curve = null"); |
[email protected] | ffd785f | 2013-10-29 17:19:58 | [diff] [blame] | 185 | |
| 186 | // Start/stop for AudioBufferSourceNodes |
| 187 | buffer = context.createBuffer(1,1, context.sampleRate); |
| 188 | shouldNotThrow("source = context.createBufferSource()"); |
[email protected] | eed4fa20 | 2013-10-31 02:13:29 | [diff] [blame] | 189 | shouldNotThrow("source.buffer = buffer"); |
[email protected] | f610149 | 2015-05-05 17:18:47 | [diff] [blame] | 190 | shouldThrow("source.buffer = context.createBuffer(1, 10, context.sampleRate)"); |
[email protected] | 288a06a | 2014-09-26 03:53:55 | [diff] [blame] | 191 | shouldThrow("source.start(-1)"); |
| 192 | shouldThrow("source.start(Infinity)"); |
| 193 | shouldThrow("source.start(-Infinity)"); |
| 194 | shouldThrow("source.start(NaN)"); |
| 195 | shouldThrow("source.start(1, Infinity)"); |
| 196 | shouldThrow("source.start(1, -Infinity)"); |
| 197 | shouldThrow("source.start(1, NaN)"); |
| 198 | shouldThrow("source.start(1, -1)"); |
[email protected] | 8e4304c | 2015-04-28 18:20:21 | [diff] [blame] | 199 | shouldThrow("source.start(1, -Number.MIN_VALUE)"); |
[email protected] | 288a06a | 2014-09-26 03:53:55 | [diff] [blame] | 200 | shouldThrow("source.start(1, 1, Infinity)"); |
| 201 | shouldThrow("source.start(1, 1, -Infinity)"); |
| 202 | shouldThrow("source.start(1, 1, NaN)"); |
| 203 | shouldThrow("source.start(1, 1, -1)"); |
[email protected] | 8e4304c | 2015-04-28 18:20:21 | [diff] [blame] | 204 | shouldThrow("source.start(1, 1, -Number.MIN_VALUE)"); |
[email protected] | eed4fa20 | 2013-10-31 02:13:29 | [diff] [blame] | 205 | shouldNotThrow("source.start()"); |
[email protected] | 8e4304c | 2015-04-28 18:20:21 | [diff] [blame] | 206 | shouldThrow("source.stop(-Number.MIN_VALUE)"); |
[email protected] | 288a06a | 2014-09-26 03:53:55 | [diff] [blame] | 207 | shouldThrow("source.stop(Infinity)"); |
| 208 | shouldThrow("source.stop(-Infinity)"); |
| 209 | shouldThrow("source.stop(NaN)"); |
[email protected] | eed4fa20 | 2013-10-31 02:13:29 | [diff] [blame] | 210 | shouldNotThrow("source.stop()"); |
| 211 | |
[email protected] | 8e4304c | 2015-04-28 18:20:21 | [diff] [blame] | 212 | // Verify that start(0, 0) doesn't signal. |
| 213 | shouldNotThrow("source = context.createBufferSource()"); |
| 214 | shouldNotThrow("source.buffer = buffer"); |
| 215 | shouldNotThrow("source.start(0, 0)"); |
| 216 | |
| 217 | // Verify that start(0, -0.0) doesn't signal. |
| 218 | shouldNotThrow("source = context.createBufferSource()"); |
| 219 | shouldNotThrow("source.buffer = buffer"); |
| 220 | shouldNotThrow("source.start(0, -1/Infinity)"); |
| 221 | |
[email protected] | 20b3e833 | 2013-11-01 00:14:05 | [diff] [blame] | 222 | // It's not clear from the spec, but I think it's valid to call start(). The spec is silent on |
| 223 | // what happens if we call stop() afterwards, so don't call it. |
[email protected] | eed4fa20 | 2013-10-31 02:13:29 | [diff] [blame] | 224 | shouldNotThrow("source = context.createBufferSource()"); |
[email protected] | ffd785f | 2013-10-29 17:19:58 | [diff] [blame] | 225 | shouldNotThrow("source.start()"); |
[email protected] | ffd785f | 2013-10-29 17:19:58 | [diff] [blame] | 226 | |
[email protected] | 20b3e833 | 2013-11-01 00:14:05 | [diff] [blame] | 227 | buffer = context.createBuffer(1,1, context.sampleRate); |
| 228 | shouldNotThrow("source = context.createBufferSource()"); |
| 229 | shouldNotThrow("source.buffer = buffer"); |
| 230 | shouldThrow("source.stop()"); |
| 231 | |
| 232 | buffer = context.createBuffer(1,1, context.sampleRate); |
| 233 | shouldNotThrow("source = context.createBufferSource()"); |
| 234 | shouldNotThrow("source.buffer = buffer"); |
| 235 | shouldNotThrow("source.start()"); |
| 236 | shouldThrow("source.start()"); |
| 237 | |
| 238 | buffer = context.createBuffer(1,1, context.sampleRate); |
| 239 | shouldNotThrow("source = context.createBufferSource()"); |
| 240 | shouldNotThrow("source.buffer = buffer"); |
| 241 | shouldNotThrow("source.start()"); |
| 242 | shouldNotThrow("source.stop()"); |
[email protected] | 20b3e833 | 2013-11-01 00:14:05 | [diff] [blame] | 243 | |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 244 | |
[email protected] | ffd785f | 2013-10-29 17:19:58 | [diff] [blame] | 245 | // Start/stop for OscillatorNodes |
| 246 | shouldNotThrow("source = context.createOscillator()"); |
[email protected] | 8e4304c | 2015-04-28 18:20:21 | [diff] [blame] | 247 | shouldThrow("source.start(-Number.MIN_VALUE)"); |
[email protected] | 288a06a | 2014-09-26 03:53:55 | [diff] [blame] | 248 | shouldThrow("source.start(Infinity)"); |
| 249 | shouldThrow("source.start(-Infinity)"); |
| 250 | shouldThrow("source.start(NaN)"); |
[email protected] | ffd785f | 2013-10-29 17:19:58 | [diff] [blame] | 251 | shouldNotThrow("source.start()"); |
[email protected] | 8e4304c | 2015-04-28 18:20:21 | [diff] [blame] | 252 | shouldThrow("source.stop(-Number.MIN_VALUE)"); |
[email protected] | 288a06a | 2014-09-26 03:53:55 | [diff] [blame] | 253 | shouldThrow("source.stop(Infinity)"); |
| 254 | shouldThrow("source.stop(-Infinity)"); |
| 255 | shouldThrow("source.stop(NaN)"); |
[email protected] | ffd785f | 2013-10-29 17:19:58 | [diff] [blame] | 256 | shouldNotThrow("source.stop()"); |
[email protected] | 20b3e833 | 2013-11-01 00:14:05 | [diff] [blame] | 257 | |
| 258 | shouldNotThrow("osc = context.createOscillator()"); |
| 259 | shouldThrow("osc.stop()"); |
| 260 | shouldNotThrow("osc1 = context.createOscillator()"); |
| 261 | shouldNotThrow("osc1.start()"); |
| 262 | shouldNotThrow("osc1.stop()"); |
[email protected] | 5ab469f | 2014-02-12 05:59:26 | [diff] [blame] | 263 | |
philipj | eb44026 | 2015-12-04 21:20:39 | [diff] [blame] | 264 | shouldThrow("osc.setPeriodicWave(null)"); |
| 265 | |
rtoy | a4ce5a8 | 2015-12-15 15:45:12 | [diff] [blame] | 266 | // exponentialRampToValue should throw only for "zero" target values. |
[email protected] | 5ab469f | 2014-02-12 05:59:26 | [diff] [blame] | 267 | node = context.createGain(); |
| 268 | node.connect(context.destination); |
rtoy | a4ce5a8 | 2015-12-15 15:45:12 | [diff] [blame] | 269 | shouldNotThrow("node.gain.exponentialRampToValueAtTime(-1, 0.1)"); |
[email protected] | 5ab469f | 2014-02-12 05:59:26 | [diff] [blame] | 270 | shouldThrow("node.gain.exponentialRampToValueAtTime(0, 0.1)"); |
rtoy | a4ce5a8 | 2015-12-15 15:45:12 | [diff] [blame] | 271 | // 1e-100 is 0 when converted to a single precision float. |
| 272 | shouldThrow("node.gain.exponentialRampToValueAtTime(1e-100, 0.1)"); |
[email protected] | 14fab3df1 | 2015-02-19 21:03:46 | [diff] [blame] | 273 | // See crbug.com/459391. |
| 274 | // Math.pow(2, -149) = 1.401298464324817e-45 is the double-float value of the |
| 275 | // least positive single float number. We do it this way to make sure no round-off or conversion |
| 276 | // errors happen when reading 1.401298464324817e-45. |
| 277 | shouldNotThrow("node.gain.exponentialRampToValueAtTime(Math.pow(2, -149), 0.1)"); |
| 278 | // Math.pow(2, -150) = 7.006492321624085d-46 is the largest double float value such that |
| 279 | // conversion to a float produces 0. Any larger value would produce a non-zero value when |
| 280 | // converted to a single float. |
| 281 | shouldThrow("node.gain.exponentialRampToValueAtTime(Math.pow(2, -150), 0.1)"); |
[email protected] | 77459e3 | 2014-03-19 00:04:10 | [diff] [blame] | 282 | |
| 283 | // Convolver buffer rate must match context rate. Create on offline context so we |
| 284 | // specify the context rate exactly, in case the test is run on platforms with different |
| 285 | // HW sample rates. |
[email protected] | f846f5a | 2014-03-25 17:33:11 | [diff] [blame] | 286 | shouldNotThrow("oc = new OfflineAudioContext(1, 44100, 44100)"); |
[email protected] | 77459e3 | 2014-03-19 00:04:10 | [diff] [blame] | 287 | shouldNotThrow("conv = oc.createConvolver()"); |
philipj | eb44026 | 2015-12-04 21:20:39 | [diff] [blame] | 288 | shouldThrow("conv.buffer = {}"); |
[email protected] | 77459e3 | 2014-03-19 00:04:10 | [diff] [blame] | 289 | shouldThrow("conv.buffer = oc.createBuffer(1, 100, 22050)"); |
[email protected] | 300c8f41 | 2015-04-08 23:04:55 | [diff] [blame] | 290 | // conv.buffer should be unchanged (null) because the above failed. |
| 291 | shouldBeNull("conv.buffer"); |
philipj | eb44026 | 2015-12-04 21:20:39 | [diff] [blame] | 292 | |
[email protected] | 1d4178a | 2014-09-26 21:37:44 | [diff] [blame] | 293 | // PannerNode channel count and mode |
| 294 | panner = context.createPanner(); |
| 295 | // Channel count can only be set to 1 or 2. |
| 296 | shouldNotThrow("panner.channelCount = 1"); |
| 297 | shouldNotThrow("panner.channelCount = 2"); |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 298 | shouldThrowAndBeUnchanged("panner.channelCount", "0"); |
| 299 | shouldThrowAndBeUnchanged("panner.channelCount", "3"); |
[email protected] | 1d4178a | 2014-09-26 21:37:44 | [diff] [blame] | 300 | // It is illegal to set the mode to 'max' |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 301 | shouldThrowAndBeUnchanged("panner.channelCountMode", "'max'"); |
[email protected] | 1d4178a | 2014-09-26 21:37:44 | [diff] [blame] | 302 | shouldNotThrow("panner.channelCountMode = 'explicit'"); |
| 303 | shouldNotThrow("panner.channelCountMode = 'clamped-max'"); |
| 304 | shouldNotThrow("panner.channelCountMode = 'junk'"); |
[email protected] | 7baad898 | 2014-09-29 22:11:48 | [diff] [blame] | 305 | |
| 306 | // Test channel count and mode for a ScriptProcessor. |
| 307 | shouldNotThrow("script = context.createScriptProcessor(256, 3)"); |
| 308 | // Make sure the channelCount and mode are set correctly. |
| 309 | shouldBeEqualToNumber("script.channelCount", 3); |
| 310 | shouldBeEqualToString("script.channelCountMode", "explicit"); |
| 311 | // Cannot change the channelCount or mode to anything else |
| 312 | shouldNotThrow("script.channelCount = 3"); |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 313 | shouldThrowAndBeUnchanged("script.channelCount", "1"); |
| 314 | |
| 315 | shouldThrowAndBeUnchanged("script.channelCount", "7"); |
[email protected] | 7baad898 | 2014-09-29 22:11:48 | [diff] [blame] | 316 | shouldNotThrow("script.channelCountMode = 'explicit'"); |
[email protected] | c026bfd2 | 2015-01-16 00:24:26 | [diff] [blame] | 317 | shouldThrowAndBeUnchanged("script.channelCountMode", "'max'"); |
| 318 | shouldThrowAndBeUnchanged("script.channelCountMode", "'clamped-max'"); |
[email protected] | 7baad898 | 2014-09-29 22:11:48 | [diff] [blame] | 319 | shouldNotThrow("script.channelCountMode = 'junk'"); |
[email protected] | 7cc3e78 | 2014-11-10 22:37:54 | [diff] [blame] | 320 | |
| 321 | // noteOn and noteOff don't exist anymore |
| 322 | shouldBeUndefined("osc.noteOn"); |
| 323 | shouldBeUndefined("osc.noteOff"); |
| 324 | shouldBeUndefined("source.noteOn"); |
| 325 | shouldBeUndefined("source.noteOff"); |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | runTest(); |
| 329 | successfullyParsed = true; |
| 330 | |
[email protected] | b702bbb | 2014-12-05 04:53:16 | [diff] [blame] | 331 | </script> |
[email protected] | 2da6ffa | 2013-10-01 00:31:35 | [diff] [blame] | 332 | </body> |
| 333 | </html> |