Treat any argument to the done callback as an error

This reduces the risk of incorrectly passing a spec due to not correctly
detecting that an argument is an `Error` instance. Detecting Error instances
in a way that's reliable and portable across different browsers, TrustedTypes,
and frames is difficult.

[Finishes #178267587]
This commit is contained in:
Steve Gravrock
2021-07-24 09:30:39 -07:00
parent 6f04044417
commit 0170005015
3 changed files with 23 additions and 113 deletions

View File

@@ -100,17 +100,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
next = once(function next(err) {
cleanup();
if (j$.isError_(err)) {
if (typeof err !== 'undefined') {
if (!(err instanceof StopExecutionError) && !err.jasmineMessage) {
self.fail(err);
}
self.errored = errored = true;
} else if (typeof err !== 'undefined' && !self.errored) {
self.deprecated(
'Any argument passed to a done callback will be treated as an ' +
'error in a future release. Call the done callback without ' +
"arguments if you don't want to trigger a spec failure."
);
}
function runNext() {