Skip to content

Commit

Permalink
Bug 1485198 [wpt PR 12606] - Fix the error catching logic of should()…
Browse files Browse the repository at this point in the history
….throw() in audit.js, a=testonly

Automatic update from web-platform-testsFix the error catching logic of should().throw() in audit.js

Context: web-platform-tests/wpt#12606

Change the logic of should.throw() so we can handle 3 cases -

should(someExpression).throw();
should(someExpression).throw(TypeError);
should(someExpression).throw(DOMException, 'NotSupportedError');

The generic error (except for DOMException) can be passed without
the second argument, but this change will enforce the second arg
when the expected error is a DOMException type.

This touches many test files, so the work will be done in several
steps:

1. Change audit.js, audionodeoptions.js on both locations.
  (wpt, non-wpt)
2. Update affected test files with the script.
3. Update the rest of test files which can't be updated
  programmatically.

Bug: 865614
Test: All layout tests pass.
Change-Id: I16acacb26c194a0ff950aca05e931195bf55167f
Reviewed-on: https://chromium-review.googlesource.com/1184146
Commit-Queue: Hongchan Choi <[email protected]>
Reviewed-by: Raymond Toy <[email protected]>
Cr-Commit-Position: refs/heads/master@{#587660}

--

wpt-commits: 4fd41de6ecf73b21534c81fc0f516defdca50ab1
wpt-pr: 12606
  • Loading branch information
hoch authored and moz-wptsync-bot committed Sep 5, 2018
1 parent ef05dc1 commit 0d5cdef
Show file tree
Hide file tree
Showing 33 changed files with 196 additions and 169 deletions.
64 changes: 32 additions & 32 deletions testing/web-platform/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -654315,7 +654315,7 @@
"support"
],
"webaudio/resources/audionodeoptions.js": [
"0d90a9c630013b9b46ba49c106e0daa89da7032e",
"df0090c6d605fc0ea5fca224de83e0f472618f9a",
"support"
],
"webaudio/resources/audioparam-testing.js": [
Expand All @@ -654327,7 +654327,7 @@
"support"
],
"webaudio/resources/audit.js": [
"7ffa4392b05a15dfacafa7d89c902d977ed23266",
"b7ca020161071437087c349c0e8b59dbf132f764",
"support"
],
"webaudio/resources/biquad-filters.js": [
Expand Down Expand Up @@ -654379,7 +654379,7 @@
"support"
],
"webaudio/resources/start-stop-exceptions.js": [
"9a77e67ed8634ca53237edcdbf71ca26866b23f9",
"0d2ea12f6db8257878087646157242cce37ed507",
"support"
],
"webaudio/resources/stereopanner-testing.js": [
Expand All @@ -654391,7 +654391,7 @@
"support"
],
"webaudio/the-audio-api/the-analysernode-interface/ctor-analyser.html": [
"2112edeeffcf5688357d98b5161e6c3ab2d761ad",
"4e27f842ddeda3e2bdd78da7b8ee3f67062d1a9f",
"testharness"
],
"webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-basic.html": [
Expand All @@ -654403,7 +654403,7 @@
"testharness"
],
"webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing.html": [
"b3de37f119f167469a4337d520345f820a6c4165",
"7ee6a2237edd209256ac2d46be6893a5305383a0",
"testharness"
],
"webaudio/the-audio-api/the-analysernode-interface/test-analyser-gain.html": [
Expand Down Expand Up @@ -654431,19 +654431,19 @@
"support"
],
"webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer-copy-channel.html": [
"b71078d8f8094cdc43ba3adfc33d0f6f15931b33",
"e0359953d2e909f69066885515f4a3f3cc00ff02",
"testharness"
],
"webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer-getChannelData.html": [
"612a91cf4ef60f6f1d441d27e2ab86f32b94f0fd",
"testharness"
],
"webaudio/the-audio-api/the-audiobuffer-interface/audiobuffer.html": [
"07a34f07c185f4bc9dcf1b325bb51067610b430a",
"a2c4581c4e80069f227fe29078bc3eb6409c8b4e",
"testharness"
],
"webaudio/the-audio-api/the-audiobuffer-interface/ctor-audiobuffer.html": [
"c5aae1ad53235f7b0f10bc3535d9a3fe5150760f",
"9845d5eaba384cced3c63ddbf4df1400b31f4994",
"testharness"
],
"webaudio/the-audio-api/the-audiobuffersourcenode-interface/.gitkeep": [
Expand All @@ -654455,7 +654455,7 @@
"testharness"
],
"webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-channels.html": [
"5527f44cc9c93e72214ca228fa53e830a8cfcead",
"f3f16c4c648166dfdb394a41881d4a515d097e86",
"testharness"
],
"webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-ended.html": [
Expand Down Expand Up @@ -654543,7 +654543,7 @@
"testharness"
],
"webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining.html": [
"0a8c73160e543d6f9d382b536e5c41f7d29c6e9a",
"4163a8439cd08c1f8cdcb587c569653c2618e021",
"testharness"
],
"webaudio/the-audio-api/the-audionode-interface/audionode-connect-order.html": [
Expand All @@ -654555,15 +654555,15 @@
"testharness"
],
"webaudio/the-audio-api/the-audionode-interface/audionode-disconnect-audioparam.html": [
"c3d3fae2155602bbae7494e0e1439ea1a477b054",
"386614ff2e20e7abd4e511bf5e9d7d492cddfeb3",
"testharness"
],
"webaudio/the-audio-api/the-audionode-interface/audionode-disconnect.html": [
"b29c09d395fc2815ee5441fdb06320ad02f2f3f5",
"65b93222d1002e227ab1ad2e29b6e140b65bd9e4",
"testharness"
],
"webaudio/the-audio-api/the-audionode-interface/audionode.html": [
"14cfbff7e2754c4ee028c7ead599e87849a60922",
"0b57d27e8e1a7b7339d0e47641cbba27ab419612",
"testharness"
],
"webaudio/the-audio-api/the-audionode-interface/channel-mode-interp-basic.html": [
Expand Down Expand Up @@ -654607,7 +654607,7 @@
"testharness"
],
"webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurve-exceptions.html": [
"7990d0aee134cb33082e058b41bdaafc69bb507e",
"df36732c3479f48fbb77a60176cdfa22f58a3611",
"testharness"
],
"webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html": [
Expand All @@ -654623,7 +654623,7 @@
"support"
],
"webaudio/the-audio-api/the-audioparam-interface/automation-rate.html": [
"a3c789e2f2cbdb31e540bf5cc58850786b4ed73b",
"a3c11994bbe37f26aa1c2eafbb4f287d559fae34",
"testharness"
],
"webaudio/the-audio-api/the-audioparam-interface/event-insertion.html": [
Expand Down Expand Up @@ -654731,11 +654731,11 @@
"testharness"
],
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-construction.https.html": [
"7cfd423c071b9a8283e291f200615b2e0a69c797",
"8b7704a781b712c0129b650da898ed79baad794c",
"testharness"
],
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-constructor-options.https.html": [
"31e204cdc8d53bfaf0226c34a0e5daf42c813b61",
"cee9ec82c20f42a5941698fc394e6babb639ace9",
"testharness"
],
"webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-disconnected-input.https.html": [
Expand Down Expand Up @@ -654811,7 +654811,7 @@
"testharness"
],
"webaudio/the-audio-api/the-biquadfilternode-interface/biquad-basic.html": [
"83f53aafb1980bf991f4d12c3a3a472b82df61a6",
"441e98a251187c3cc600299681306d29df11e618",
"testharness"
],
"webaudio/the-audio-api/the-biquadfilternode-interface/biquad-getFrequencyResponse.html": [
Expand Down Expand Up @@ -654863,7 +654863,7 @@
"support"
],
"webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-basic.html": [
"f967f0699a321783fe832464b6e72a2a12021746",
"71a62f176f8eefd9b9168b2c222cc6d1c752d3a5",
"testharness"
],
"webaudio/the-audio-api/the-channelmergernode-interface/audiochannelmerger-disconnect.html": [
Expand All @@ -654879,19 +654879,19 @@
"testharness"
],
"webaudio/the-audio-api/the-channelmergernode-interface/ctor-channelmerger.html": [
"115bd9943490ab09efbff70239167911eb83d933",
"0d6b45c56df0f43a0eac3f364cadca2e4669c6ed",
"testharness"
],
"webaudio/the-audio-api/the-channelsplitternode-interface/.gitkeep": [
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
"support"
],
"webaudio/the-audio-api/the-channelsplitternode-interface/audiochannelsplitter.html": [
"e0449919ad5e744065bb0257dddfe9b488511812",
"954c71a96b288530e6c22878fed7a91f42091dc2",
"testharness"
],
"webaudio/the-audio-api/the-channelsplitternode-interface/ctor-channelsplitter.html": [
"7fa9d6fa5466d2fbfeec8bbcf0718b80b52d2298",
"9cbb46b6d969a6440fc5b29ee1a20d607912fc83",
"testharness"
],
"webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic.html": [
Expand Down Expand Up @@ -654927,7 +654927,7 @@
"testharness"
],
"webaudio/the-audio-api/the-convolvernode-interface/convolver-channels.html": [
"11d6f332a1bbc943bec1ad7391610ffe776b955c",
"ac4f198d7c1449f38ca14963f73b0d3d90b40b5b",
"testharness"
],
"webaudio/the-audio-api/the-convolvernode-interface/convolver-response-1-chan.html": [
Expand All @@ -654943,7 +654943,7 @@
"testharness"
],
"webaudio/the-audio-api/the-convolvernode-interface/convolver-setBuffer-already-has-value.html": [
"31f115da5321ef52be0ee1ba078b726473694b9c",
"c8dbeb941bc48f4f3a92907cb140a29f96567057",
"testharness"
],
"webaudio/the-audio-api/the-convolvernode-interface/convolver-setBuffer-null.html": [
Expand All @@ -654955,7 +654955,7 @@
"testharness"
],
"webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver.html": [
"cf818330060143078cacbecf77724244eee55cf8",
"935ceeb715edd2ffdeb7979d6824736fa82b6d2f",
"testharness"
],
"webaudio/the-audio-api/the-delaynode-interface/.gitkeep": [
Expand Down Expand Up @@ -654983,7 +654983,7 @@
"testharness"
],
"webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit.html": [
"7bbff410650c3bd234c47f080697705b088bd6a4",
"caf2f85dfd459b2d48526b8f4c13b37b2bceaddb",
"testharness"
],
"webaudio/the-audio-api/the-delaynode-interface/delaynode-scheduling.html": [
Expand All @@ -655003,7 +655003,7 @@
"support"
],
"webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html": [
"98d5dbfded1e2f10e32b14444279760fa2cdeec1",
"c2460dfa1ddd26a5c2e199873c0b28189275ff83",
"testharness"
],
"webaudio/the-audio-api/the-dynamicscompressornode-interface/dynamicscompressor-basic.html": [
Expand Down Expand Up @@ -655043,7 +655043,7 @@
"testharness"
],
"webaudio/the-audio-api/the-iirfilternode-interface/iirfilter-basic.html": [
"79c40dc084753d48970212eafd97ef531c0ae402",
"7828f05226151ebf7d6c7ec984cae1f90ef848d2",
"testharness"
],
"webaudio/the-audio-api/the-iirfilternode-interface/iirfilter-getFrequencyResponse.html": [
Expand Down Expand Up @@ -655079,7 +655079,7 @@
"support"
],
"webaudio/the-audio-api/the-offlineaudiocontext-interface/ctor-offlineaudiocontext.html": [
"f480ec8ce51f929417b922adf60a2f9ede800fcd",
"4b6863103622c5fb248dee3e3eb20d955275d037",
"testharness"
],
"webaudio/the-audio-api/the-offlineaudiocontext-interface/current-time-block-size.html": [
Expand All @@ -655091,15 +655091,15 @@
"support"
],
"webaudio/the-audio-api/the-oscillatornode-interface/ctor-oscillator.html": [
"aaf77aec555b720b343a9e63adae924c730510dc",
"36bf604b296c63b213d99408ab38937c62a755dc",
"testharness"
],
"webaudio/the-audio-api/the-pannernode-interface/.gitkeep": [
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
"support"
],
"webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html": [
"5475a6210b724ab2d6a0cefedee9c5432953c61f",
"98a171ad059eaf9b8e24f3f46db4658f76773f19",
"testharness"
],
"webaudio/the-audio-api/the-pannernode-interface/distance-exponential.html": [
Expand Down Expand Up @@ -655159,7 +655159,7 @@
"support"
],
"webaudio/the-audio-api/the-stereopanner-interface/ctor-stereopanner.html": [
"caa99aa4031a22f8c538e5622470560a50c4d5bc",
"9409f1ffce2110c177332388988d7ddb559d3ae2",
"testharness"
],
"webaudio/the-audio-api/the-stereopanner-interface/no-dezippering.html": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
35 changes: 19 additions & 16 deletions testing/web-platform/tests/webaudio/resources/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]."
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 0d5cdef

Please sign in to comment.