Automatic update from web-platform-tests
Replace some "assert_throws({'name': 'jserror'}, stuff)" with assert_throws_js. (#21379)
This diff was generated by running:
find . -type f -print0 | xargs -0 perl -pi -e "BEGIN { \$/ = undef; } s/assert_throws\(([ \n]*)\{ *[\"']?name[\"']? *: *['\"](TypeError|Error)[\"'] *\} *(, *.)/assert_throws_js(\1\2\3/gs"
in bash (doesn't work in tcsh, due to the $ inside "") and then manually
changing service-workers/service-worker/ServiceWorkerGlobalScope/resources/extendable-message-event-constructor-worker.js
to use assert_throws_exactly in a few places where we want to verify that
specific exception values are propagated out.
Co-authored-by: Boris Zbarsky <bzbarsky@mit.edu>
--
wpt-commits: b0daaa6b86c3dc2f9c16aa362136655c0db7308b
wpt-pr: 21379
30 lines
920 B
JavaScript
30 lines
920 B
JavaScript
"use strict";
|
|
// https://console.spec.whatwg/org/#counting
|
|
// https://console.spec.whatwg/org/#timing
|
|
|
|
const methods = ['count', 'countReset', 'time', 'timeLog', 'timeEnd'];
|
|
|
|
for (const method of methods) {
|
|
test(() => {
|
|
let labelToStringCalled = false;
|
|
|
|
console[method]({
|
|
toString() {
|
|
labelToStringCalled = true;
|
|
}
|
|
});
|
|
|
|
assert_true(labelToStringCalled, `${method}() must call toString() on label when label is an object`);
|
|
}, `console.${method}()'s label gets converted to string via label.toString() when label is an object`);
|
|
|
|
test(() => {
|
|
assert_throws_js(Error, () => {
|
|
console[method]({
|
|
toString() {
|
|
throw new Error('conversion error');
|
|
}
|
|
});
|
|
}, `${method} must re-throw any exceptions thrown by label.toString() conversion`);
|
|
}, `console.${method}() throws exceptions generated by erroneous label.toString() conversion`);
|
|
}
|