diff --git a/webaudio/resources/audionodeoptions.js b/webaudio/resources/audionodeoptions.js index 0d90a9c630013b..df0090c6d605fc 100644 --- a/webaudio/resources/audionodeoptions.js +++ b/webaudio/resources/audionodeoptions.js @@ -40,19 +40,19 @@ function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) { {channelCount: testChannelCount})); }, 'new ' + nodeName + '(c, {channelCount: ' + testChannelCount + '}}') - .throw(expectedNodeOptions.channelCount.errorType || TypeError); + .throw(DOMException, + expectedNodeOptions.channelCount.exceptionType); } else { // The channel count is not fixed. Try to set the count to invalid // values and make sure an error is thrown. - let errorType = 'NotSupportedError'; - [0, 99].forEach(testValue => { should(() => { node = new window[nodeName]( context, Object.assign({}, expectedNodeOptions.additionalOptions, { channelCount: testValue })); - }, `new ${nodeName}(c, {channelCount: ${testValue}})`).throw(errorType); + }, `new ${nodeName}(c, {channelCount: ${testValue}})`) + .throw(DOMException, 'NotSupportedError'); }); } @@ -88,7 +88,8 @@ function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) { {channelCountMode: testValue})); }, `new ${nodeName}(c, {channelCountMode: "${testValue}"})`) - .throw(expectedNodeOptions.channelCountMode.errorType); + .throw(DOMException, + expectedNodeOptions.channelCountMode.exceptionType); } }); } else { @@ -140,7 +141,8 @@ function testAudioNodeOptions(should, context, nodeName, expectedNodeOptions) { {channelInterpretation: testValue})); }, `new ${nodeName}(c, {channelInterpretation: "${testValue}"})`) - .throw(expectedNodeOptions.channelInterpretation.errorType); + .throw(DOMException, + expectedNodeOptions.channelCountMode.exceptionType); } }); } else { diff --git a/webaudio/resources/audit.js b/webaudio/resources/audit.js index 7ffa4392b05a15..b7ca0201610714 100644 --- a/webaudio/resources/audit.js +++ b/webaudio/resources/audit.js @@ -274,21 +274,25 @@ window.Audit = (function() { /** * Check if |actual| operation wrapped in a function throws an exception - * with a expected error type correctly. |expected| is optional. If it is a - * String, then it is considered to be the name of a DOMException. It can - * also be an instance of either an Error or a DOMException, to be more - * strict about the actual error type. + * with a expected error type correctly. |expected| is optional. If it is an + * instance of DOMException, then the description (second argument) can be + * provided to be more strict about the expected exception type. |expected| + * also can be other generic error types such as TypeError, RangeError or + * etc. * * @example * should(() => { let a = b; }, 'A bad code').throw(); - * should(() => { let c = d; }, 'Assigning d to c.') - * .throw('ReferenceError'); - * should(() => { let e = f; }, 'Assigning e to f.') - * .throw('ReferenceError', { omitErrorMessage: true }); + * should(() => { new SomeConstructor(); }, 'A bad construction') + * .throw(DOMException, 'NotSupportedError'); + * should(() => { let c = d; }, 'Assigning d to c') + * .throw(ReferenceError); + * should(() => { let e = f; }, 'Assigning e to f') + * .throw(ReferenceError, { omitErrorMessage: true }); * * @result * "PASS A bad code threw an exception of ReferenceError: b is not * defined." + * "PASS A bad construction threw DOMException:NotSupportedError." * "PASS Assigning d to c threw ReferenceError: d is not defined." * "PASS Assigning e to f threw ReferenceError: [error message * omitted]." @@ -313,17 +317,16 @@ window.Audit = (function() { // The expected error type was not given. didThrowCorrectly = true; passDetail = '${actual} threw ' + error.name + errorMessage + '.'; - } else if (typeof(this._expected) == "string" && - error instanceof DOMException && - error.name === this._expected) { - // A DOMException was thrown and expected, and the names match + } else if (this._expected === DOMException && + (this._expectedDescription === undefined || + this._expectedDescription === error.name)) { + // Handles DOMException with the associated name. didThrowCorrectly = true; passDetail = '${actual} threw ${expected}' + errorMessage + '.'; - } else if (this._expected == error.constructor && - this._expected.name == error.name) { - // The expected error type and names match the actual one. + } else if (this._expected == error.constructor) { + // Handler other error types. didThrowCorrectly = true; - passDetail = '${actual} threw ${expected}' + errorMessage + '.'; + passDetail = '${actual} threw ' + error.name + errorMessage + '.'; } else { didThrowCorrectly = false; failDetail = diff --git a/webaudio/resources/start-stop-exceptions.js b/webaudio/resources/start-stop-exceptions.js index 9a77e67ed8634c..0d2ea12f6db825 100644 --- a/webaudio/resources/start-stop-exceptions.js +++ b/webaudio/resources/start-stop-exceptions.js @@ -13,7 +13,7 @@ function testStartStop(should, node, options) { should(() => { node.stop(); - }, 'Calling stop() before start()').throw('InvalidStateError'); + }, 'Calling stop() before start()').throw(DOMException, 'InvalidStateError'); should(() => { node.start(-1); @@ -29,7 +29,7 @@ function testStartStop(should, node, options) { node.start(); should(() => { node.start(); - }, 'Calling start() twice').throw('InvalidStateError'); + }, 'Calling start() twice').throw(DOMException, 'InvalidStateError'); should(() => { node.stop(-1); }, 'stop(-1)').throw(RangeError); diff --git a/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html b/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html index 2112edeeffcf56..4e27f842ddeda3 100644 --- a/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html +++ b/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html @@ -91,25 +91,25 @@ node = new AnalyserNode(context, {fftSize: 33}); }, 'node = new AnalyserNode(c, { fftSize: 33 })') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should( () => { node = new AnalyserNode(context, {maxDecibels: -500}); }, 'node = new AnalyserNode(c, { maxDecibels: -500 })') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should( () => { node = new AnalyserNode(context, {minDecibels: -10}); }, 'node = new AnalyserNode(c, { minDecibels: -10 })') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should( () => { node = new AnalyserNode(context, {smoothingTimeConstant: 2}); }, 'node = new AnalyserNode(c, { smoothingTimeConstant: 2 })') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should(function() { node = new AnalyserNode(context, {frequencyBinCount: 33}); }, 'node = new AnalyserNode(c, { frequencyBinCount: 33 })').notThrow(); @@ -164,7 +164,7 @@ node = new AnalyserNode(context, options); }, 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); options = {minDecibels: -10, maxDecibels: -150}; should( @@ -172,7 +172,7 @@ node = new AnalyserNode(context, options); }, 'node = new AnalyserNode(c, ' + JSON.stringify(options) + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html b/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html index b3de37f119f167..7ee6a2237edd20 100644 --- a/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html +++ b/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html @@ -22,7 +22,7 @@ }; if (illegal) { - should(tester, message).throw('IndexSizeError'); + should(tester, message).throw(DOMException, 'IndexSizeError'); } else { should(tester, message).notThrow(); } diff --git a/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer-copy-channel.html b/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer-copy-channel.html index b71078d8f8094c..e0359953d2e909 100644 --- a/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer-copy-channel.html +++ b/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer-copy-channel.html @@ -127,27 +127,27 @@ }, '2: buffer.copyFromChannel(context, 0)').throw(TypeError); should(() => { buffer.copyFromChannel(x, -1); - }, '3: buffer.copyFromChannel(x, -1)').throw('IndexSizeError'); + }, '3: buffer.copyFromChannel(x, -1)').throw(DOMException, 'IndexSizeError'); should( () => { buffer.copyFromChannel(x, numberOfChannels); }, '4: buffer.copyFromChannel(x, ' + numberOfChannels + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); ; should(() => { buffer.copyFromChannel(x, 0, -1); - }, '5: buffer.copyFromChannel(x, 0, -1)').throw('IndexSizeError'); + }, '5: buffer.copyFromChannel(x, 0, -1)').throw(DOMException, 'IndexSizeError'); should( () => { buffer.copyFromChannel(x, 0, bufferLength); }, '6: buffer.copyFromChannel(x, 0, ' + bufferLength + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should(() => { buffer.copyFromChannel(x, 3); - }, '7: buffer.copyFromChannel(x, 3)').throw('IndexSizeError'); + }, '7: buffer.copyFromChannel(x, 3)').throw(DOMException, 'IndexSizeError'); if (window.SharedArrayBuffer) { let shared_buffer = new Float32Array(new SharedArrayBuffer(32)); @@ -183,26 +183,26 @@ }, '1: buffer.copyToChannel(context, 0)').throw(TypeError); should(() => { buffer.copyToChannel(x, -1); - }, '2: buffer.copyToChannel(x, -1)').throw('IndexSizeError'); + }, '2: buffer.copyToChannel(x, -1)').throw(DOMException, 'IndexSizeError'); should( () => { buffer.copyToChannel(x, numberOfChannels); }, '3: buffer.copyToChannel(x, ' + numberOfChannels + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should(() => { buffer.copyToChannel(x, 0, -1); - }, '4: buffer.copyToChannel(x, 0, -1)').throw('IndexSizeError'); + }, '4: buffer.copyToChannel(x, 0, -1)').throw(DOMException, 'IndexSizeError'); should( () => { buffer.copyToChannel(x, 0, bufferLength); }, '5: buffer.copyToChannel(x, 0, ' + bufferLength + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should(() => { buffer.copyToChannel(x, 3); - }, '6: buffer.copyToChannel(x, 3)').throw('IndexSizeError'); + }, '6: buffer.copyToChannel(x, 3)').throw(DOMException, 'IndexSizeError'); if (window.SharedArrayBuffer) { let shared_buffer = new Float32Array(new SharedArrayBuffer(32)); diff --git a/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html b/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html index 07a34f07c185f4..a2c4581c4e8006 100644 --- a/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html +++ b/webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html @@ -53,7 +53,7 @@ buffer.getChannelData(buffer.numberOfChannels); }, 'buffer.getChannelData(' + buffer.numberOfChannels + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); let buffer2 = context.createBuffer(1, 1000, 24576); let expectedDuration = 1000 / 24576; diff --git a/webaudio/the-audio-api/the-audiobuffer-interface/ctor-audiobuffer.html b/webaudio/the-audio-api/the-audiobuffer-interface/ctor-audiobuffer.html index c5aae1ad53235f..9845d5eaba384c 100644 --- a/webaudio/the-audio-api/the-audiobuffer-interface/ctor-audiobuffer.html +++ b/webaudio/the-audio-api/the-audiobuffer-interface/ctor-audiobuffer.html @@ -96,7 +96,7 @@ let buffer = new AudioBuffer(options); }, 'new AudioBuffer(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); options = {numberOfChannels: 99, length: 0, sampleRate: 16000}; should( @@ -104,7 +104,7 @@ let buffer = new AudioBuffer(options); }, 'new AudioBuffer(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); options = {numberOfChannels: 1, length: 0, sampleRate: 16000}; should( @@ -112,7 +112,7 @@ let buffer = new AudioBuffer(options); }, 'new AudioBuffer(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); options = {numberOfChannels: 1, length: 1, sampleRate: 100}; should( @@ -120,7 +120,7 @@ let buffer = new AudioBuffer(options); }, 'new AudioBuffer(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); task.done(); }); @@ -178,7 +178,7 @@ buffer.getChannelData(options.numberOfChannels); }, 'buffer.getChannelData(' + options.numberOfChannels + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels.html b/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels.html index 5527f44cc9c93e..f3f16c4c648166 100644 --- a/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels.html +++ b/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels.html @@ -47,7 +47,7 @@ should(function() { source.buffer = new AudioBuffer({length: 128, sampleRate: context.sampleRate}) - }, 'source.buffer = new buffer').throw('InvalidStateError'); + }, 'source.buffer = new buffer').throw(DOMException, 'InvalidStateError'); // The buffer has been set; it's ok to set it to null. should(function() { @@ -58,7 +58,7 @@ // again. should(function() { source.buffer = buffer; - }, 'source.buffer = buffer again').throw('InvalidStateError'); + }, 'source.buffer = buffer again').throw(DOMException, 'InvalidStateError'); // But setting to null is ok. should(function() { diff --git a/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining.html b/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining.html index 0a8c73160e543d..4163a8439cd08c 100644 --- a/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining.html +++ b/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining.html @@ -114,7 +114,7 @@ // does not have the second output, so it should throw. should(function() { gain1.connect(gain2, 1).connect(contextA.destination); - }, 'Connecting with an invalid output').throw('IndexSizeError'); + }, 'Connecting with an invalid output').throw(DOMException, 'IndexSizeError'); // Test if the second connection throws correctly. The contextB's // destination is not compatible with the nodes from contextA, thus the @@ -124,7 +124,7 @@ gain1.connect(gain2).connect(contextB.destination); }, 'Connecting to a node from the different context') - .throw('InvalidAccessError'); + .throw(DOMException, 'InvalidAccessError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html b/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html index c3d3fae2155602..386614ff2e20e7 100644 --- a/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html +++ b/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html @@ -193,17 +193,17 @@ // gain1 is not connected to gain3.gain. Exception should be thrown. should(function() { gain1.disconnect(gain3.gain); - }, 'gain1.disconnect(gain3.gain)').throw('InvalidAccessError'); + }, 'gain1.disconnect(gain3.gain)').throw(DOMException, 'InvalidAccessError'); // When the output index is good but the destination is invalid. should(function() { splitter.disconnect(gain1.gain, 1); - }, 'splitter.disconnect(gain1.gain, 1)').throw('InvalidAccessError'); + }, 'splitter.disconnect(gain1.gain, 1)').throw(DOMException, 'InvalidAccessError'); // When both arguments are wrong, throw IndexSizeError first. should(function() { splitter.disconnect(gain1.gain, 2); - }, 'splitter.disconnect(gain1.gain, 2)').throw('IndexSizeError'); + }, 'splitter.disconnect(gain1.gain, 2)').throw(DOMException, 'IndexSizeError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect.html b/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect.html index b29c09d395fc28..65b93222d1002e 100644 --- a/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect.html +++ b/webaudio/the-audio-api/the-audionode-interface/audionode-disconnect.html @@ -230,7 +230,7 @@ // There is no output #2. An exception should be thrown. should(function() { splitter.disconnect(2); - }, 'splitter.disconnect(2)').throw('IndexSizeError'); + }, 'splitter.disconnect(2)').throw(DOMException, 'IndexSizeError'); // Disconnecting the output already disconnected should not throw. should(function() { @@ -241,34 +241,34 @@ // gain1 is not connected gain2. An exception should be thrown. should(function() { gain1.disconnect(gain2); - }, 'gain1.disconnect(gain2)').throw('InvalidAccessError'); + }, 'gain1.disconnect(gain2)').throw(DOMException, 'InvalidAccessError'); // gain1 and gain3 are not connected. An exception should be thrown. should(function() { gain1.disconnect(gain3); - }, 'gain1.disconnect(gain3)').throw('InvalidAccessError'); + }, 'gain1.disconnect(gain3)').throw(DOMException, 'InvalidAccessError'); // There is no output #2 in the splitter. An exception should be thrown. should(function() { splitter.disconnect(gain2, 2); - }, 'splitter.disconnect(gain2, 2)').throw('IndexSizeError'); + }, 'splitter.disconnect(gain2, 2)').throw(DOMException, 'IndexSizeError'); // The splitter and gain1 are not connected. An exception should be // thrown. should(function() { splitter.disconnect(gain1, 0); - }, 'splitter.disconnect(gain1, 0)').throw('InvalidAccessError'); + }, 'splitter.disconnect(gain1, 0)').throw(DOMException, 'InvalidAccessError'); // The splitter output #0 and the gain3 output #0 are not connected. An // exception should be thrown. should(function() { splitter.disconnect(gain3, 0, 0); - }, 'splitter.disconnect(gain3, 0, 0)').throw('InvalidAccessError'); + }, 'splitter.disconnect(gain3, 0, 0)').throw(DOMException, 'InvalidAccessError'); // The output index is out of bound. An exception should be thrown. should(function() { splitter.disconnect(merger, 3, 0); - }, 'splitter.disconnect(merger, 3, 0)').throw('IndexSizeError'); + }, 'splitter.disconnect(merger, 3, 0)').throw(DOMException, 'IndexSizeError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-audionode-interface/audionode.html b/webaudio/the-audio-api/the-audionode-interface/audionode.html index 14cfbff7e2754c..0b57d27e8e1a7b 100644 --- a/webaudio/the-audio-api/the-audionode-interface/audionode.html +++ b/webaudio/the-audio-api/the-audionode-interface/audionode.html @@ -54,11 +54,11 @@ should( () => audioNode.connect(context.destination, 5, 0), 'audioNode.connect(context.destination, 5, 0)') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should( () => audioNode.connect(context.destination, 0, 5), 'audioNode.connect(context.destination, 0, 5)') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); should( () => audioNode.connect(context.destination, 0, 0), @@ -71,7 +71,7 @@ should( () => window.audioNode.connect(context2.destination), 'Connecting a node to a different context') - .throw('InvalidAccessError'); + .throw(DOMException, 'InvalidAccessError'); // 3-arg AudioContext doesn't create an offline context anymore. should( diff --git a/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurve-exceptions.html b/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurve-exceptions.html index 31405ebfcd2aa9..39bfb5de911dc1 100644 --- a/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurve-exceptions.html +++ b/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurve-exceptions.html @@ -46,28 +46,28 @@ g.gain.setValueAtTime(1, automationTime); }, 'setValueAtTime(1, ' + automationTime + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); should( function() { g.gain.linearRampToValueAtTime(1, automationTime); }, 'linearRampToValueAtTime(1, ' + automationTime + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); should( function() { g.gain.exponentialRampToValueAtTime(1, automationTime); }, 'exponentialRampToValueAtTime(1, ' + automationTime + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); should( function() { g.gain.setTargetAtTime(1, automationTime, 1); }, 'setTargetAtTime(1, ' + automationTime + ', 1)') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); should( function() { @@ -120,7 +120,7 @@ g.gain.setValueCurveAtTime(curve, time, 0.01); }, 'setValueCurveAtTime(curve, ' + time + ', 0.01)') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); } // Elements of setValueCurve should be finite. @@ -167,7 +167,7 @@ g.gain.setValueCurveAtTime(curve, time, 0.01); }, 'setValueCurveAtTime(curve, ' + time + ', 0.01)') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); task.done(); }); @@ -298,14 +298,14 @@ g.gain.setValueCurveAtTime(Float32Array.from([]), time, 0.01); }, 'setValueCurveAtTime([], ' + time + ', 0.01)') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); should( () => { g.gain.setValueCurveAtTime(Float32Array.from([1]), time, 0.01); }, 'setValueCurveAtTime([1], ' + time + ', 0.01)') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); should(() => { g.gain.setValueCurveAtTime(Float32Array.from([1, 2]), time, 0.01); diff --git a/webaudio/the-audio-api/the-audioparam-interface/automation-rate.html b/webaudio/the-audio-api/the-audioparam-interface/automation-rate.html index a3c789e2f2cbdb..a3c11994bbe37f 100644 --- a/webaudio/the-audio-api/the-audioparam-interface/automation-rate.html +++ b/webaudio/the-audio-api/the-audioparam-interface/automation-rate.html @@ -151,7 +151,7 @@ if (param.isFixed) { should(() => audioParam.automationRate = newRate, setMessage) - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); } else { should(() => audioParam.automationRate = newRate, setMessage) diff --git a/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html b/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html index 7cfd423c071b9a..8b7704a781b712 100644 --- a/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html +++ b/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html @@ -23,7 +23,7 @@ (task, should) => { should(() => new AudioWorkletNode(realtimeContext, 'dummy'), 'Creating a node before loading a module should throw.') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-constructor-options.https.html b/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-constructor-options.https.html index 31e204cdc8d53b..cee9ec82c20f42 100644 --- a/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-constructor-options.https.html +++ b/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-constructor-options.https.html @@ -90,13 +90,13 @@ should( () => new AudioWorkletNode(context, 'dummy', options2), 'Creating AudioWorkletNode with channelCount 0') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); const options3 = {channelCount: 33}; should( () => new AudioWorkletNode(context, 'dummy', options3), 'Creating AudioWorkletNode with channelCount 33') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html b/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html index 83f53aafb1980b..441e98a251187c 100644 --- a/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html +++ b/webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html @@ -110,7 +110,7 @@ 'new Float32Array(10), ' + 'new Float32Array(1), ' + 'new Float32Array(20))') - .throw('InvalidAccessError'); + .throw(DOMException, 'InvalidAccessError'); should( function() { @@ -123,7 +123,7 @@ 'new Float32Array(10), ' + 'new Float32Array(20), ' + 'new Float32Array(1))') - .throw('InvalidAccessError'); + .throw(DOMException, 'InvalidAccessError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-basic.html b/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-basic.html index f967f0699a3217..71a62f176f8eef 100644 --- a/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-basic.html +++ b/webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-basic.html @@ -24,7 +24,7 @@ should(function() { merger = context.createChannelMerger(0); - }, 'context.createChannelMerger(0)').throw('IndexSizeError'); + }, 'context.createChannelMerger(0)').throw(DOMException, 'IndexSizeError'); should(function() { merger = context.createChannelMerger(32); @@ -34,7 +34,7 @@ // context has a 32-channel-limit in Chrome. should(function() { merger = context.createChannelMerger(33); - }, 'context.createChannelMerger(33)').throw('IndexSizeError'); + }, 'context.createChannelMerger(33)').throw(DOMException, 'IndexSizeError'); task.done(); }); @@ -49,14 +49,14 @@ should(function() { merger.channelCount = 3; - }, 'merger.channelCount = 3').throw('InvalidStateError'); + }, 'merger.channelCount = 3').throw(DOMException, 'InvalidStateError'); should(merger.channelCountMode, 'merger.channelCountMode') .beEqualTo('explicit'); should(function() { merger.channelCountMode = 'max'; - }, 'merger.channelCountMode = "max"').throw('InvalidStateError'); + }, 'merger.channelCountMode = "max"').throw(DOMException, 'InvalidStateError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-channelmergernode-interface/ctor-channelmerger.html b/webaudio/the-audio-api/the-channelmergernode-interface/ctor-channelmerger.html index 115bd9943490ab..0d6b45c56df0f4 100644 --- a/webaudio/the-audio-api/the-channelmergernode-interface/ctor-channelmerger.html +++ b/webaudio/the-audio-api/the-channelmergernode-interface/ctor-channelmerger.html @@ -43,12 +43,15 @@ audit.define('test AudioNodeOptions', (task, should) => { testAudioNodeOptions(should, context, 'ChannelMergerNode', { - channelCount: - {value: 1, isFixed: true, errorType: 'InvalidStateError'}, + channelCount: { + value: 1, + isFixed: true, + exceptionType: 'InvalidStateError' + }, channelCountMode: { value: 'explicit', isFixed: true, - errorType: 'InvalidStateError' + exceptionType: 'InvalidStateError' } }); task.done(); @@ -82,7 +85,7 @@ node = new ChannelMergerNode(context, options); }, 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); options = {channelCount: 3}; should( @@ -90,7 +93,7 @@ node = new ChannelMergerNode(context, options); }, 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); options = {channelCountMode: 'max'}; should( @@ -98,7 +101,7 @@ node = new ChannelMergerNode(context, options); }, 'new ChannelMergerNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-channelsplitternode-interface/audiochannelsplitter.html b/webaudio/the-audio-api/the-channelsplitternode-interface/audiochannelsplitter.html index e0449919ad5e74..954c71a96b2885 100644 --- a/webaudio/the-audio-api/the-channelsplitternode-interface/audiochannelsplitter.html +++ b/webaudio/the-audio-api/the-channelsplitternode-interface/audiochannelsplitter.html @@ -75,11 +75,11 @@ let splitternode; should(() => { let splitternode = context.createChannelSplitter(0); - }, 'createChannelSplitter(0)').throw('IndexSizeError'); + }, 'createChannelSplitter(0)').throw(DOMException, 'IndexSizeError'); should(() => { splitternode = context.createChannelSplitter(33); - }, 'createChannelSplitter(33)').throw('IndexSizeError'); + }, 'createChannelSplitter(33)').throw(DOMException, 'IndexSizeError'); should(() => { splitternode = context.createChannelSplitter(32); diff --git a/webaudio/the-audio-api/the-channelsplitternode-interface/ctor-channelsplitter.html b/webaudio/the-audio-api/the-channelsplitternode-interface/ctor-channelsplitter.html index 7fa9d6fa5466d2..9cbb46b6d969a6 100644 --- a/webaudio/the-audio-api/the-channelsplitternode-interface/ctor-channelsplitter.html +++ b/webaudio/the-audio-api/the-channelsplitternode-interface/ctor-channelsplitter.html @@ -41,8 +41,11 @@ audit.define('test AudioNodeOptions', (task, should) => { testAudioNodeOptions(should, context, 'ChannelSplitterNode', { - channelCount: - {value: 6, isFixed: true, errorType: 'InvalidStateError'}, + channelCount: { + value: 6, + isFixed: true, + exceptionType: 'InvalidStateError' + }, channelCountMode: { value: 'explicit', isFixed: true, @@ -50,7 +53,7 @@ channelInterpretation: { value: 'discrete', isFixed: true, - errorType: 'InvalidStateError' + exceptionType: 'InvalidStateError' }, }); task.done(); @@ -84,7 +87,7 @@ node = new ChannelSplitterNode(context, options); }, 'new ChannelSplitterNode(c, ' + JSON.stringify(options) + ')') - .throw('IndexSizeError'); + .throw(DOMException, 'IndexSizeError'); options = {channelCount: 3}; should( @@ -92,7 +95,7 @@ node = new ChannelSplitterNode(context, options); }, 'new ChannelSplitterNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); options = {channelCountMode: 'max'}; should( @@ -100,7 +103,7 @@ node = new ChannelSplitterNode(context, options); }, 'new ChannelSplitterNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels.html b/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels.html index 11d6f332a1bbc9..ac4f198d7c1449 100644 --- a/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels.html +++ b/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels.html @@ -30,7 +30,7 @@ should(() => convolver.buffer = buffer, message).notThrow(); } else { should(() => convolver.buffer = buffer, message) - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); } } diff --git a/webaudio/the-audio-api/the-convolvernode-interface/convolver-setBuffer-already-has-value.html b/webaudio/the-audio-api/the-convolvernode-interface/convolver-setBuffer-already-has-value.html index 31f115da5321ef..c8dbeb941bc48f 100644 --- a/webaudio/the-audio-api/the-convolvernode-interface/convolver-setBuffer-already-has-value.html +++ b/webaudio/the-audio-api/the-convolvernode-interface/convolver-setBuffer-already-has-value.html @@ -27,7 +27,7 @@ should(() => { convolver.buffer = audioBuffer; - }, 'Set buffer a second time').throw('InvalidStateError'); + }, 'Set buffer a second time').throw(DOMException, 'InvalidStateError'); should(() => { convolver.buffer = null; @@ -40,7 +40,7 @@ should(() => { convolver.buffer = audioBuffer; }, 'Set buffer to non-null to verify to throw an error') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver.html b/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver.html index cf818330060143..935ceeb715edd2 100644 --- a/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver.html +++ b/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver.html @@ -46,12 +46,15 @@ audit.define('test AudioNodeOptions', (task, should) => { testAudioNodeOptions(should, context, 'ConvolverNode', { - channelCount: - {value: 2, isFixed: true, errorType: 'NotSupportedError'}, + channelCount: { + value: 2, + isFixed: true, + exceptionType: 'NotSupportedError' + }, channelCountMode: { value: 'clamped-max', isFixed: true, - errorType: 'NotSupportedError' + exceptionType: 'NotSupportedError' }, }); task.done(); diff --git a/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit.html b/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit.html index 7bbff410650c3b..caf2f85dfd459b 100644 --- a/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit.html +++ b/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit.html @@ -32,14 +32,18 @@ bufferSource.buffer = toneBuffer; window.context = context; - should(() => context.createDelay(180)).throw("NotSupportedError", - "Delay length cannot be 180 seconds or more"); - should(() => context.createDelay(0)).throw("NotSupportedError", - "Delay length cannot be 0"); - should(() => context.createDelay(-1)).throw("NotSupportedError", - "Delay length cannot be negative"); - should(() => context.createDelay(NaN)).throw(TypeError, - "Delay length cannot be a NaN"); + should(() => context.createDelay(180), + 'Setting Delay length to 180 seconds or more') + .throw(DOMException, 'NotSupportedError'); + should(() => context.createDelay(0), + 'Setting Delay length to 0 seconds') + .throw(DOMException, 'NotSupportedError'); + should(() => context.createDelay(-1), + 'Setting Delay length to negative') + .throw(DOMException, 'NotSupportedError'); + should(() => context.createDelay(NaN), + 'Setting Delay length to NaN') + .throw(TypeError); let delay = context.createDelay(179); delay.delayTime.value = delayTimeSeconds; diff --git a/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html b/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html index 98d5dbfded1e2f..c2460dfa1ddd26 100644 --- a/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html +++ b/webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html @@ -182,9 +182,12 @@ let message = 'new DynamicsCompressorNode(c, ' + JSON.stringify(options.nodeOptions) + ')'; - if (options.expectedErrorType) { + if (options.expectedErrorType === TypeError) { should(createNodeFunction(), message) .throw(options.expectedErrorType); + } else if (options.expectedErrorType === 'NotSupportedError') { + should(createNodeFunction(), message) + .throw(DOMException, 'NotSupportedError'); } else { should(createNodeFunction(), message).notThrow(); should(node[options.testAttribute], 'node.' + options.testAttribute) diff --git a/webaudio/the-audio-api/the-iirfilternode-interface/iirfilter-basic.html b/webaudio/the-audio-api/the-iirfilternode-interface/iirfilter-basic.html index 79c40dc084753d..7828f05226151e 100644 --- a/webaudio/the-audio-api/the-iirfilternode-interface/iirfilter-basic.html +++ b/webaudio/the-audio-api/the-iirfilternode-interface/iirfilter-basic.html @@ -66,17 +66,17 @@ should(function() { // There has to be at least one coefficient. context.createIIRFilter([], []); - }, 'createIIRFilter([], [])').throw('NotSupportedError'); + }, 'createIIRFilter([], [])').throw(DOMException, 'NotSupportedError'); should(function() { // There has to be at least one coefficient. context.createIIRFilter([1], []); - }, 'createIIRFilter([1], [])').throw('NotSupportedError'); + }, 'createIIRFilter([1], [])').throw(DOMException, 'NotSupportedError'); should(function() { // There has to be at least one coefficient. context.createIIRFilter([], [1]); - }, 'createIIRFilter([], [1])').throw('NotSupportedError'); + }, 'createIIRFilter([], [1])').throw(DOMException, 'NotSupportedError'); should( function() { @@ -96,7 +96,7 @@ context.createIIRFilter(coef, [1]); }, 'createIIRFilter(new Float32Array(21), [1])') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); should( function() { @@ -106,7 +106,7 @@ context.createIIRFilter([1], coef); }, 'createIIRFilter([1], new Float32Array(21))') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); should( function() { @@ -114,7 +114,7 @@ context.createIIRFilter([1], new Float32Array(2)); }, 'createIIRFilter([1], new Float32Array(2))') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); should( function() { @@ -122,7 +122,7 @@ context.createIIRFilter(new Float32Array(10), [1]); }, 'createIIRFilter(new Float32Array(10), [1])') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); should(function() { // Feedback coefficients must be finite. @@ -183,7 +183,7 @@ new Float32Array(20)); }, 'getFrequencyResponse(new Float32Array(10), new Float32Array(1), new Float32Array(20))') - .throw('InvalidAccessError'); + .throw(DOMException, 'InvalidAccessError'); should( function() { @@ -193,7 +193,7 @@ new Float32Array(1)); }, 'getFrequencyResponse(new Float32Array(10), new Float32Array(20), new Float32Array(1))') - .throw('InvalidAccessError'); + .throw(DOMException, 'InvalidAccessError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html b/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html index f480ec8ce51f92..4b6863103622c5 100644 --- a/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html +++ b/webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html @@ -129,7 +129,7 @@ new OfflineAudioContext(options); }, 'new OfflineAudioContext(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); // length cannot be 0 options = {length: 0, sampleRate: 8000}; @@ -138,7 +138,7 @@ new OfflineAudioContext(options); }, 'new OfflineAudioContext(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); // sampleRate outside valid range options = {length: 1, sampleRate: 1}; @@ -147,7 +147,7 @@ new OfflineAudioContext(options); }, 'new OfflineAudioContext(' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); task.done(); }); diff --git a/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator.html b/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator.html index aaf77aec555b72..36bf604b296c63 100644 --- a/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator.html +++ b/webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator.html @@ -87,7 +87,7 @@ node = new OscillatorNode(context, options); }, 'new OscillatorNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); options = { type: 'custom', diff --git a/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html b/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html index 5475a6210b724a..98a171ad059eaf 100644 --- a/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html +++ b/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html @@ -107,7 +107,7 @@ node = new PannerNode(context, options); }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); options = {channelCount: 3}; should( @@ -115,7 +115,7 @@ node = new PannerNode(context, options); }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); options = {channelCount: 99}; should( @@ -123,7 +123,7 @@ node = new PannerNode(context, options); }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); // Test channelCountMode. A mode of "max" is illegal, but others are // ok. @@ -153,7 +153,7 @@ node = new PannerNode(context, options); }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') - .throw('NotSupportedError'); + .throw(DOMException, 'NotSupportedError'); options = {channelCountMode: 'foobar'}; should( diff --git a/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner.html b/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner.html index caa99aa4031a22..9409f1ffce2110 100644 --- a/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner.html +++ b/webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner.html @@ -80,17 +80,23 @@ entry.tests.forEach(testItem => { let options = {}; options[entry.attribute] = testItem.value; - let method = testItem.error ? 'throw' : 'notThrow'; - - should( - () => { - node = new StereoPannerNode(context, options); - }, - `new StereoPannerNode(c, ${JSON.stringify(options)})`)[method]( - testItem.error); - if (!testItem.error) + + const testFunction = () => { + node = new StereoPannerNode(context, options); + }; + const testDescription = + `new StereoPannerNode(c, ${JSON.stringify(options)})`; + + if (testItem.error) { + testItem.error === TypeError + ? should(testFunction, testDescription).throw(TypeError) + : should(testFunction, testDescription) + .throw(DOMException, 'NotSupportedError'); + } else { + should(testFunction, testDescription).notThrow(); should(node[entry.attribute], `node.${entry.attribute}`) .beEqualTo(options[entry.attribute]); + } }); });