mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
03ae8985da
Automatic update from web-platform-testsConsolidate console label conversion tests + add timeLog -- wpt-commits: 38ef0a35c3890876923fe96d34e5ebbb56c4e568 wpt-pr: 11401
30 lines
927 B
JavaScript
30 lines
927 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({name: '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`);
|
|
}
|