diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/console | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/console')
13 files changed, 335 insertions, 0 deletions
diff --git a/testing/web-platform/tests/console/META.yml b/testing/web-platform/tests/console/META.yml new file mode 100644 index 0000000000..60c95d0d57 --- /dev/null +++ b/testing/web-platform/tests/console/META.yml @@ -0,0 +1,5 @@ +spec: https://console.spec.whatwg.org/ +suggested_reviewers: + - domenic + - pwnall + - domfarolino diff --git a/testing/web-platform/tests/console/console-count-logging-manual.html b/testing/web-platform/tests/console/console-count-logging-manual.html new file mode 100644 index 0000000000..640729f1a2 --- /dev/null +++ b/testing/web-platform/tests/console/console-count-logging-manual.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> +<head> +<title>Console Count - Logging Manual Test</title> +<meta name="author" title="Dominic Farolino" href="mailto:domfarolino@gmail.com"> +<meta name="assert" content="Console count method default parameter should work"> +<link rel="help" href="https://console.spec.whatwg.org/#count"> +</head> +<body> +<p>Open the console inside the developer tools. It should contain four entries whose contents are:</p> +<p><code>default: 1</code></p> +<p><code>default: 2</code></p> +<p><code>default: 3</code></p> +<p><code>default: 4</code></p> + +<script> +console.count(); +console.count(undefined); +console.count("default"); +console.count({toString() {return "default"}}); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/console/console-countReset-logging-manual.html b/testing/web-platform/tests/console/console-countReset-logging-manual.html new file mode 100644 index 0000000000..7fe01f50ed --- /dev/null +++ b/testing/web-platform/tests/console/console-countReset-logging-manual.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html> +<head> +<title>Console Count Reset - Logging Manual Test</title> +<meta name="author" title="Dominic Farolino" href="mailto:domfarolino@gmail.com"> +<meta name="assert" content="Console countReset method"> +<link rel="help" href="https://console.spec.whatwg.org/#countreset"> +</head> +<body> +<p>Open the console inside the developer tools. It should contain entries whose contents are:</p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>default: 1</code></p> +<p><code>a label: 1</code></p> +<p><code>a label: 1</code></p> +<p style="color:grey;">[some warning message indicating that a count for label "b" does not exist]</p> + +<script> +console.count(); +console.countReset(); +console.count(); + +console.count(undefined); +console.countReset(undefined); +console.count(undefined); + +console.count("default"); +console.countReset("default"); +console.count("default"); + +console.count({toString() {return "default"}}); +console.countReset({toString() {return "default"}}); +console.count({toString() {return "default"}}); + +console.count("a label"); +console.countReset(); +console.count("a label"); + +console.countReset("b"); // should produce a warning +</script> +</body> +</html> diff --git a/testing/web-platform/tests/console/console-is-a-namespace.any.js b/testing/web-platform/tests/console/console-is-a-namespace.any.js new file mode 100644 index 0000000000..1756ba6bc1 --- /dev/null +++ b/testing/web-platform/tests/console/console-is-a-namespace.any.js @@ -0,0 +1,28 @@ +// META: global=window,dedicatedworker,shadowrealm +"use strict"; +// https://webidl.spec.whatwg.org/#es-namespaces +// https://console.spec.whatwg.org/#console-namespace + +test(() => { + assert_true(self.hasOwnProperty("console")); +}, "console exists on the global object"); + +test(() => { + const propDesc = Object.getOwnPropertyDescriptor(self, "console"); + assert_equals(propDesc.writable, true, "must be writable"); + assert_equals(propDesc.enumerable, false, "must not be enumerable"); + assert_equals(propDesc.configurable, true, "must be configurable"); + assert_equals(propDesc.value, console, "must have the right value"); +}, "console has the right property descriptors"); + +test(() => { + assert_false("Console" in self); +}, "Console (uppercase, as if it were an interface) must not exist"); + +test(() => { + const prototype1 = Object.getPrototypeOf(console); + const prototype2 = Object.getPrototypeOf(prototype1); + + assert_equals(Object.getOwnPropertyNames(prototype1).length, 0, "The [[Prototype]] must have no properties"); + assert_equals(prototype2, Object.prototype, "The [[Prototype]]'s [[Prototype]] must be %ObjectPrototype%"); +}, "The prototype chain must be correct"); diff --git a/testing/web-platform/tests/console/console-label-conversion.any.js b/testing/web-platform/tests/console/console-label-conversion.any.js new file mode 100644 index 0000000000..4d48df3b1d --- /dev/null +++ b/testing/web-platform/tests/console/console-label-conversion.any.js @@ -0,0 +1,29 @@ +"use strict"; +// 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_js(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`); +} diff --git a/testing/web-platform/tests/console/console-log-shadowrealm-manual.html b/testing/web-platform/tests/console/console-log-shadowrealm-manual.html new file mode 100644 index 0000000000..b091a850c0 --- /dev/null +++ b/testing/web-platform/tests/console/console-log-shadowrealm-manual.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<mete charset=utf-8> +<title>Console Logging Manual Test</title> +<p>Open the console inside the developer tools. It should contain one entry saying "test passed".</p> +<script> +const sr = new ShadowRealm(); +sr.evaluate(` + console.log("test passed"); +`); +</script> diff --git a/testing/web-platform/tests/console/console-namespace-object-class-string.any.js b/testing/web-platform/tests/console/console-namespace-object-class-string.any.js new file mode 100644 index 0000000000..d3ff7f7d07 --- /dev/null +++ b/testing/web-platform/tests/console/console-namespace-object-class-string.any.js @@ -0,0 +1,40 @@ +"use strict"; +// https://webidl.spec.whatwg.org/#es-namespaces +// https://console.spec.whatwg.org/#console-namespace + +test(() => { + assert_own_property(console, Symbol.toStringTag); + + const propDesc = Object.getOwnPropertyDescriptor(console, Symbol.toStringTag); + assert_equals(propDesc.value, "console", "value"); + assert_equals(propDesc.writable, false, "writable"); + assert_equals(propDesc.enumerable, false, "enumerable"); + assert_equals(propDesc.configurable, true, "configurable"); +}, "@@toStringTag exists on the namespace object with the appropriate descriptor"); + +test(() => { + assert_equals(console.toString(), "[object console]"); + assert_equals(Object.prototype.toString.call(console), "[object console]"); +}, "Object.prototype.toString applied to the namespace object"); + +test(t => { + assert_own_property(console, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); + t.add_cleanup(() => { + Object.defineProperty(console, Symbol.toStringTag, { value: "console" }); + }); + + Object.defineProperty(console, Symbol.toStringTag, { value: "Test" }); + assert_equals(console.toString(), "[object Test]"); + assert_equals(Object.prototype.toString.call(console), "[object Test]"); +}, "Object.prototype.toString applied after modifying the namespace object's @@toStringTag"); + +test(t => { + assert_own_property(console, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); + t.add_cleanup(() => { + Object.defineProperty(console, Symbol.toStringTag, { value: "console" }); + }); + + assert_true(delete console[Symbol.toStringTag]); + assert_equals(console.toString(), "[object Object]"); + assert_equals(Object.prototype.toString.call(console), "[object Object]"); +}, "Object.prototype.toString applied after deleting @@toStringTag"); diff --git a/testing/web-platform/tests/console/console-number-format-specifiers-symbol-manual.html b/testing/web-platform/tests/console/console-number-format-specifiers-symbol-manual.html new file mode 100644 index 0000000000..f77b84e515 --- /dev/null +++ b/testing/web-platform/tests/console/console-number-format-specifiers-symbol-manual.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html> +<head> +<title>Console Number Format Specifiers on Symbols</title> +<meta name="author" title="Dominic Farolino" href="mailto:domfarolino@gmail.com"> +<meta name="assert" content="Console format specifiers on Symbols"> +<link rel="help" href="https://console.spec.whatwg.org/#formatter"> +</head> +<body> +<p>Open the console inside the developer tools. It should contain 15 entries, each of which are:</p> +<p><code>NaN</code></p> + +<script> +const methods = ["log", "dirxml", "trace", "group", "groupCollapsed"]; + +for (method of methods) { + console[method]("%i", Symbol.for("description")); + if (method == "group" || method == "groupCollapsed") console.groupEnd(); + console[method]("%d", Symbol.for("description")); + if (method == "group" || method == "groupCollapsed") console.groupEnd(); + console[method]("%f", Symbol.for("description")); + if (method == "group" || method == "groupCollapsed") console.groupEnd(); +} +</script> +</body> +</html> diff --git a/testing/web-platform/tests/console/console-string-format-specifier-symbol-manual.html b/testing/web-platform/tests/console/console-string-format-specifier-symbol-manual.html new file mode 100644 index 0000000000..3a1b93f735 --- /dev/null +++ b/testing/web-platform/tests/console/console-string-format-specifier-symbol-manual.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> +<head> +<title>Console String Format Specifier on Symbols</title> +<meta name="author" title="Dominic Farolino" href="mailto:domfarolino@gmail.com"> +<meta name="assert" content="Console format specifiers on Symbols"> +<link rel="help" href="https://console.spec.whatwg.org/#formatter"> +</head> +<body> +<p>Open the console inside the developer tools. It should contain five entries, each of which are:</p> +<p><code>Symbol(description)</code></p> + +<script> +console.log("%s", Symbol.for("description")); +console.dirxml("%s", Symbol.for("description")); +console.trace("%s", Symbol.for("description")); +console.group("%s", Symbol.for("description")); +console.groupEnd(); +console.groupCollapsed("%s", Symbol.for("description")); +console.groupEnd(); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/console/console-tests-historical.any.js b/testing/web-platform/tests/console/console-tests-historical.any.js new file mode 100644 index 0000000000..1b18a9879f --- /dev/null +++ b/testing/web-platform/tests/console/console-tests-historical.any.js @@ -0,0 +1,20 @@ +// META: global=window,dedicatedworker,shadowrealm +/** + * 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"); diff --git a/testing/web-platform/tests/console/console-timing-logging-manual.html b/testing/web-platform/tests/console/console-timing-logging-manual.html new file mode 100644 index 0000000000..3b9e5cea21 --- /dev/null +++ b/testing/web-platform/tests/console/console-timing-logging-manual.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html> +<head> +<title>Console Timing Methods - Logging Manual Test</title> +<meta name="author" title="Dominic Farolino" href="mailto:domfarolino@gmail.com"> +<meta name="assert" content="Console timing methods"> +<link rel="help" href="https://console.spec.whatwg.org/#timing"> +</head> +<body> +<p>Open the console inside the developer tools. It should contain entries whose contents are:</p> +<p><code>default: <some time></code></p> +<p><code>default: <some time></code></p> + +<p><code>default: <some time></code></p> +<p><code>default: <some time> extra data</code></p> +<p><code>default: <some time></code></p> + +<p><code>default: <some time></code></p> +<p><code>default: <some time> extra data</code></p> +<p><code>default: <some time></code></p> + +<p><code>default: <some time></code></p> +<p><code>default: <some time> extra data</code></p> +<p><code>default: <some time></code></p> + +<p><code>custom toString(): <some time></code></p> +<p><code>custom toString(): <some time> extra data</code></p> +<p><code>custom toString(): <some time></code></p> + +<p><code>a label: <some time></code></p> +<p><code>a label: <some time> extra data</code></p> +<p><code>a label: <some time></code></p> + +<p style="color:grey;">[some warning message indicating that a timer for label "b" does not exist]</p> + +<script> +console.time(); +console.timeLog(); +console.timeEnd(); + +console.time(undefined); +console.timeLog(undefined); +console.timeLog(undefined, "extra data"); +console.timeEnd(undefined); + +console.time("default"); +console.timeLog("default"); +console.timeLog("default", "extra data"); +console.timeEnd("default"); + +console.time({toString() {return "default"}}); +console.timeLog({toString() {return "default"}}); +console.timeLog({toString() {return "default"}}, "extra data"); +console.timeEnd({toString() {return "default"}}); + +console.time({toString() {return "custom toString()"}}); +console.timeLog({toString() {return "custom toString()"}}); +console.timeLog({toString() {return "custom toString()"}}, "extra data"); +console.timeEnd({toString() {return "custom toString()"}}); + +console.time("a label"); +console.timeLog("a label"); +console.timeLog("a label", "extra data"); +console.timeEnd("a label"); + +console.timeLog("b"); // should produce a warning +console.timeEnd("b"); // should produce a warning +</script> +</body> +</html> diff --git a/testing/web-platform/tests/console/idlharness-shadowrealm.window.js b/testing/web-platform/tests/console/idlharness-shadowrealm.window.js new file mode 100644 index 0000000000..8f68252dcd --- /dev/null +++ b/testing/web-platform/tests/console/idlharness-shadowrealm.window.js @@ -0,0 +1,5 @@ +// META: script=/resources/idlharness-shadowrealm.js + +// https://console.spec.whatwg.org/ + +idl_test_shadowrealm(["console"], []); diff --git a/testing/web-platform/tests/console/idlharness.any.js b/testing/web-platform/tests/console/idlharness.any.js new file mode 100644 index 0000000000..1e7ba76ecd --- /dev/null +++ b/testing/web-platform/tests/console/idlharness.any.js @@ -0,0 +1,9 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +// https://console.spec.whatwg.org/ + +idl_test( + ['console'], + [] // no deps +); |