Commit a9f9abb3 authored by hongchan's avatar hongchan Committed by Commit bot

Add options.omitErrorMessage for should.throw()

This suppresses unnecessary error message (due to the local hardware
configuration) from the exception from should.throw().

BUG=709167
TEST=webaudio/dom-exceptions.html

Review-Url: https://codereview.chromium.org/2803913003
Cr-Commit-Position: refs/heads/master@{#462680}
parent 7d3049a9
...@@ -96,7 +96,7 @@ PASS node.channelCountMode = "fancy" did not throw an exception. ...@@ -96,7 +96,7 @@ PASS node.channelCountMode = "fancy" did not throw an exception.
PASS node.channelCountMode is equal to max. PASS node.channelCountMode is equal to max.
PASS node.channelInterpretation = mode did not throw an exception. PASS node.channelInterpretation = mode did not throw an exception.
PASS node.channelInterpretation is equal to speakers. PASS node.channelInterpretation is equal to speakers.
PASS context.destination.channelCount = 99 threw IndexSizeError: "Failed to set the 'channelCount' property on 'AudioNode': The channel count provided (99) is outside the range [1, 2].". PASS context.destination.channelCount = 99 threw IndexSizeError: [error message omitted].
PASS < [channel-stuff] All assertions passed. (total 7 assertions) PASS < [channel-stuff] All assertions passed. (total 7 assertions)
PASS > [audioparam] PASS > [audioparam]
PASS param.setValueCurveAtTime(null, 0, 0) threw TypeError: "Failed to execute 'setValueCurveAtTime' on 'AudioParam': parameter 1 is not of type 'Float32Array'.". PASS param.setValueCurveAtTime(null, 0, 0) threw TypeError: "Failed to execute 'setValueCurveAtTime' on 'AudioParam': parameter 1 is not of type 'Float32Array'.".
......
...@@ -323,7 +323,7 @@ audit.define( ...@@ -323,7 +323,7 @@ audit.define(
should( should(
() => context.destination.channelCount = 99, () => context.destination.channelCount = 99,
'context.destination.channelCount = 99') 'context.destination.channelCount = 99')
.throw('IndexSizeError'); .throw('IndexSizeError', { omitErrorMessage: true });
task.done(); task.done();
}); });
......
...@@ -269,10 +269,15 @@ window.Audit = (function () { ...@@ -269,10 +269,15 @@ window.Audit = (function () {
* should(() => { let a = b; }, 'A bad code').throw(); * should(() => { let a = b; }, 'A bad code').throw();
* should(() => { let c = d; }, 'Assigning d to c.') * should(() => { let c = d; }, 'Assigning d to c.')
* .throw('ReferenceError'); * .throw('ReferenceError');
* should(() => { let e = f; }, 'Assigning e to f.')
* .throw('ReferenceError', { omitErrorMessage: true });
* *
* @result * @result
* "PASS A bad code threw an exception of ReferenceError." * "PASS A bad code threw an exception of ReferenceError: b is not
* "PASS Assigning d to c threw ReferenceError." * defined."
* "PASS Assigning d to c threw ReferenceError: d is not defined."
* "PASS Assigning e to f threw ReferenceError: [error message
* omitted]."
*/ */
throw () { throw () {
this._processArguments(arguments); this._processArguments(arguments);
...@@ -287,16 +292,17 @@ window.Audit = (function () { ...@@ -287,16 +292,17 @@ window.Audit = (function () {
// Catch did not happen, so the test is failed. // Catch did not happen, so the test is failed.
failDetail = '${actual} did not throw an exception.'; failDetail = '${actual} did not throw an exception.';
} catch (error) { } catch (error) {
let errorMessage = this._options.omitErrorMessage
? ': [error message omitted]'
: ': "' + error.message + '"';
if (this._expected === null || this._expected === undefined) { if (this._expected === null || this._expected === undefined) {
// The expected error type was not given. // The expected error type was not given.
didThrowCorrectly = true; didThrowCorrectly = true;
passDetail = '${actual} threw ' + error.name + ': "' passDetail = '${actual} threw ' + error.name + errorMessage + '.';
+ error.message + '".';
} else if (error.name === this._expected) { } else if (error.name === this._expected) {
// The expected error type match the actual one. // The expected error type match the actual one.
didThrowCorrectly = true; didThrowCorrectly = true;
passDetail = '${actual} threw ${expected}: "' passDetail = '${actual} threw ${expected}' + errorMessage + '.';
+ error.message + '".';
} else { } else {
didThrowCorrectly = false; didThrowCorrectly = false;
failDetail = '${actual} threw "' + error.name failDetail = '${actual} threw "' + error.name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment