• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"use strict";
2// https://console.spec.whatwg/org/#counting
3// https://console.spec.whatwg/org/#timing
4
5const methods = ['count', 'countReset', 'time', 'timeLog', 'timeEnd'];
6
7for (const method of methods) {
8  test(() => {
9    let labelToStringCalled = false;
10
11    console[method]({
12      toString() {
13        labelToStringCalled = true;
14      }
15    });
16
17    assert_true(labelToStringCalled, `${method}() must call toString() on label when label is an object`);
18  }, `console.${method}()'s label gets converted to string via label.toString() when label is an object`);
19
20  test(() => {
21    assert_throws({name: 'Error'}, () => {
22      console[method]({
23        toString() {
24          throw new Error('conversion error');
25        }
26      });
27    }, `${method} must re-throw any exceptions thrown by label.toString() conversion`);
28  }, `console.${method}() throws exceptions generated by erroneous label.toString() conversion`);
29}
30