https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 87ab33ad66664bc19c0b9b54493a496e621ccf96 authored by L. David Baron on 04 April 2018, 23:15:54 UTC
Sync Mozilla tests as of https://hg.mozilla.org/mozilla-central/rev/071ee904485e21e19ca08456d32bce6825b77a26 .
Tip revision: 87ab33a
console-count-label-conversion.any.js
"use strict";
// https://console.spec.whatwg.org/#count

test(() => {
  let countLabelToStringCalled = false;

  console.count({
    toString() {
      countLabelToStringCalled = true;
    }
  });

  assert_true(countLabelToStringCalled, "toString() must be called on count()'s label when label is an object");
}, "console.count()'s label gets converted to string via label.toString() when label is an object");

test(() => {
  assert_throws({name: "Error"}, () => {
    console.count({
      toString() {
        throw new Error("conversion error");
      }
    });
  }, "count() must re-throw any exceptions thrown by label.toString() conversion");
}, "console.count() throws exceptions generated by erroneous label.toString() conversion");
back to top