Make console methods take any instead of string (#31241)

* Make console methods use `any` for the message

Match the Console spec by allowing any value to be passed to console
methods, instead of just values that can be converted to a string.

Signed-off-by: syvb <me@iter.ca>

* Add test for console logging a Symbol

Signed-off-by: syvb <me@iter.ca>

* Implement object stringification for logs

Signed-off-by: syvb <me@iter.ca>

* Address review comments

Signed-off-by: syvb <me@iter.ca>

* Make time/timeEnd accept DOMString to match spec

* Update WPT results for layout 2013

---------

Signed-off-by: syvb <me@iter.ca>
This commit is contained in:
Smitty 2024-02-05 09:30:53 -05:00 committed by GitHub
parent 4758ffabca
commit 50c930866b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 545 additions and 40 deletions

View file

@ -3,6 +3,8 @@ skip: true
skip: false
[_webgl]
skip: false
[console]
skip: false
[cookies]
skip: false
[samesite]

View file

@ -0,0 +1,11 @@
[console-is-a-namespace.any.shadowrealm.html]
expected: ERROR
[console-is-a-namespace.any.html]
[The prototype chain must be correct]
expected: FAIL
[console-is-a-namespace.any.worker.html]
[The prototype chain must be correct]
expected: FAIL

View file

@ -0,0 +1,38 @@
[console-label-conversion.any.html]
[console.count()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.count() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.countReset()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.countReset() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.timeLog()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.timeLog() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console-label-conversion.any.worker.html]
[console.count()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.count() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.countReset()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.countReset() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.timeLog()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.timeLog() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL

View file

@ -0,0 +1,6 @@
[console-log-symbol.any.html]
[console-log-symbol.any.shadowrealm.html]
expected: ERROR
[console-log-symbol.any.worker.html]

View file

@ -0,0 +1,26 @@
[console-namespace-object-class-string.any.worker.html]
[@@toStringTag exists on the namespace object with the appropriate descriptor]
expected: FAIL
[Object.prototype.toString applied to the namespace object]
expected: FAIL
[Object.prototype.toString applied after modifying the namespace object's @@toStringTag]
expected: FAIL
[Object.prototype.toString applied after deleting @@toStringTag]
expected: FAIL
[console-namespace-object-class-string.any.html]
[@@toStringTag exists on the namespace object with the appropriate descriptor]
expected: FAIL
[Object.prototype.toString applied to the namespace object]
expected: FAIL
[Object.prototype.toString applied after modifying the namespace object's @@toStringTag]
expected: FAIL
[Object.prototype.toString applied after deleting @@toStringTag]
expected: FAIL

View file

@ -0,0 +1,6 @@
[console-tests-historical.any.worker.html]
[console-tests-historical.any.shadowrealm.html]
expected: ERROR
[console-tests-historical.any.html]

View file

@ -0,0 +1,2 @@
[idlharness-shadowrealm.window.html]
expected: ERROR

View file

@ -0,0 +1,68 @@
[idlharness.any.worker.html]
[console namespace: [[Prototype\]\] is Object.prototype]
expected: FAIL
[console namespace: operation assert(optional boolean, any...)]
expected: FAIL
[console namespace: operation table(optional any, optional sequence<DOMString>)]
expected: FAIL
[console namespace: operation trace(any...)]
expected: FAIL
[console namespace: operation dir(optional any, optional object?)]
expected: FAIL
[console namespace: operation dirxml(any...)]
expected: FAIL
[console namespace: operation count(optional DOMString)]
expected: FAIL
[console namespace: operation countReset(optional DOMString)]
expected: FAIL
[console namespace: operation time(optional DOMString)]
expected: FAIL
[console namespace: operation timeLog(optional DOMString, any...)]
expected: FAIL
[console namespace: operation timeEnd(optional DOMString)]
expected: FAIL
[idlharness.any.html]
[console namespace: [[Prototype\]\] is Object.prototype]
expected: FAIL
[console namespace: operation assert(optional boolean, any...)]
expected: FAIL
[console namespace: operation table(optional any, optional sequence<DOMString>)]
expected: FAIL
[console namespace: operation trace(any...)]
expected: FAIL
[console namespace: operation dir(optional any, optional object?)]
expected: FAIL
[console namespace: operation dirxml(any...)]
expected: FAIL
[console namespace: operation count(optional DOMString)]
expected: FAIL
[console namespace: operation countReset(optional DOMString)]
expected: FAIL
[console namespace: operation time(optional DOMString)]
expected: FAIL
[console namespace: operation timeLog(optional DOMString, any...)]
expected: FAIL
[console namespace: operation timeEnd(optional DOMString)]
expected: FAIL

View file

@ -517775,6 +517775,42 @@
{}
]
],
"console-log-symbol.any.js": [
"a2facb6c64e86428383260735ed2df3e88c2c809",
[
"console/console-log-symbol.any.html",
{
"script_metadata": [
[
"global",
"window,dedicatedworker,shadowrealm"
]
]
}
],
[
"console/console-log-symbol.any.shadowrealm.html",
{
"script_metadata": [
[
"global",
"window,dedicatedworker,shadowrealm"
]
]
}
],
[
"console/console-log-symbol.any.worker.html",
{
"script_metadata": [
[
"global",
"window,dedicatedworker,shadowrealm"
]
]
}
]
],
"console-namespace-object-class-string.any.js": [
"d3ff7f7d07636154080f4d24106e1a6703c37dc4",
[

View file

@ -0,0 +1,12 @@
[console-is-a-namespace.any.worker.html]
[The prototype chain must be correct]
expected: FAIL
[console-is-a-namespace.any.html]
[The prototype chain must be correct]
expected: FAIL
[console-is-a-namespace.any.shadowrealm.html]
expected: ERROR

View file

@ -0,0 +1,38 @@
[console-label-conversion.any.html]
[console.count()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.count() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.countReset()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.countReset() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.timeLog()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.timeLog() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console-label-conversion.any.worker.html]
[console.count()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.count() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.countReset()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.countReset() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL
[console.timeLog()'s label gets converted to string via label.toString() when label is an object]
expected: FAIL
[console.timeLog() throws exceptions generated by erroneous label.toString() conversion]
expected: FAIL

View file

@ -0,0 +1,6 @@
[console-log-symbol.any.shadowrealm.html]
expected: ERROR
[console-log-symbol.any.html]
[console-log-symbol.any.worker.html]

View file

@ -0,0 +1,26 @@
[console-namespace-object-class-string.any.html]
[@@toStringTag exists on the namespace object with the appropriate descriptor]
expected: FAIL
[Object.prototype.toString applied to the namespace object]
expected: FAIL
[Object.prototype.toString applied after modifying the namespace object's @@toStringTag]
expected: FAIL
[Object.prototype.toString applied after deleting @@toStringTag]
expected: FAIL
[console-namespace-object-class-string.any.worker.html]
[@@toStringTag exists on the namespace object with the appropriate descriptor]
expected: FAIL
[Object.prototype.toString applied to the namespace object]
expected: FAIL
[Object.prototype.toString applied after modifying the namespace object's @@toStringTag]
expected: FAIL
[Object.prototype.toString applied after deleting @@toStringTag]
expected: FAIL

View file

@ -0,0 +1,6 @@
[console-tests-historical.any.worker.html]
[console-tests-historical.any.shadowrealm.html]
expected: ERROR
[console-tests-historical.any.html]

View file

@ -0,0 +1,2 @@
[idlharness-shadowrealm.window.html]
expected: ERROR

View file

@ -0,0 +1,68 @@
[idlharness.any.html]
[console namespace: [[Prototype\]\] is Object.prototype]
expected: FAIL
[console namespace: operation assert(optional boolean, any...)]
expected: FAIL
[console namespace: operation table(optional any, optional sequence<DOMString>)]
expected: FAIL
[console namespace: operation trace(any...)]
expected: FAIL
[console namespace: operation dir(optional any, optional object?)]
expected: FAIL
[console namespace: operation dirxml(any...)]
expected: FAIL
[console namespace: operation count(optional DOMString)]
expected: FAIL
[console namespace: operation countReset(optional DOMString)]
expected: FAIL
[console namespace: operation time(optional DOMString)]
expected: FAIL
[console namespace: operation timeLog(optional DOMString, any...)]
expected: FAIL
[console namespace: operation timeEnd(optional DOMString)]
expected: FAIL
[idlharness.any.worker.html]
[console namespace: [[Prototype\]\] is Object.prototype]
expected: FAIL
[console namespace: operation assert(optional boolean, any...)]
expected: FAIL
[console namespace: operation table(optional any, optional sequence<DOMString>)]
expected: FAIL
[console namespace: operation trace(any...)]
expected: FAIL
[console namespace: operation dir(optional any, optional object?)]
expected: FAIL
[console namespace: operation dirxml(any...)]
expected: FAIL
[console namespace: operation count(optional DOMString)]
expected: FAIL
[console namespace: operation countReset(optional DOMString)]
expected: FAIL
[console namespace: operation time(optional DOMString)]
expected: FAIL
[console namespace: operation timeLog(optional DOMString, any...)]
expected: FAIL
[console namespace: operation timeEnd(optional DOMString)]
expected: FAIL

View file

@ -0,0 +1,10 @@
// META: global=window,dedicatedworker,shadowrealm
"use strict";
// https://console.spec.whatwg.org/
test(() => {
console.log(Symbol());
console.log(Symbol("abc"));
console.log(Symbol.for("def"));
console.log(Symbol.isConcatSpreadable);
}, "Logging a symbol doesn't throw");