gecko-dev/testing/web-platform/tests/console/console-label-conversion.any.js
Dominic Farolino 03ae8985da Bug 1467737 [wpt PR 11401] - Consolidate label conversion tests + add timeLog, a=testonly
Automatic update from web-platform-testsConsolidate console label conversion tests + add timeLog

--

wpt-commits: 38ef0a35c3890876923fe96d34e5ebbb56c4e568
wpt-pr: 11401
2018-07-11 07:52:08 +01:00

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`);
}