script: Support sprintf-style substitutions in console methods#43897
Conversation
Signed-off-by: Kelechi Ebiri <ebiritg@gmail.com>
|
🔨 Triggering try run (#23944429964) for Linux (WPT) |
|
Test results for linux-wpt from try job (#23944429964): Flaky unexpected result (26)
Stable unexpected results that are known to be intermittent (17)
|
|
✨ Try run (#23944429964) succeeded. |
| Some('c') => { | ||
| chars.next(); | ||
| if arg_index < messages.len() { | ||
| arg_index += 1; // consume but ignore CSS styling |
There was a problem hiding this comment.
"css styling"? Why can we ignore the argument in this case?
There was a problem hiding this comment.
"css styling"? Why can we ignore the argument in this case?
In https://console.spec.whatwg.org/#formatter, the behaviour is not yet specified but the argument is used for styling console output in other browers and I don't think Servo supports styled console output at the moment.
There was a problem hiding this comment.
Thanks, I had naively assumed that %c would format a char like it does in C (:
simonwuelker
left a comment
There was a problem hiding this comment.
LGTM, can you write a test?
You can test console functionality with the devtools tests in devtools_tests.py, there are already some other console tests that you can use as a reference.
| Some('d') | Some('i') => { | ||
| let spec = chars.next().unwrap(); | ||
| if arg_index < messages.len() { | ||
| let num = unsafe { ToNumber(*cx, messages[arg_index]) }; |
There was a problem hiding this comment.
Does this throw if the value is a BigInt/Symbol like https://tc39.es/ecma262/#sec-tonumber? If so we need some if checks to avoid that.
I see, I'll give it a try |
…ormatter Signed-off-by: Kelechi Ebiri <ebiritg@gmail.com>
| if num.is_err() { | ||
| unsafe { jsapi::JS_ClearPendingException(*cx) }; | ||
| } |
There was a problem hiding this comment.
Rather than clearing the exception I'd prefer if we didn't call ToNumber at all in those error cases.
There was a problem hiding this comment.
Well, gecko has https://searchfox.org/firefox-main/rev/0989a082704f0bda8d370ccd57402645d834757e/dom/console/Console.cpp#1332 too so I guess it's fine.
|
@simonwuelker is this good enough to land? |
Implement the Console Formatter operation for all console methods.
Fixes: #43827