summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2018-10-08 13:17:32 -0700
committerRich Trott <rtrott@gmail.com>2018-10-10 15:07:48 -0700
commit39490798ba9198f65cee4b8a13e74a5019ab12d3 (patch)
tree69fb2292fc9ecfa596c94c57abc232a4b2f8e674 /test
parentb3980c76e433f1ff51912108b8b607c04655e014 (diff)
downloadandroid-node-v8-39490798ba9198f65cee4b8a13e74a5019ab12d3.tar.gz
android-node-v8-39490798ba9198f65cee4b8a13e74a5019ab12d3.tar.bz2
android-node-v8-39490798ba9198f65cee4b8a13e74a5019ab12d3.zip
test: add WPT console-label-conversion test
Add console-label-conversion.any.js from WPT to the test suite. PR-URL: https://github.com/nodejs/node/pull/23340 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-whatwg-console-label-conversion.js45
1 files changed, 45 insertions, 0 deletions
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 0000000000..74c6c007b0
--- /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 */