Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WPT Console tests #23340

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/parallel/test-console-self-assign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

require('../common');

// Assigning to itself should not throw.
global.console = global.console; // eslint-disable-line no-self-assign
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
45 changes: 45 additions & 0 deletions test/parallel/test-whatwg-console-label-conversion.js
Original file line number Diff line number Diff line change
@@ -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: https://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 */
36 changes: 36 additions & 0 deletions test/parallel/test-whatwg-console-tests-historical.js
Original file line number Diff line number Diff line change
@@ -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 */