Skip to content

Commit

Permalink
Update audit.js and fix error catching logic in should().throw()
Browse files Browse the repository at this point in the history
Fetch/update audit.js in non-WPT layout tests and also fix the error
in the error catching logic in should().throw() assertion.

The updated code checks if the |error| object passed by try/catch
is "DOMException". This is unnecessarily specific, so this CL changes
the check to look for the "Error" type, which is more generic.

Bug: 865614
Test: All layout tests pass.
Change-Id: I16acacb26c194a0ff950aca05e931195bf55167f
  • Loading branch information
hoch authored and Chrome-bot committed Aug 23, 2018
1 parent e57d136 commit d16f5e3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions webaudio/resources/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ 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.
* String, then it is considered to be the name of an Error. It can also be
* an instance of an Error to be more strict about the actual error type.
*
* @example
* should(() => { let a = b; }, 'A bad code').throw();
Expand Down Expand Up @@ -313,10 +312,10 @@ 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 &&
} else if (typeof this._expected === "string" &&
error instanceof Error &&
error.name === this._expected) {
// A DOMException was thrown and expected, and the names match
// An |Error| was thrown and expected, and the names match.
didThrowCorrectly = true;
passDetail = '${actual} threw ${expected}' + errorMessage + '.';
} else if (this._expected == error.constructor &&
Expand Down

0 comments on commit d16f5e3

Please sign in to comment.