| OLD | NEW |
| 1 <!doctype html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/testharness.js"></script> | 4 <title> |
| 5 <script src="../resources/testharnessreport.js"></script> | 5 dom-exceptions.html |
| 6 <script src="resources/audit-util.js"></script> | 6 </title> |
| 7 <script src="resources/audit.js"></script> | 7 <script src="../resources/testharness.js"></script> |
| 8 <script src="resources/biquad-testing.js"></script> | 8 <script src="../resources/testharnessreport.js"></script> |
| 9 </head> | 9 <script src="resources/audit-util.js"></script> |
| 10 | 10 <script src="resources/audit.js"></script> |
| 11 <body> | 11 <script src="resources/biquad-testing.js"></script> |
| 12 <script> | 12 </head> |
| 13 let audit = Audit.createTaskRunner(); | 13 <body> |
| 14 | 14 <script id="layout-test-code"> |
| 15 let otherContext; | 15 let audit = Audit.createTaskRunner(); |
| 16 let node; | 16 |
| 17 let node2; | 17 let otherContext; |
| 18 let mode; | 18 let node; |
| 19 let panner; | 19 let node2; |
| 20 let script; | 20 let mode; |
| 21 let source; | 21 let panner; |
| 22 | 22 let script; |
| 23 function shouldThrowAndBeUnchanged(should, node, attr, value) { | 23 let source; |
| 24 should( | 24 |
| 25 () => node[attr] = value, | 25 function shouldThrowAndBeUnchanged(should, node, attr, value) { |
| 26 node.constructor.name + '.' + attr + ' = ' + value) | 26 should( |
| 27 .throw(); | 27 () => node[attr] = value, |
| 28 should(node[attr], node.constructor.name + '.' + attr).notBeEqualTo(value); | 28 node.constructor.name + '.' + attr + ' = ' + value) |
| 29 } | 29 .throw(); |
| 30 | 30 should(node[attr], node.constructor.name + '.' + attr) |
| 31 audit.define( | 31 .notBeEqualTo(value); |
| 32 {label: 'initialize', description: 'Initialize contexts for testing'}, | 32 } |
| 33 (task, should) => { | 33 |
| 34 | 34 audit.define( |
| 35 should(() => { | 35 {label: 'initialize', description: 'Initialize contexts for testing'}, |
| 36 context = new AudioContext(); | 36 (task, should) => { |
| 37 }, 'context = new AudioContext()').notThrow(); | 37 |
| 38 | 38 should(() => { |
| 39 should(() => { | 39 context = new AudioContext(); |
| 40 otherContext = new AudioContext(); | 40 }, 'context = new AudioContext()').notThrow(); |
| 41 }, 'otherContext = new AudioContext()').notThrow(); | 41 |
| 42 | 42 should(() => { |
| 43 task.done(); | 43 otherContext = new AudioContext(); |
| 44 }); | 44 }, 'otherContext = new AudioContext()').notThrow(); |
| 45 | 45 |
| 46 audit.define('createBuffer', (task, should) => { | 46 task.done(); |
| 47 // Invalid number of channels: NotSupportedError | 47 }); |
| 48 should( | 48 |
| 49 () => context.createBuffer(99, 1, context.sampleRate), | 49 audit.define('createBuffer', (task, should) => { |
| 50 'context.createBuffer(99, 1, context.sampleRate)') | 50 // Invalid number of channels: NotSupportedError |
| 51 .throw('NotSupportedError'); | 51 should( |
| 52 should( | 52 () => context.createBuffer(99, 1, context.sampleRate), |
| 53 () => context.createBuffer(0, 1, context.sampleRate), | 53 'context.createBuffer(99, 1, context.sampleRate)') |
| 54 'context.createBuffer(0, 1, context.sampleRate)') | 54 .throw('NotSupportedError'); |
| 55 .throw('NotSupportedError'); | 55 should( |
| 56 // Invalid sample rate: NotSupportedError | 56 () => context.createBuffer(0, 1, context.sampleRate), |
| 57 should(() => context.createBuffer(1, 1, 1), 'context.createBuffer(1, 1, 1)') | 57 'context.createBuffer(0, 1, context.sampleRate)') |
| 58 .throw('NotSupportedError'); | 58 .throw('NotSupportedError'); |
| 59 should( | 59 // Invalid sample rate: NotSupportedError |
| 60 () => context.createBuffer(1, 1, 2999), | 60 should( |
| 61 'context.createBuffer(1, 1, 2999)') | 61 () => context.createBuffer(1, 1, 1), |
| 62 .throw('NotSupportedError'); | 62 'context.createBuffer(1, 1, 1)') |
| 63 should( | 63 .throw('NotSupportedError'); |
| 64 () => context.createBuffer(1, 1, 384001), | 64 should( |
| 65 'context.createBuffer(1, 1, 384001)') | 65 () => context.createBuffer(1, 1, 2999), |
| 66 .throw('NotSupportedError'); | 66 'context.createBuffer(1, 1, 2999)') |
| 67 should( | 67 .throw('NotSupportedError'); |
| 68 () => context.createBuffer(1, 1, 1e6), 'context.createBuffer(1, 1, 1e6)') | 68 should( |
| 69 .throw('NotSupportedError'); | 69 () => context.createBuffer(1, 1, 384001), |
| 70 // Check valid values from crbug.com/344375 | 70 'context.createBuffer(1, 1, 384001)') |
| 71 should( | 71 .throw('NotSupportedError'); |
| 72 () => context.createBuffer(1, 1, 3000), | 72 should( |
| 73 'context.createBuffer(1, 1, 3000)') | 73 () => context.createBuffer(1, 1, 1e6), |
| 74 .notThrow(); | 74 'context.createBuffer(1, 1, 1e6)') |
| 75 should( | 75 .throw('NotSupportedError'); |
| 76 () => context.createBuffer(1, 1, 192000), | 76 // Check valid values from crbug.com/344375 |
| 77 'context.createBuffer(1, 1, 192000)') | 77 should( |
| 78 .notThrow(); | 78 () => context.createBuffer(1, 1, 3000), |
| 79 should( | 79 'context.createBuffer(1, 1, 3000)') |
| 80 () => context.createBuffer(1, 1, 384000), | 80 .notThrow(); |
| 81 'context.createBuffer(1, 1, 384000)') | 81 should( |
| 82 .notThrow(); | 82 () => context.createBuffer(1, 1, 192000), |
| 83 // Invalid number of frames: NotSupportedError | 83 'context.createBuffer(1, 1, 192000)') |
| 84 should( | 84 .notThrow(); |
| 85 () => context.createBuffer(1, 0, context.sampleRate), | 85 should( |
| 86 'context.createBuffer(1, 0, context.sampleRate)') | 86 () => context.createBuffer(1, 1, 384000), |
| 87 .throw('NotSupportedError'); | 87 'context.createBuffer(1, 1, 384000)') |
| 88 // 2-arg createBuffer not allowed. | 88 .notThrow(); |
| 89 should( | 89 // Invalid number of frames: NotSupportedError |
| 90 () => context.createBuffer(new ArrayBuffer(100), true), | 90 should( |
| 91 'context.createBuffer(new ArrayBuffer(100), true)') | 91 () => context.createBuffer(1, 0, context.sampleRate), |
| 92 .throw('TypeError'); | 92 'context.createBuffer(1, 0, context.sampleRate)') |
| 93 | 93 .throw('NotSupportedError'); |
| 94 task.done(); | 94 // 2-arg createBuffer not allowed. |
| 95 }); | 95 should( |
| 96 | 96 () => context.createBuffer(new ArrayBuffer(100), true), |
| 97 audit.define('createMediaElementSource', (task, should) => { | 97 'context.createBuffer(new ArrayBuffer(100), true)') |
| 98 // Invalid sources (unspecified error) | 98 .throw('TypeError'); |
| 99 should( | 99 |
| 100 () => context.createMediaElementSource(null), | 100 task.done(); |
| 101 'context.createMediaElementSource(null)') | 101 }); |
| 102 .throw(); | 102 |
| 103 task.done(); | 103 audit.define('createMediaElementSource', (task, should) => { |
| 104 }); | 104 // Invalid sources (unspecified error) |
| 105 | 105 should( |
| 106 audit.define('createMediaStreamSource', (task, should) => { | 106 () => context.createMediaElementSource(null), |
| 107 // Invalid sources (unspecified error) | 107 'context.createMediaElementSource(null)') |
| 108 should( | 108 .throw(); |
| 109 () => context.createMediaStreamSource(null), | 109 task.done(); |
| 110 'context.createMediaStreamSource(null)') | 110 }); |
| 111 .throw(); | 111 |
| 112 | 112 audit.define('createMediaStreamSource', (task, should) => { |
| 113 task.done(); | 113 // Invalid sources (unspecified error) |
| 114 }); | 114 should( |
| 115 | 115 () => context.createMediaStreamSource(null), |
| 116 audit.define('createScriptProcessor', (task, should) => { | 116 'context.createMediaStreamSource(null)') |
| 117 // Invalid buffer size: IndexSizeError | 117 .throw(); |
| 118 should( | 118 |
| 119 () => context.createScriptProcessor(1, 1, 1), | 119 task.done(); |
| 120 'context.createScriptProcessor(1, 1, 1)') | 120 }); |
| 121 .throw('IndexSizeError'); | 121 |
| 122 // Invalid number of inputs and outputs: IndexSizeError | 122 audit.define('createScriptProcessor', (task, should) => { |
| 123 should( | 123 // Invalid buffer size: IndexSizeError |
| 124 () => context.createScriptProcessor(4096, 100, 1), | 124 should( |
| 125 'context.createScriptProcessor(4096, 100, 1)') | 125 () => context.createScriptProcessor(1, 1, 1), |
| 126 .throw('IndexSizeError'); | 126 'context.createScriptProcessor(1, 1, 1)') |
| 127 should( | 127 .throw('IndexSizeError'); |
| 128 () => context.createScriptProcessor(4096, 1, 100), | 128 // Invalid number of inputs and outputs: IndexSizeError |
| 129 'context.createScriptProcessor(4096, 1, 100)') | 129 should( |
| 130 .throw('IndexSizeError'); | 130 () => context.createScriptProcessor(4096, 100, 1), |
| 131 should( | 131 'context.createScriptProcessor(4096, 100, 1)') |
| 132 () => context.createScriptProcessor(), 'context.createScriptProcessor()') | 132 .throw('IndexSizeError'); |
| 133 .notThrow(); | 133 should( |
| 134 should( | 134 () => context.createScriptProcessor(4096, 1, 100), |
| 135 () => context.createScriptProcessor(0), | 135 'context.createScriptProcessor(4096, 1, 100)') |
| 136 'context.createScriptProcessor(0)') | 136 .throw('IndexSizeError'); |
| 137 .notThrow(); | 137 should( |
| 138 | 138 () => context.createScriptProcessor(), |
| 139 task.done(); | 139 'context.createScriptProcessor()') |
| 140 }); | 140 .notThrow(); |
| 141 | 141 should( |
| 142 audit.define('createChannelSplitter', (task, should) => { | 142 () => context.createScriptProcessor(0), |
| 143 // Invalid number of channels: IndexSizeError | 143 'context.createScriptProcessor(0)') |
| 144 should( | 144 .notThrow(); |
| 145 () => context.createChannelSplitter(0), | 145 |
| 146 'context.createChannelSplitter(0)') | 146 task.done(); |
| 147 .throw('IndexSizeError'); | 147 }); |
| 148 should( | 148 |
| 149 () => context.createChannelSplitter(99), | 149 audit.define('createChannelSplitter', (task, should) => { |
| 150 'context.createChannelSplitter(99)') | 150 // Invalid number of channels: IndexSizeError |
| 151 .throw('IndexSizeError'); | 151 should( |
| 152 should(() => context.createChannelMerger(0), 'context.createChannelMerger(0)') | 152 () => context.createChannelSplitter(0), |
| 153 .throw('IndexSizeError'); | 153 'context.createChannelSplitter(0)') |
| 154 | 154 .throw('IndexSizeError'); |
| 155 task.done(); | 155 should( |
| 156 }); | 156 () => context.createChannelSplitter(99), |
| 157 | 157 'context.createChannelSplitter(99)') |
| 158 audit.define('createChannelMerger', (task, should) => { | 158 .throw('IndexSizeError'); |
| 159 // Invalid number of channels: IndexSizeError | 159 should( |
| 160 should( | 160 () => context.createChannelMerger(0), |
| 161 () => context.createChannelMerger(99), 'context.createChannelMerger(99)') | 161 'context.createChannelMerger(0)') |
| 162 .throw('IndexSizeError'); | 162 .throw('IndexSizeError'); |
| 163 | 163 |
| 164 task.done(); | 164 task.done(); |
| 165 }); | 165 }); |
| 166 | 166 |
| 167 audit.define('createPeriodicWave', (task, should) => { | 167 audit.define('createChannelMerger', (task, should) => { |
| 168 // Invalid real/imag arrays: IndexSizeError | 168 // Invalid number of channels: IndexSizeError |
| 169 should( | 169 should( |
| 170 () => context.createPeriodicWave(null, null), | 170 () => context.createChannelMerger(99), |
| 171 'context.createPeriodicWave(null, null)') | 171 'context.createChannelMerger(99)') |
| 172 .throw('TypeError'); | 172 .throw('IndexSizeError'); |
| 173 should( | 173 |
| 174 () => context.createPeriodicWave(new Float32Array(10), null), | 174 task.done(); |
| 175 'context.createPeriodicWave(new Float32Array(10), null)') | 175 }); |
| 176 .throw('TypeError'); | 176 |
| 177 // Verify that we can use large arrays with no limit. Roughly. | 177 audit.define('createPeriodicWave', (task, should) => { |
| 178 should( | 178 // Invalid real/imag arrays: IndexSizeError |
| 179 () => context.createPeriodicWave( | 179 should( |
| 180 new Float32Array(4100), new Float32Array(4100)), | 180 () => context.createPeriodicWave(null, null), |
| 181 'context.createPeriodicWave(new Float32Array(4100), new Float32Array(4100)
)') | 181 'context.createPeriodicWave(null, null)') |
| 182 .notThrow(); | 182 .throw('TypeError'); |
| 183 should( | 183 should( |
| 184 () => context.createPeriodicWave( | 184 () => context.createPeriodicWave(new Float32Array(10), null), |
| 185 new Float32Array(8192), new Float32Array(8192)), | 185 'context.createPeriodicWave(new Float32Array(10), null)') |
| 186 'context.createPeriodicWave(new Float32Array(8192), new Float32Array(8192)
)') | 186 .throw('TypeError'); |
| 187 .notThrow(); | 187 // Verify that we can use large arrays with no limit. Roughly. |
| 188 should( | 188 should( |
| 189 () => context.createPeriodicWave( | 189 () => context.createPeriodicWave( |
| 190 new Float32Array(10000), new Float32Array(10000)), | 190 new Float32Array(4100), new Float32Array(4100)), |
| 191 'context.createPeriodicWave(new Float32Array(10000), new Float32Array(1000
0))') | 191 'context.createPeriodicWave(new Float32Array(4100), new Float32Array
(4100))') |
| 192 .notThrow(); | 192 .notThrow(); |
| 193 // Real and imaginary arrays must have the same size: IndexSizeError | 193 should( |
| 194 should( | 194 () => context.createPeriodicWave( |
| 195 () => | 195 new Float32Array(8192), new Float32Array(8192)), |
| 196 context.createPeriodicWave(new Float32Array(10), new Float32Array(7)), | 196 'context.createPeriodicWave(new Float32Array(8192), new Float32Array
(8192))') |
| 197 'context.createPeriodicWave(new Float32Array(10), new Float32Array(7))') | 197 .notThrow(); |
| 198 .throw('IndexSizeError'); | 198 should( |
| 199 | 199 () => context.createPeriodicWave( |
| 200 task.done(); | 200 new Float32Array(10000), new Float32Array(10000)), |
| 201 }); | 201 'context.createPeriodicWave(new Float32Array(10000), new Float32Arra
y(10000))') |
| 202 | 202 .notThrow(); |
| 203 audit.define('createAnalyser', (task, should) => { | 203 // Real and imaginary arrays must have the same size: IndexSizeError |
| 204 // Analysers | 204 should( |
| 205 node = context.createAnalyser(); | 205 () => context.createPeriodicWave( |
| 206 // Invalid fftSize: IndexSizeError | 206 new Float32Array(10), new Float32Array(7)), |
| 207 shouldThrowAndBeUnchanged(should, node, 'fftSize', '42'); | 207 'context.createPeriodicWave(new Float32Array(10), new Float32Array(7
))') |
| 208 shouldThrowAndBeUnchanged(should, node, 'fftSize', '16'); | 208 .throw('IndexSizeError'); |
| 209 should(() => node.fftSize = 32768, 'AnalyserNode.fftSize = 32768').notThrow(); | 209 |
| 210 shouldThrowAndBeUnchanged(should, node, 'fftSize', '65536'); | 210 task.done(); |
| 211 | 211 }); |
| 212 shouldThrowAndBeUnchanged(should, node, 'minDecibels', '-10'); | 212 |
| 213 shouldThrowAndBeUnchanged(should, node, 'maxDecibels', '-150'); | 213 audit.define('createAnalyser', (task, should) => { |
| 214 shouldThrowAndBeUnchanged(should, node, 'minDecibels', '-30'); | 214 // Analysers |
| 215 shouldThrowAndBeUnchanged(should, node, 'maxDecibels', '-100'); | 215 node = context.createAnalyser(); |
| 216 | 216 // Invalid fftSize: IndexSizeError |
| 217 shouldThrowAndBeUnchanged(should, node, 'smoothingTimeConstant', '-0.1'); | 217 shouldThrowAndBeUnchanged(should, node, 'fftSize', '42'); |
| 218 shouldThrowAndBeUnchanged(should, node, 'smoothingTimeConstant', '1.5'); | 218 shouldThrowAndBeUnchanged(should, node, 'fftSize', '16'); |
| 219 | 219 should(() => node.fftSize = 32768, 'AnalyserNode.fftSize = 32768') |
| 220 should( | 220 .notThrow(); |
| 221 () => node.getFloatFrequencyData(null), | 221 shouldThrowAndBeUnchanged(should, node, 'fftSize', '65536'); |
| 222 'AnalyserNode.getFloatFrequencyData(null)') | 222 |
| 223 .throw(); | 223 shouldThrowAndBeUnchanged(should, node, 'minDecibels', '-10'); |
| 224 should( | 224 shouldThrowAndBeUnchanged(should, node, 'maxDecibels', '-150'); |
| 225 () => node.getByteFrequencyData(null), | 225 shouldThrowAndBeUnchanged(should, node, 'minDecibels', '-30'); |
| 226 node.constructor.name + '.getByteFrequencyData(null)') | 226 shouldThrowAndBeUnchanged(should, node, 'maxDecibels', '-100'); |
| 227 .throw(); | 227 |
| 228 should( | 228 shouldThrowAndBeUnchanged( |
| 229 () => node.getFloatTimeDomainData(null), | 229 should, node, 'smoothingTimeConstant', '-0.1'); |
| 230 node.constructor.name + '.getFloatTimeDomainData(null)') | 230 shouldThrowAndBeUnchanged(should, node, 'smoothingTimeConstant', '1.5'); |
| 231 .throw(); | 231 |
| 232 should( | 232 should( |
| 233 () => node.getByteTimeDomainData(null), | 233 () => node.getFloatFrequencyData(null), |
| 234 node.constructor.name + '.getByteTimeDomainData(null)') | 234 'AnalyserNode.getFloatFrequencyData(null)') |
| 235 .throw(); | 235 .throw(); |
| 236 | 236 should( |
| 237 if (window.SharedArrayBuffer) { | 237 () => node.getByteFrequencyData(null), |
| 238 should( | 238 node.constructor.name + '.getByteFrequencyData(null)') |
| 239 () => node.getFloatFrequencyData(new Float32Array(new SharedArrayBuffer(
16))), | 239 .throw(); |
| 240 'AnalyserNode.getFloatFrequencyData(SharedArrayBuffer view)') | 240 should( |
| 241 .throw(); | 241 () => node.getFloatTimeDomainData(null), |
| 242 should( | 242 node.constructor.name + '.getFloatTimeDomainData(null)') |
| 243 () => node.getByteFrequencyData(new Uint8Array(new SharedArrayBuffer(16)
)), | 243 .throw(); |
| 244 node.constructor.name + '.getByteFrequencyData(SharedArrayBuffer view)') | 244 should( |
| 245 .throw(); | 245 () => node.getByteTimeDomainData(null), |
| 246 should( | 246 node.constructor.name + '.getByteTimeDomainData(null)') |
| 247 () => node.getFloatTimeDomainData(new Float32Array(new SharedArrayBuffer
(16))), | 247 .throw(); |
| 248 node.constructor.name + '.getFloatTimeDomainData(SharedArrayBuffer view)
') | 248 |
| 249 .throw(); | 249 if (window.SharedArrayBuffer) { |
| 250 should( | 250 should( |
| 251 () => node.getByteTimeDomainData(new Uint8Array(new SharedArrayBuffer(16
))), | 251 () => node.getFloatFrequencyData( |
| 252 node.constructor.name + '.getByteTimeDomainData(SharedArrayBuffer view)'
) | 252 new Float32Array(new SharedArrayBuffer(16))), |
| 253 .throw(); | 253 'AnalyserNode.getFloatFrequencyData(SharedArrayBuffer view)') |
| 254 } | 254 .throw(); |
| 255 | 255 should( |
| 256 // AudioBuffers | 256 () => node.getByteFrequencyData( |
| 257 node = context.createBuffer(1, 1, context.sampleRate); | 257 new Uint8Array(new SharedArrayBuffer(16))), |
| 258 // Invalid channel index: IndexSizeError | 258 node.constructor.name + |
| 259 should( | 259 '.getByteFrequencyData(SharedArrayBuffer view)') |
| 260 () => node.getChannelData(2), | 260 .throw(); |
| 261 node.constructor.name + '.getChannelData(2)') | 261 should( |
| 262 .throw(); | 262 () => node.getFloatTimeDomainData( |
| 263 | 263 new Float32Array(new SharedArrayBuffer(16))), |
| 264 task.done(); | 264 node.constructor.name + |
| 265 }); | 265 '.getFloatTimeDomainData(SharedArrayBuffer view)') |
| 266 | 266 .throw(); |
| 267 audit.define( | 267 should( |
| 268 { | 268 () => node.getByteTimeDomainData( |
| 269 label: 'Init test nodes', | 269 new Uint8Array(new SharedArrayBuffer(16))), |
| 270 description: 'Create test nodes for the following tests' | 270 node.constructor.name + |
| 271 }, | 271 '.getByteTimeDomainData(SharedArrayBuffer view)') |
| 272 (task, should) => { | 272 .throw(); |
| 273 should(() => { | 273 } |
| 274 node = context.createGain(); | 274 |
| 275 }, 'node = context.createGain()').notThrow(); | 275 // AudioBuffers |
| 276 should(() => { | 276 node = context.createBuffer(1, 1, context.sampleRate); |
| 277 node2 = context.createGain(); | 277 // Invalid channel index: IndexSizeError |
| 278 }, 'node2 = context.createGain()').notThrow(); | 278 should( |
| 279 | 279 () => node.getChannelData(2), |
| 280 task.done(); | 280 node.constructor.name + '.getChannelData(2)') |
| 281 }); | 281 .throw(); |
| 282 | 282 |
| 283 audit.define( | 283 task.done(); |
| 284 {label: 'connections', description: 'AudioNode connections'}, | 284 }); |
| 285 (task, should) => { | 285 |
| 286 | 286 audit.define( |
| 287 // AudioNode connections | 287 { |
| 288 // Invalid destination node (unspecified error) | 288 label: 'Init test nodes', |
| 289 should(() => node.connect(null, 0, 0), 'node.connect(null, 0, 0)') | 289 description: 'Create test nodes for the following tests' |
| 290 .throw(); | 290 }, |
| 291 // Invalid input or output index: IndexSizeError | 291 (task, should) => { |
| 292 should( | 292 should(() => { |
| 293 () => node.connect(context.destination, 100, 0), | 293 node = context.createGain(); |
| 294 'node.connect(context.destination, 100, 0)') | 294 }, 'node = context.createGain()').notThrow(); |
| 295 .throw('IndexSizeError'); | 295 should(() => { |
| 296 should( | 296 node2 = context.createGain(); |
| 297 () => node.connect(context.destination, 0, 100), | 297 }, 'node2 = context.createGain()').notThrow(); |
| 298 'node.connect(context.destination, 0, 100)') | 298 |
| 299 .throw('IndexSizeError'); | 299 task.done(); |
| 300 should( | 300 }); |
| 301 () => node.connect(node2.gain, 100), 'node.connect(node2.gain, 100)') | 301 |
| 302 .throw('IndexSizeError'); | 302 audit.define( |
| 303 should(() => node.disconnect(99), 'node.disconnect(99)') | 303 {label: 'connections', description: 'AudioNode connections'}, |
| 304 .throw('IndexSizeError'); | 304 (task, should) => { |
| 305 // Can't connect to a different context (unspecified error) | 305 |
| 306 should( | 306 // AudioNode connections |
| 307 () => node.connect(otherContext.destination), | 307 // Invalid destination node (unspecified error) |
| 308 'node.connect(otherContext.destination)') | 308 should(() => node.connect(null, 0, 0), 'node.connect(null, 0, 0)') |
| 309 .throw(); | 309 .throw(); |
| 310 | 310 // Invalid input or output index: IndexSizeError |
| 311 task.done(); | 311 should( |
| 312 }); | 312 () => node.connect(context.destination, 100, 0), |
| 313 | 313 'node.connect(context.destination, 100, 0)') |
| 314 audit.define( | 314 .throw('IndexSizeError'); |
| 315 { | 315 should( |
| 316 label: 'channel-stuff', | 316 () => node.connect(context.destination, 0, 100), |
| 317 description: 'channelCount, channelCountMode, channelInterpretation' | 317 'node.connect(context.destination, 0, 100)') |
| 318 }, | 318 .throw('IndexSizeError'); |
| 319 (task, should) => { | 319 should( |
| 320 | 320 () => node.connect(node2.gain, 100), |
| 321 // Invalid channel count: NotSupportedError | 321 'node.connect(node2.gain, 100)') |
| 322 shouldThrowAndBeUnchanged(should, node, 'channelCount', '99'); | 322 .throw('IndexSizeError'); |
| 323 // Invalid mode or interpretation (unspecified error) | 323 should(() => node.disconnect(99), 'node.disconnect(99)') |
| 324 currentMode = node.channelCountMode; | 324 .throw('IndexSizeError'); |
| 325 currentInterpretation = node.channelInterpretation; | 325 // Can't connect to a different context (unspecified error) |
| 326 should( | 326 should( |
| 327 () => node.channelCountMode = 'fancy', | 327 () => node.connect(otherContext.destination), |
| 328 'node.channelCountMode = "fancy"') | 328 'node.connect(otherContext.destination)') |
| 329 .notThrow(); | 329 .throw(); |
| 330 should(node.channelCountMode, 'node.channelCountMode') | 330 |
| 331 .beEqualTo(currentMode); | 331 task.done(); |
| 332 should( | 332 }); |
| 333 () => node.channelInterpretation = mode, | 333 |
| 334 'node.channelInterpretation = mode') | 334 audit.define( |
| 335 .notThrow(); | 335 { |
| 336 should(node.channelInterpretation, 'node.channelInterpretation') | 336 label: 'channel-stuff', |
| 337 .beEqualTo(currentInterpretation); | 337 description: 'channelCount, channelCountMode, channelInterpretation' |
| 338 // Destination node channel count: should throw IndexSizeError on invalid | 338 }, |
| 339 // channel count. shouldNotThrow() method cannot be used because the error | 339 (task, should) => { |
| 340 // message includes the number of channels, which can change depending on | 340 |
| 341 // the actual attached hardware. | 341 // Invalid channel count: NotSupportedError |
| 342 should( | 342 shouldThrowAndBeUnchanged(should, node, 'channelCount', '99'); |
| 343 () => context.destination.channelCount = 99, | 343 // Invalid mode or interpretation (unspecified error) |
| 344 'context.destination.channelCount = 99') | 344 currentMode = node.channelCountMode; |
| 345 .throw('IndexSizeError', { omitErrorMessage: true }); | 345 currentInterpretation = node.channelInterpretation; |
| 346 | 346 should( |
| 347 task.done(); | 347 () => node.channelCountMode = 'fancy', |
| 348 }); | 348 'node.channelCountMode = "fancy"') |
| 349 | 349 .notThrow(); |
| 350 audit.define('audioparam', (task, should) => { | 350 should(node.channelCountMode, 'node.channelCountMode') |
| 351 // AudioParams | 351 .beEqualTo(currentMode); |
| 352 param = context.createGain().gain; | 352 should( |
| 353 should( | 353 () => node.channelInterpretation = mode, |
| 354 () => param.setValueCurveAtTime(null, 0, 0), | 354 'node.channelInterpretation = mode') |
| 355 'param.setValueCurveAtTime(null, 0, 0)') | 355 .notThrow(); |
| 356 .throw(); | 356 should(node.channelInterpretation, 'node.channelInterpretation') |
| 357 | 357 .beEqualTo(currentInterpretation); |
| 358 // exponentialRampToValue should throw only for "zero" target values. | 358 // Destination node channel count: should throw IndexSizeError on |
| 359 should( | 359 // invalid channel count. shouldNotThrow() method cannot be used |
| 360 () => node.gain.exponentialRampToValueAtTime(-1, 0.1), | 360 // because the error message includes the number of channels, which |
| 361 'node.gain.exponentialRampToValueAtTime(-1, 0.1)') | 361 // can change depending on the actual attached hardware. |
| 362 .notThrow(); | 362 should( |
| 363 should( | 363 () => context.destination.channelCount = 99, |
| 364 () => node.gain.exponentialRampToValueAtTime(0, 0.1), | 364 'context.destination.channelCount = 99') |
| 365 'node.gain.exponentialRampToValueAtTime(0, 0.1)') | 365 .throw('IndexSizeError', {omitErrorMessage: true}); |
| 366 .throw(); | 366 |
| 367 // 1e-100 is 0 when converted to a single precision float. | 367 task.done(); |
| 368 should( | 368 }); |
| 369 () => node.gain.exponentialRampToValueAtTime(1e-100, 0.1), | 369 |
| 370 'node.gain.exponentialRampToValueAtTime(1e-100, 0.1)') | 370 audit.define('audioparam', (task, should) => { |
| 371 .throw(); | 371 // AudioParams |
| 372 // See crbug.com/459391. | 372 param = context.createGain().gain; |
| 373 // Math.pow(2, -149) = 1.401298464324817e-45 is the double-float value of the | 373 should( |
| 374 // least positive single float number. We do it this way to make sure no | 374 () => param.setValueCurveAtTime(null, 0, 0), |
| 375 // round-off or conversion | 375 'param.setValueCurveAtTime(null, 0, 0)') |
| 376 // errors happen when reading 1.401298464324817e-45. | 376 .throw(); |
| 377 should( | 377 |
| 378 () => node.gain.exponentialRampToValueAtTime(Math.pow(2, -149), 0.1), | 378 // exponentialRampToValue should throw only for "zero" target values. |
| 379 'node.gain.exponentialRampToValueAtTime(Math.pow(2, -149), 0.1)') | 379 should( |
| 380 .notThrow(); | 380 () => node.gain.exponentialRampToValueAtTime(-1, 0.1), |
| 381 // Math.pow(2, -150) = 7.006492321624085d-46 is the largest double float value | 381 'node.gain.exponentialRampToValueAtTime(-1, 0.1)') |
| 382 // such that | 382 .notThrow(); |
| 383 // conversion to a float produces 0. Any larger value would produce a | 383 should( |
| 384 // non-zero value when | 384 () => node.gain.exponentialRampToValueAtTime(0, 0.1), |
| 385 // converted to a single float. | 385 'node.gain.exponentialRampToValueAtTime(0, 0.1)') |
| 386 should( | 386 .throw(); |
| 387 () => node.gain.exponentialRampToValueAtTime(Math.pow(2, -150), 0.1), | 387 // 1e-100 is 0 when converted to a single precision float. |
| 388 'node.gain.exponentialRampToValueAtTime(Math.pow(2, -150), 0.1)') | 388 should( |
| 389 .throw(); | 389 () => node.gain.exponentialRampToValueAtTime(1e-100, 0.1), |
| 390 | 390 'node.gain.exponentialRampToValueAtTime(1e-100, 0.1)') |
| 391 task.done(); | 391 .throw(); |
| 392 }); | 392 // See crbug.com/459391. |
| 393 | 393 // Math.pow(2, -149) = 1.401298464324817e-45 is the double-float value |
| 394 audit.define('biquad', (task, should) => { | 394 // of the least positive single float number. We do it this way to make |
| 395 // BiquadFilterNode | 395 // sure no round-off or conversion errors happen when reading |
| 396 node = context.createBiquadFilter(); | 396 // 1.401298464324817e-45. |
| 397 should( | 397 should( |
| 398 () => node.getFrequencyResponse( | 398 () => |
| 399 new Float32Array(1), new Float32Array(1), new Float32Array(1)), | 399 node.gain.exponentialRampToValueAtTime(Math.pow(2, -149), 0.1), |
| 400 'node.getFrequencyResponse(new Float32Array(1), new Float32Array(1), new F
loat32Array(1))') | 400 'node.gain.exponentialRampToValueAtTime(Math.pow(2, -149), 0.1)') |
| 401 .notThrow(); | 401 .notThrow(); |
| 402 should( | 402 // Math.pow(2, -150) = 7.006492321624085d-46 is the largest double float |
| 403 () => node.getFrequencyResponse( | 403 // value such that conversion to a float produces 0. Any larger value |
| 404 null, new Float32Array(1), new Float32Array(1)), | 404 // would produce a non-zero value when converted to a single float. |
| 405 'node.getFrequencyResponse(null, new Float32Array(1), new Float32Array(1))
') | 405 should( |
| 406 .throw(); | 406 () => |
| 407 should( | 407 node.gain.exponentialRampToValueAtTime(Math.pow(2, -150), 0.1), |
| 408 () => node.getFrequencyResponse( | 408 'node.gain.exponentialRampToValueAtTime(Math.pow(2, -150), 0.1)') |
| 409 new Float32Array(1), null, new Float32Array(1)), | 409 .throw(); |
| 410 'node.getFrequencyResponse(new Float32Array(1), null, new Float32Array(1))
') | 410 |
| 411 .throw(); | 411 task.done(); |
| 412 should( | 412 }); |
| 413 () => node.getFrequencyResponse( | 413 |
| 414 new Float32Array(1), new Float32Array(1), null), | 414 audit.define('biquad', (task, should) => { |
| 415 'node.getFrequencyResponse(new Float32Array(1), new Float32Array(1), null)
') | 415 // BiquadFilterNode |
| 416 .throw(); | 416 node = context.createBiquadFilter(); |
| 417 | 417 should( |
| 418 if (window.SharedArrayBuffer) { | 418 () => node.getFrequencyResponse( |
| 419 let shared_view = new Float32Array(new SharedArrayBuffer(4)); | 419 new Float32Array(1), new Float32Array(1), new Float32Array(1)), |
| 420 let nonshared_view = new Float32Array(1); | 420 'node.getFrequencyResponse(new Float32Array(1), new Float32Array(1),
new Float32Array(1))') |
| 421 | 421 .notThrow(); |
| 422 should( | 422 should( |
| 423 () => node.getFrequencyResponse(shared_view, nonshared_view, nonshared_v
iew), | 423 () => node.getFrequencyResponse( |
| 424 'node.getFrequencyResponse(shared_view, nonshared_view, nonshared_view)'
) | 424 null, new Float32Array(1), new Float32Array(1)), |
| 425 .throw(); | 425 'node.getFrequencyResponse(null, new Float32Array(1), new Float32Arr
ay(1))') |
| 426 should( | 426 .throw(); |
| 427 () => node.getFrequencyResponse(nonshared_view, shared_view, nonshared_v
iew), | 427 should( |
| 428 'node.getFrequencyResponse(nonshared_view, shared_view, nonshared_view)'
) | 428 () => node.getFrequencyResponse( |
| 429 .throw(); | 429 new Float32Array(1), null, new Float32Array(1)), |
| 430 should( | 430 'node.getFrequencyResponse(new Float32Array(1), null, new Float32Arr
ay(1))') |
| 431 () => node.getFrequencyResponse(nonshared_view, nonshared_view, shared_v
iew), | 431 .throw(); |
| 432 'node.getFrequencyResponse(nonshared_view, nonshared_view, shared_view)'
) | 432 should( |
| 433 .throw(); | 433 () => node.getFrequencyResponse( |
| 434 } | 434 new Float32Array(1), new Float32Array(1), null), |
| 435 | 435 'node.getFrequencyResponse(new Float32Array(1), new Float32Array(1),
null)') |
| 436 task.done(); | 436 .throw(); |
| 437 }); | 437 |
| 438 | 438 if (window.SharedArrayBuffer) { |
| 439 audit.define('offline-audio-context', (task, should) => { | 439 let shared_view = new Float32Array(new SharedArrayBuffer(4)); |
| 440 // OfflineAudioContext | 440 let nonshared_view = new Float32Array(1); |
| 441 // Max supported channels | 441 |
| 442 should( | 442 should( |
| 443 () => new OfflineAudioContext(32, 100, context.sampleRate), | 443 () => node.getFrequencyResponse( |
| 444 'new OfflineAudioContext(32, 100, context.sampleRate)') | 444 shared_view, nonshared_view, nonshared_view), |
| 445 .notThrow(); | 445 'node.getFrequencyResponse(shared_view, nonshared_view, nonshared_
view)') |
| 446 // Invalid number of channels | 446 .throw(); |
| 447 should( | 447 should( |
| 448 () => new OfflineAudioContext(0, 100, context.sampleRate), | 448 () => node.getFrequencyResponse( |
| 449 'new OfflineAudioContext(0, 100, context.sampleRate)') | 449 nonshared_view, shared_view, nonshared_view), |
| 450 .throw('NotSupportedError'); | 450 'node.getFrequencyResponse(nonshared_view, shared_view, nonshared_
view)') |
| 451 should( | 451 .throw(); |
| 452 () => new OfflineAudioContext(99, 100, context.sampleRate), | 452 should( |
| 453 'new OfflineAudioContext(99, 100, context.sampleRate)') | 453 () => node.getFrequencyResponse( |
| 454 .throw('NotSupportedError'); | 454 nonshared_view, nonshared_view, shared_view), |
| 455 // Invalid sample rate. | 455 'node.getFrequencyResponse(nonshared_view, nonshared_view, shared_
view)') |
| 456 should( | 456 .throw(); |
| 457 () => new OfflineAudioContext(1, 100, 1), | 457 } |
| 458 'new OfflineAudioContext(1, 100, 1)') | 458 |
| 459 .throw('NotSupportedError'); | 459 task.done(); |
| 460 should( | 460 }); |
| 461 () => new OfflineAudioContext(1, 100, 1e6), | 461 |
| 462 'new OfflineAudioContext(1, 100, 1e6)') | 462 audit.define('offline-audio-context', (task, should) => { |
| 463 .throw('NotSupportedError'); | 463 // OfflineAudioContext |
| 464 // Invalid frame length (crbug.com/351277) | 464 // Max supported channels |
| 465 should( | 465 should( |
| 466 () => new OfflineAudioContext(1, -88200000000000, 44100), | 466 () => new OfflineAudioContext(32, 100, context.sampleRate), |
| 467 'new OfflineAudioContext(1, -88200000000000, 44100)') | 467 'new OfflineAudioContext(32, 100, context.sampleRate)') |
| 468 .throw('NotSupportedError'); | 468 .notThrow(); |
| 469 should( | 469 // Invalid number of channels |
| 470 () => new OfflineAudioContext(1, 0, 44100), | 470 should( |
| 471 'new OfflineAudioContext(1, 0, 44100)') | 471 () => new OfflineAudioContext(0, 100, context.sampleRate), |
| 472 .throw('NotSupportedError'); | 472 'new OfflineAudioContext(0, 100, context.sampleRate)') |
| 473 | 473 .throw('NotSupportedError'); |
| 474 task.done(); | 474 should( |
| 475 }); | 475 () => new OfflineAudioContext(99, 100, context.sampleRate), |
| 476 | 476 'new OfflineAudioContext(99, 100, context.sampleRate)') |
| 477 audit.define('waveshaper', (task, should) => { | 477 .throw('NotSupportedError'); |
| 478 // WaveShaper types | 478 // Invalid sample rate. |
| 479 node = context.createWaveShaper(); | 479 should( |
| 480 currentOversample = node.oversample; | 480 () => new OfflineAudioContext(1, 100, 1), |
| 481 should(() => node.oversample = '9x', 'node.oversample = "9x"').notThrow(); | 481 'new OfflineAudioContext(1, 100, 1)') |
| 482 should(node.oversample, 'node.oversample').beEqualTo(currentOversample); | 482 .throw('NotSupportedError'); |
| 483 should(() => node.curve = {}, 'node.curve = {}').throw(); | 483 should( |
| 484 should( | 484 () => new OfflineAudioContext(1, 100, 1e6), |
| 485 () => node.curve = new Float32Array(1), | 485 'new OfflineAudioContext(1, 100, 1e6)') |
| 486 'node.curve = new Float32Array(1)') | 486 .throw('NotSupportedError'); |
| 487 .throw(); | 487 // Invalid frame length (crbug.com/351277) |
| 488 should(node.curve, 'node.curve').beEqualTo(null); | 488 should( |
| 489 should( | 489 () => new OfflineAudioContext(1, -88200000000000, 44100), |
| 490 () => node.curve = new Float32Array(2), | 490 'new OfflineAudioContext(1, -88200000000000, 44100)') |
| 491 'node.curve = new Float32Array(2)') | 491 .throw('NotSupportedError'); |
| 492 .notThrow(); | 492 should( |
| 493 should(() => node.curve = null, 'node.curve = null').notThrow(); | 493 () => new OfflineAudioContext(1, 0, 44100), |
| 494 | 494 'new OfflineAudioContext(1, 0, 44100)') |
| 495 task.done(); | 495 .throw('NotSupportedError'); |
| 496 }); | 496 |
| 497 | 497 task.done(); |
| 498 audit.define( | 498 }); |
| 499 {label: 'audio-buffer-source', description: 'AudioBufferSource start/stop'}, | 499 |
| 500 (task, should) => { | 500 audit.define('waveshaper', (task, should) => { |
| 501 // Start/stop for AudioBufferSourceNodes | 501 // WaveShaper types |
| 502 buffer = context.createBuffer(1, 1, context.sampleRate); | 502 node = context.createWaveShaper(); |
| 503 should( | 503 currentOversample = node.oversample; |
| 504 () => source = context.createBufferSource(), | 504 should(() => node.oversample = '9x', 'node.oversample = "9x"') |
| 505 'source = context.createBufferSource()') | 505 .notThrow(); |
| 506 .notThrow(); | 506 should(node.oversample, 'node.oversample').beEqualTo(currentOversample); |
| 507 should(() => { source.buffer = buffer}, 'source.buffer = buffer').notThrow
(); | 507 should(() => node.curve = {}, 'node.curve = {}').throw(); |
| 508 should( | 508 should( |
| 509 () => source.buffer = context.createBuffer(1, 10, context.sampleRate), | 509 () => node.curve = new Float32Array(1), |
| 510 'source.buffer = context.createBuffer(1, 10, context.sampleRate)') | 510 'node.curve = new Float32Array(1)') |
| 511 .throw(); | 511 .throw(); |
| 512 should(() => {source.start(-1)}, 'source.start(-1)').throw(); | 512 should(node.curve, 'node.curve').beEqualTo(null); |
| 513 should(() => {source.start(Infinity)}, 'source.start(Infinity)').throw(); | 513 should( |
| 514 should(() => {source.start(-Infinity)}, 'source.start(-Infinity)').throw()
; | 514 () => node.curve = new Float32Array(2), |
| 515 should(() => {source.start(NaN)}, 'source.start(NaN)').throw(); | 515 'node.curve = new Float32Array(2)') |
| 516 should(() => {source.start(1, Infinity)}, 'source.start(1, Infinity)') | 516 .notThrow(); |
| 517 .throw(); | 517 should(() => node.curve = null, 'node.curve = null').notThrow(); |
| 518 should(() => {source.start(1, -Infinity)}, 'source.start(1, -Infinity)') | 518 |
| 519 .throw(); | 519 task.done(); |
| 520 should(() => {source.start(1, NaN)}, 'source.start(1, NaN)').throw(); | 520 }); |
| 521 should(() => {source.start(1, -1)}, 'source.start(1, -1)').throw(); | 521 |
| 522 should( | 522 audit.define( |
| 523 () => {source.start(1, -Number.MIN_VALUE)}, | 523 { |
| 524 'source.start(1, -Number.MIN_VALUE)') | 524 label: 'audio-buffer-source', |
| 525 .throw(); | 525 description: 'AudioBufferSource start/stop' |
| 526 should(() => {source.start(1, 1, Infinity)}, 'source.start(1, 1, Infinity)
') | 526 }, |
| 527 .throw(); | 527 (task, should) => { |
| 528 should( | 528 // Start/stop for AudioBufferSourceNodes |
| 529 () => {source.start(1, 1, -Infinity)}, 'source.start(1, 1, -Infinity)'
) | 529 buffer = context.createBuffer(1, 1, context.sampleRate); |
| 530 .throw(); | 530 should( |
| 531 should(() => {source.start(1, 1, NaN)}, 'source.start(1, 1, NaN)').throw()
; | 531 () => source = context.createBufferSource(), |
| 532 should(() => {source.start(1, 1, -1)}, 'source.start(1, 1, -1)').throw(); | 532 'source = context.createBufferSource()') |
| 533 should( | 533 .notThrow(); |
| 534 () => {source.start(1, 1, -Number.MIN_VALUE)}, | 534 should(() => {source.buffer = buffer}, 'source.buffer = buffer') |
| 535 'source.start(1, 1, -Number.MIN_VALUE)') | 535 .notThrow(); |
| 536 .throw(); | 536 should( |
| 537 should(() => source.start(), 'source.start()').notThrow(); | 537 () => source.buffer = |
| 538 should( | 538 context.createBuffer(1, 10, context.sampleRate), |
| 539 () => source.stop(-Number.MIN_VALUE), | 539 'source.buffer = context.createBuffer(1, 10, context.sampleRate)
') |
| 540 'source.stop(-Number.MIN_VALUE)') | 540 .throw(); |
| 541 .throw(); | 541 should(() => {source.start(-1)}, 'source.start(-1)').throw(); |
| 542 should(() => source.stop(Infinity), 'source.stop(Infinity)').throw(); | 542 should(() => {source.start(Infinity)}, 'source.start(Infinity)') |
| 543 should(() => source.stop(-Infinity), 'source.stop(-Infinity)').throw(); | 543 .throw(); |
| 544 should(() => source.stop(NaN), 'source.stop(NaN)').throw(); | 544 should(() => {source.start(-Infinity)}, 'source.start(-Infinity)') |
| 545 should(() => source.stop(), 'source.stop()').notThrow(); | 545 .throw(); |
| 546 | 546 should(() => {source.start(NaN)}, 'source.start(NaN)').throw(); |
| 547 // Verify that start(0, 0) doesn't signal. | 547 should( |
| 548 let source2; | 548 () => {source.start(1, Infinity)}, 'source.start(1, Infinity)') |
| 549 should( | 549 .throw(); |
| 550 () => { source2 = context.createBufferSource()}, | 550 should( |
| 551 'source2 = context.createBufferSource()') | 551 () => {source.start(1, -Infinity)}, |
| 552 .notThrow(); | 552 'source.start(1, -Infinity)') |
| 553 should(() => source2.buffer = buffer, 'source2.buffer = buffer').notThrow(
); | 553 .throw(); |
| 554 should(() => source2.start(0, 0), 'source2.start(0, 0)').notThrow(); | 554 should(() => {source.start(1, NaN)}, 'source.start(1, NaN)') |
| 555 | 555 .throw(); |
| 556 // Verify that start(0, -0.0) doesn't signal. | 556 should(() => {source.start(1, -1)}, 'source.start(1, -1)').throw(); |
| 557 let source3; | 557 should( |
| 558 should( | 558 () => {source.start(1, -Number.MIN_VALUE)}, |
| 559 () => source3 = context.createBufferSource(), | 559 'source.start(1, -Number.MIN_VALUE)') |
| 560 'source3 = context.createBufferSource()') | 560 .throw(); |
| 561 .notThrow(); | 561 should( |
| 562 should(() => source3.buffer = buffer, 'source3.buffer = buffer').notThrow(
); | 562 () => {source.start(1, 1, Infinity)}, |
| 563 should( | 563 'source.start(1, 1, Infinity)') |
| 564 () => source3.start(0, -1 / Infinity), 'source3.start(0, -1/Infinity)'
) | 564 .throw(); |
| 565 .notThrow(); | 565 should( |
| 566 | 566 () => {source.start(1, 1, -Infinity)}, |
| 567 // It's not clear from the spec, but I think it's valid to call start(). | 567 'source.start(1, 1, -Infinity)') |
| 568 // The spec is silent on what happens if we call stop() afterwards, so | 568 .throw(); |
| 569 // don't call it. | 569 should(() => {source.start(1, 1, NaN)}, 'source.start(1, 1, NaN)') |
| 570 let source4; | 570 .throw(); |
| 571 should( | 571 should(() => {source.start(1, 1, -1)}, 'source.start(1, 1, -1)') |
| 572 () => source4 = context.createBufferSource(), | 572 .throw(); |
| 573 'source4 = context.createBufferSource()') | 573 should( |
| 574 .notThrow(); | 574 () => {source.start(1, 1, -Number.MIN_VALUE)}, |
| 575 should(() => source4.start(), 'source4.start()').notThrow(); | 575 'source.start(1, 1, -Number.MIN_VALUE)') |
| 576 | 576 .throw(); |
| 577 buffer = context.createBuffer(1, 1, context.sampleRate); | 577 should(() => source.start(), 'source.start()').notThrow(); |
| 578 let source5; | 578 should( |
| 579 should( | 579 () => source.stop(-Number.MIN_VALUE), |
| 580 () => source5 = context.createBufferSource(), | 580 'source.stop(-Number.MIN_VALUE)') |
| 581 'source5 = context.createBufferSource()') | 581 .throw(); |
| 582 .notThrow(); | 582 should(() => source.stop(Infinity), 'source.stop(Infinity)') |
| 583 should(() => source5.buffer = buffer, 'source5.buffer = buffer').notThrow(
); | 583 .throw(); |
| 584 should(() => source5.stop(), 'source5.stop()').throw(); | 584 should(() => source.stop(-Infinity), 'source.stop(-Infinity)') |
| 585 | 585 .throw(); |
| 586 buffer = context.createBuffer(1, 1, context.sampleRate); | 586 should(() => source.stop(NaN), 'source.stop(NaN)').throw(); |
| 587 let source6; | 587 should(() => source.stop(), 'source.stop()').notThrow(); |
| 588 should( | 588 |
| 589 () => source6 = context.createBufferSource(), | 589 // Verify that start(0, 0) doesn't signal. |
| 590 'source6 = context.createBufferSource()') | 590 let source2; |
| 591 .notThrow(); | 591 should( |
| 592 should(() => source6.buffer = buffer, 'source6.buffer = buffer').notThrow(
); | 592 () => {source2 = context.createBufferSource()}, |
| 593 should(() => source6.start(), 'source6.start()').notThrow(); | 593 'source2 = context.createBufferSource()') |
| 594 should(() => source6.start(), 'source6.start()').throw(); | 594 .notThrow(); |
| 595 | 595 should(() => source2.buffer = buffer, 'source2.buffer = buffer') |
| 596 buffer = context.createBuffer(1, 1, context.sampleRate); | 596 .notThrow(); |
| 597 let source7; | 597 should(() => source2.start(0, 0), 'source2.start(0, 0)').notThrow(); |
| 598 should( | 598 |
| 599 () => source7 = context.createBufferSource(), | 599 // Verify that start(0, -0.0) doesn't signal. |
| 600 'source7 = context.createBufferSource()') | 600 let source3; |
| 601 .notThrow(); | 601 should( |
| 602 should(() => source7.buffer = buffer, 'source7.buffer = buffer').notThrow(
); | 602 () => source3 = context.createBufferSource(), |
| 603 should(() => source7.start(), 'source7.start()').notThrow(); | 603 'source3 = context.createBufferSource()') |
| 604 should(() => source7.stop(), 'source7.stop()').notThrow(); | 604 .notThrow(); |
| 605 | 605 should(() => source3.buffer = buffer, 'source3.buffer = buffer') |
| 606 task.done(); | 606 .notThrow(); |
| 607 }); | 607 should( |
| 608 | 608 () => source3.start(0, -1 / Infinity), |
| 609 audit.define( | 609 'source3.start(0, -1/Infinity)') |
| 610 {label: 'oscillator', description: 'start/stop'}, (task, should) => { | 610 .notThrow(); |
| 611 | 611 |
| 612 let source8; | 612 // It's not clear from the spec, but I think it's valid to call |
| 613 // Start/stop for OscillatorNodes | 613 // start(). The spec is silent on what happens if we call stop() |
| 614 should( | 614 // afterwards, so don't call it. |
| 615 () => source8 = context.createOscillator(), | 615 let source4; |
| 616 'source8 = context.createOscillator()') | 616 should( |
| 617 .notThrow(); | 617 () => source4 = context.createBufferSource(), |
| 618 should( | 618 'source4 = context.createBufferSource()') |
| 619 () => source8.start(-Number.MIN_VALUE), | 619 .notThrow(); |
| 620 'source8.start(-Number.MIN_VALUE)') | 620 should(() => source4.start(), 'source4.start()').notThrow(); |
| 621 .throw(); | 621 |
| 622 should(() => source8.start(Infinity), 'source8.start(Infinity)').throw(); | 622 buffer = context.createBuffer(1, 1, context.sampleRate); |
| 623 should(() => source8.start(-Infinity), 'source8.start(-Infinity)').throw()
; | 623 let source5; |
| 624 should(() => source8.start(NaN), 'source8.start(NaN)').throw(); | 624 should( |
| 625 should(() => source8.start(), 'source8.start()').notThrow(); | 625 () => source5 = context.createBufferSource(), |
| 626 should( | 626 'source5 = context.createBufferSource()') |
| 627 () => source8.stop(-Number.MIN_VALUE), | 627 .notThrow(); |
| 628 'source8.stop(-Number.MIN_VALUE)') | 628 should(() => source5.buffer = buffer, 'source5.buffer = buffer') |
| 629 .throw(); | 629 .notThrow(); |
| 630 should(() => source8.stop(Infinity), 'source8.stop(Infinity)').throw(); | 630 should(() => source5.stop(), 'source5.stop()').throw(); |
| 631 should(() => source8.stop(-Infinity), 'source8.stop(-Infinity)').throw(); | 631 |
| 632 should(() => source8.stop(NaN), 'source8.stop(NaN)').throw(); | 632 buffer = context.createBuffer(1, 1, context.sampleRate); |
| 633 should(() => source8.stop(), 'source8.stop()').notThrow(); | 633 let source6; |
| 634 | 634 should( |
| 635 should( | 635 () => source6 = context.createBufferSource(), |
| 636 () => osc = context.createOscillator(), | 636 'source6 = context.createBufferSource()') |
| 637 'osc = context.createOscillator()') | 637 .notThrow(); |
| 638 .notThrow(); | 638 should(() => source6.buffer = buffer, 'source6.buffer = buffer') |
| 639 should(() => osc.stop(), 'osc.stop()').throw(); | 639 .notThrow(); |
| 640 should( | 640 should(() => source6.start(), 'source6.start()').notThrow(); |
| 641 () => osc1 = context.createOscillator(), | 641 should(() => source6.start(), 'source6.start()').throw(); |
| 642 'osc1 = context.createOscillator()') | 642 |
| 643 .notThrow(); | 643 buffer = context.createBuffer(1, 1, context.sampleRate); |
| 644 should(() => osc1.start(), 'osc1.start()').notThrow(); | 644 let source7; |
| 645 should(() => osc1.stop(), 'osc1.stop()').notThrow(); | 645 should( |
| 646 | 646 () => source7 = context.createBufferSource(), |
| 647 should(() => osc.setPeriodicWave(null), 'osc.setPeriodicWave(null)') | 647 'source7 = context.createBufferSource()') |
| 648 .throw(); | 648 .notThrow(); |
| 649 | 649 should(() => source7.buffer = buffer, 'source7.buffer = buffer') |
| 650 | 650 .notThrow(); |
| 651 task.done(); | 651 should(() => source7.start(), 'source7.start()').notThrow(); |
| 652 }); | 652 should(() => source7.stop(), 'source7.stop()').notThrow(); |
| 653 | 653 |
| 654 audit.define('convolver', (task, should) => { | 654 task.done(); |
| 655 // Convolver buffer rate must match context rate. Create on offline context so | 655 }); |
| 656 // we | 656 |
| 657 // specify the context rate exactly, in case the test is run on platforms with | 657 audit.define( |
| 658 // different | 658 {label: 'oscillator', description: 'start/stop'}, (task, should) => { |
| 659 // HW sample rates. | 659 |
| 660 should( | 660 let source8; |
| 661 () => oc = new OfflineAudioContext(1, 44100, 44100), | 661 // Start/stop for OscillatorNodes |
| 662 'oc = new OfflineAudioContext(1, 44100, 44100)') | 662 should( |
| 663 .notThrow(); | 663 () => source8 = context.createOscillator(), |
| 664 should(() => conv = oc.createConvolver(), 'conv = oc.createConvolver()') | 664 'source8 = context.createOscillator()') |
| 665 .notThrow(); | 665 .notThrow(); |
| 666 should(() => conv.buffer = {}, 'conv.buffer = {}').throw(); | 666 should( |
| 667 should( | 667 () => source8.start(-Number.MIN_VALUE), |
| 668 () => conv.buffer = oc.createBuffer(1, 100, 22050), | 668 'source8.start(-Number.MIN_VALUE)') |
| 669 'conv.buffer = oc.createBuffer(1, 100, 22050)') | 669 .throw(); |
| 670 .throw(); | 670 should(() => source8.start(Infinity), 'source8.start(Infinity)') |
| 671 // conv.buffer should be unchanged (null) because the above failed. | 671 .throw(); |
| 672 should(conv.buffer, 'conv.buffer').beEqualTo(null); | 672 should(() => source8.start(-Infinity), 'source8.start(-Infinity)') |
| 673 | 673 .throw(); |
| 674 task.done(); | 674 should(() => source8.start(NaN), 'source8.start(NaN)').throw(); |
| 675 }); | 675 should(() => source8.start(), 'source8.start()').notThrow(); |
| 676 | 676 should( |
| 677 audit.define('panner', (task, should) => { | 677 () => source8.stop(-Number.MIN_VALUE), |
| 678 // PannerNode channel count and mode | 678 'source8.stop(-Number.MIN_VALUE)') |
| 679 panner = context.createPanner(); | 679 .throw(); |
| 680 // Channel count can only be set to 1 or 2. | 680 should(() => source8.stop(Infinity), 'source8.stop(Infinity)') |
| 681 should(() => panner.channelCount = 1, 'panner.channelCount = 1').notThrow(); | 681 .throw(); |
| 682 should(() => panner.channelCount = 2, 'panner.channelCount = 2').notThrow(); | 682 should(() => source8.stop(-Infinity), 'source8.stop(-Infinity)') |
| 683 shouldThrowAndBeUnchanged(should, panner, 'channelCount', 0); | 683 .throw(); |
| 684 shouldThrowAndBeUnchanged(should, panner, 'channelCount', 3); | 684 should(() => source8.stop(NaN), 'source8.stop(NaN)').throw(); |
| 685 // It is illegal to set the mode to 'max' | 685 should(() => source8.stop(), 'source8.stop()').notThrow(); |
| 686 shouldThrowAndBeUnchanged(should, panner, 'channelCountMode', 'max'); | 686 |
| 687 should( | 687 should( |
| 688 () => panner.channelCountMode = 'explicit', | 688 () => osc = context.createOscillator(), |
| 689 'panner.channelCountMode = "explicit"') | 689 'osc = context.createOscillator()') |
| 690 .notThrow(); | 690 .notThrow(); |
| 691 should( | 691 should(() => osc.stop(), 'osc.stop()').throw(); |
| 692 () => panner.channelCountMode = 'clamped-max', | 692 should( |
| 693 'panner.channelCountMode = "clamped-max"') | 693 () => osc1 = context.createOscillator(), |
| 694 .notThrow(); | 694 'osc1 = context.createOscillator()') |
| 695 should( | 695 .notThrow(); |
| 696 () => panner.channelCountMode = 'junk', | 696 should(() => osc1.start(), 'osc1.start()').notThrow(); |
| 697 'panner.channelCountMode = "junk"') | 697 should(() => osc1.stop(), 'osc1.stop()').notThrow(); |
| 698 .notThrow(); | 698 |
| 699 | 699 should(() => osc.setPeriodicWave(null), 'osc.setPeriodicWave(null)') |
| 700 task.done(); | 700 .throw(); |
| 701 }); | 701 |
| 702 | 702 |
| 703 audit.define('script-processor', (task, should) => { | 703 task.done(); |
| 704 // Test channel count and mode for a ScriptProcessor. | 704 }); |
| 705 should( | 705 |
| 706 () => script = context.createScriptProcessor(256, 3), | 706 audit.define('convolver', (task, should) => { |
| 707 'script = context.createScriptProcessor(256, 3)') | 707 // Convolver buffer rate must match context rate. Create on offline |
| 708 .notThrow(); | 708 // context so we specify the context rate exactly, in case the test is |
| 709 // Make sure the channelCount and mode are set correctly. | 709 // run on platforms with different HW sample rates. |
| 710 should(script.channelCount, 'script.channelCount').beEqualTo(3); | 710 should( |
| 711 should(script.channelCountMode, 'script.channelCountMode') | 711 () => oc = new OfflineAudioContext(1, 44100, 44100), |
| 712 .beEqualTo('explicit'); | 712 'oc = new OfflineAudioContext(1, 44100, 44100)') |
| 713 // Cannot change the channelCount or mode to anything else | 713 .notThrow(); |
| 714 should(() => script.channelCount = 3, 'script.channelCount = 3').notThrow(); | 714 should(() => conv = oc.createConvolver(), 'conv = oc.createConvolver()') |
| 715 shouldThrowAndBeUnchanged(should, script, 'channelCount', 1); | 715 .notThrow(); |
| 716 | 716 should(() => conv.buffer = {}, 'conv.buffer = {}').throw(); |
| 717 shouldThrowAndBeUnchanged(should, script, 'channelCount', 7); | 717 should( |
| 718 should( | 718 () => conv.buffer = oc.createBuffer(1, 100, 22050), |
| 719 () => script.channelCountMode = 'explicit', | 719 'conv.buffer = oc.createBuffer(1, 100, 22050)') |
| 720 'script.channelCountMode = "explicit"') | 720 .throw(); |
| 721 .notThrow(); | 721 // conv.buffer should be unchanged (null) because the above failed. |
| 722 shouldThrowAndBeUnchanged(should, script, 'channelCountMode', 'max'); | 722 should(conv.buffer, 'conv.buffer').beEqualTo(null); |
| 723 shouldThrowAndBeUnchanged(should, script, 'channelCountMode', 'clamped-max'); | 723 |
| 724 should( | 724 task.done(); |
| 725 () => script.channelCountMode = 'junk', | 725 }); |
| 726 'script.channelCountMode = "junk"') | 726 |
| 727 .notThrow(); | 727 audit.define('panner', (task, should) => { |
| 728 | 728 // PannerNode channel count and mode |
| 729 task.done(); | 729 panner = context.createPanner(); |
| 730 }); | 730 // Channel count can only be set to 1 or 2. |
| 731 | 731 should(() => panner.channelCount = 1, 'panner.channelCount = 1') |
| 732 audit.define( | 732 .notThrow(); |
| 733 {label: 'misc', description: 'Miscellaneous tests'}, (task, should) => { | 733 should(() => panner.channelCount = 2, 'panner.channelCount = 2') |
| 734 | 734 .notThrow(); |
| 735 // noteOn and noteOff don't exist anymore | 735 shouldThrowAndBeUnchanged(should, panner, 'channelCount', 0); |
| 736 should(osc.noteOn, 'osc.noteOn').beEqualTo(undefined); | 736 shouldThrowAndBeUnchanged(should, panner, 'channelCount', 3); |
| 737 should(osc.noteOff, 'osc.noteOff').beEqualTo(undefined); | 737 // It is illegal to set the mode to 'max' |
| 738 should(source.noteOn, 'source.noteOn').beEqualTo(undefined); | 738 shouldThrowAndBeUnchanged(should, panner, 'channelCountMode', 'max'); |
| 739 should(source.noteOff, 'source.noteOff').beEqualTo(undefined); | 739 should( |
| 740 | 740 () => panner.channelCountMode = 'explicit', |
| 741 task.done(); | 741 'panner.channelCountMode = "explicit"') |
| 742 }); | 742 .notThrow(); |
| 743 | 743 should( |
| 744 audit.run(); | 744 () => panner.channelCountMode = 'clamped-max', |
| 745 </script> | 745 'panner.channelCountMode = "clamped-max"') |
| 746 </body> | 746 .notThrow(); |
| 747 should( |
| 748 () => panner.channelCountMode = 'junk', |
| 749 'panner.channelCountMode = "junk"') |
| 750 .notThrow(); |
| 751 |
| 752 task.done(); |
| 753 }); |
| 754 |
| 755 audit.define('script-processor', (task, should) => { |
| 756 // Test channel count and mode for a ScriptProcessor. |
| 757 should( |
| 758 () => script = context.createScriptProcessor(256, 3), |
| 759 'script = context.createScriptProcessor(256, 3)') |
| 760 .notThrow(); |
| 761 // Make sure the channelCount and mode are set correctly. |
| 762 should(script.channelCount, 'script.channelCount').beEqualTo(3); |
| 763 should(script.channelCountMode, 'script.channelCountMode') |
| 764 .beEqualTo('explicit'); |
| 765 // Cannot change the channelCount or mode to anything else |
| 766 should(() => script.channelCount = 3, 'script.channelCount = 3') |
| 767 .notThrow(); |
| 768 shouldThrowAndBeUnchanged(should, script, 'channelCount', 1); |
| 769 |
| 770 shouldThrowAndBeUnchanged(should, script, 'channelCount', 7); |
| 771 should( |
| 772 () => script.channelCountMode = 'explicit', |
| 773 'script.channelCountMode = "explicit"') |
| 774 .notThrow(); |
| 775 shouldThrowAndBeUnchanged(should, script, 'channelCountMode', 'max'); |
| 776 shouldThrowAndBeUnchanged( |
| 777 should, script, 'channelCountMode', 'clamped-max'); |
| 778 should( |
| 779 () => script.channelCountMode = 'junk', |
| 780 'script.channelCountMode = "junk"') |
| 781 .notThrow(); |
| 782 |
| 783 task.done(); |
| 784 }); |
| 785 |
| 786 audit.define( |
| 787 {label: 'misc', description: 'Miscellaneous tests'}, |
| 788 (task, should) => { |
| 789 |
| 790 // noteOn and noteOff don't exist anymore |
| 791 should(osc.noteOn, 'osc.noteOn').beEqualTo(undefined); |
| 792 should(osc.noteOff, 'osc.noteOff').beEqualTo(undefined); |
| 793 should(source.noteOn, 'source.noteOn').beEqualTo(undefined); |
| 794 should(source.noteOff, 'source.noteOff').beEqualTo(undefined); |
| 795 |
| 796 task.done(); |
| 797 }); |
| 798 |
| 799 audit.run(); |
| 800 </script> |
| 801 </body> |
| 747 </html> | 802 </html> |
| OLD | NEW |