From 482ee109096581faa8e5a17896dbfaa459df10ab Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 12:41:56 -0700 Subject: [PATCH 1/4] test: rename WPT console test test-console-is-a-namespace.js is a WPT Console test. It is the only WPT Console test file that we have that doesn't start with `test-whatwg-`. Rename it to test-whatwg-console-is-a-namespace.js so that WPT tests can be found relatively easily. Just as it is useful to separate the WPT URL tests from our URL tests, it will likely be useful to separate our Console tests from WPT Console tests if we add more WPT Console tests (which I hope we do). --- ...le-is-a-namespace.js => test-whatwg-console-is-a-namespace.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/parallel/{test-console-is-a-namespace.js => test-whatwg-console-is-a-namespace.js} (100%) diff --git a/test/parallel/test-console-is-a-namespace.js b/test/parallel/test-whatwg-console-is-a-namespace.js similarity index 100% rename from test/parallel/test-console-is-a-namespace.js rename to test/parallel/test-whatwg-console-is-a-namespace.js From 9c00fd01f4810273f36c7fc910a0a214915fcd1f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 13:17:32 -0700 Subject: [PATCH 2/4] test: add WPT console-label-conversion test Add console-label-conversion.any.js from WPT to the test suite. --- .../test-whatwg-console-label-conversion.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/parallel/test-whatwg-console-label-conversion.js diff --git a/test/parallel/test-whatwg-console-label-conversion.js b/test/parallel/test-whatwg-console-label-conversion.js new file mode 100644 index 00000000000000..74c6c007b0151a --- /dev/null +++ b/test/parallel/test-whatwg-console-label-conversion.js @@ -0,0 +1,45 @@ +'use strict'; + +require('../common'); + +const { test, assert_true, assert_throws } = + require('../common/wpt'); + +/* eslint-disable max-len, object-curly-spacing */ + +/* The following tests should not be modified as they are copied */ +/* WPT Refs: + https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/console/console-label-conversion.any.js + License: hhttps://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md +*/ + +// 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`); +} + +/* eslint-enable */ From 168566d173abe0fda33c1d343a417c2197d9ba00 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 13:20:49 -0700 Subject: [PATCH 3/4] test: separate WPT console test from other test Remove one test from test-whatwg-console-is-a-namespace that is not part of the WPT test. Put it in test-console-self-assign. --- test/parallel/test-console-self-assign.js | 6 ++++++ test/parallel/test-whatwg-console-is-a-namespace.js | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-console-self-assign.js diff --git a/test/parallel/test-console-self-assign.js b/test/parallel/test-console-self-assign.js new file mode 100644 index 00000000000000..53c54ab9a327cf --- /dev/null +++ b/test/parallel/test-console-self-assign.js @@ -0,0 +1,6 @@ +'use strict'; + +require('../common'); + +// Assigning to itself should not throw. +global.console = global.console; // eslint-disable-line no-self-assign diff --git a/test/parallel/test-whatwg-console-is-a-namespace.js b/test/parallel/test-whatwg-console-is-a-namespace.js index 82665411879ca9..fb28e751a322af 100644 --- a/test/parallel/test-whatwg-console-is-a-namespace.js +++ b/test/parallel/test-whatwg-console-is-a-namespace.js @@ -5,9 +5,6 @@ require('../common'); const { test, assert_equals, assert_true, assert_false } = require('../common/wpt'); -// Assigning to itself should not throw. -global.console = global.console; // eslint-disable-line no-self-assign - const self = global; /* eslint-disable quotes, max-len */ From d02063b35549eaa5a4ce2a0ea2ed6702eddc3fd9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 8 Oct 2018 13:26:05 -0700 Subject: [PATCH 4/4] test: add WPT console-tests-historical Add WPT console-tests-historical to the test suite. --- .../test-whatwg-console-label-conversion.js | 2 +- .../test-whatwg-console-tests-historical.js | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-whatwg-console-tests-historical.js diff --git a/test/parallel/test-whatwg-console-label-conversion.js b/test/parallel/test-whatwg-console-label-conversion.js index 74c6c007b0151a..9131a0c175d11c 100644 --- a/test/parallel/test-whatwg-console-label-conversion.js +++ b/test/parallel/test-whatwg-console-label-conversion.js @@ -10,7 +10,7 @@ const { test, assert_true, assert_throws } = /* The following tests should not be modified as they are copied */ /* WPT Refs: https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/console/console-label-conversion.any.js - License: hhttps://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md + License: https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md */ // https://console.spec.whatwg/org/#counting diff --git a/test/parallel/test-whatwg-console-tests-historical.js b/test/parallel/test-whatwg-console-tests-historical.js new file mode 100644 index 00000000000000..d4a998b07061b9 --- /dev/null +++ b/test/parallel/test-whatwg-console-tests-historical.js @@ -0,0 +1,36 @@ +'use strict'; + +require('../common'); + +const { test, assert_equals } = + require('../common/wpt'); + +/* eslint-disable max-len, quotes */ + +/* The following tests should not be modified as they are copied */ +/* WPT Refs: + https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/console/console-tests-historical.any.js + License: https://github.com/web-platform-tests/wpt/blob/6f0a96ed650935b17b6e5d277889cfbe0ccc103e/LICENSE.md +*/ + +/** + * These tests assert the non-existence of certain + * legacy Console methods that are not included in + * the specification: http://console.spec.whatwg.org/ + */ + +"use strict"; + +test(() => { + assert_equals(console.timeline, undefined, "console.timeline should be undefined"); +}, "'timeline' function should not exist on the console object"); + +test(() => { + assert_equals(console.timelineEnd, undefined, "console.timelineEnd should be undefined"); +}, "'timelineEnd' function should not exist on the console object"); + +test(() => { + assert_equals(console.markTimeline, undefined, "console.markTimeline should be undefined"); +}, "'markTimeline' function should not exist on the console object"); + +/* eslint-enable */