Skip to content

Commit

Permalink
Console time/timeEnd label conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino authored and domenic committed Mar 3, 2017
1 parent 3822eee commit 80b0f65
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions console/OWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@domenic
@pwnall
@domfarolino
46 changes: 46 additions & 0 deletions console/console-time-label-conversion.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"use strict";
// https://console.spec.whatwg.org/#timing

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

console.time({
toString() {
timeLabelToStringCalled = true;
}
});

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

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

console.timeEnd({
toString() {
timeEndLabelToStringCalled = true;
}
});

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

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

test(() => {
assert_throws({name: "Error"}, () => {
console.timeEnd({
toString() {
throw new Error("conversion error");
}
});
}, "timeEnd() must re-throw any exceptions thrown by label.toString() conversion");
}, "console.timeEnd() throws exceptions generated by erroneous label.toString() conversion");
1 change: 1 addition & 0 deletions lint.whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ PRINT STATEMENT:encrypted-media/polyfill/make-polyfill-tests.py
W3C-TEST.ORG:subresource-integrity/refresh-header.js.headers

# semi-legitimate use of console.*
CONSOLE:console/*
CONSOLE:streams/resources/test-utils.js
CONSOLE:service-workers/service-worker/resources/navigation-redirect-other-origin.html
CONSOLE:service-workers/service-worker/navigation-redirect.https.html
Expand Down

0 comments on commit 80b0f65

Please sign in to comment.