Closed
Bug 1200551
Opened 9 years ago
Closed 9 years ago
console.log() formatted output applies only the second specified style when %c%c is part of the string
Categories
(DevTools :: General, defect, P2)
DevTools
General
Tracking
(firefox43 fixed)
VERIFIED
FIXED
Firefox 43
Tracking | Status | |
---|---|---|
firefox43 | --- | fixed |
People
(Reporter: pascalc, Assigned: bgrins)
Details
(Whiteboard: [polish-backlog])
Attachments
(5 files)
The output of Monolog (de facto standard library for PHP development) to the browser is styled incorrectly in Firefox integrated devtools while it is styled correctly in Chrome, Firebug or Safari. I am attaching to this bug a reduced testcase exposing the incorrect formatting in our devtools. This same testcase is also online there: http://dev.pascalc.net/console_log_output/example.html Here is the output of Firefox devtools: http://dev.pascalc.net/console_log_output/firefox_console_output.png Here is the output of Chrome: http://dev.pascalc.net/console_log_output/chrome_console_output.png Here is the output of Firebug: http://dev.pascalc.net/console_log_output/firebug_console_output.png I do not have Safari but a colleague told me that the output of their devtools is the same as Chrome and Firebug on this testcase. I can reproduce this bug both on the release channel (42) and on Nightly.
Reporter | ||
Comment 1•9 years ago
|
||
Reporter | ||
Comment 2•9 years ago
|
||
Reporter | ||
Comment 3•9 years ago
|
||
Reporter | ||
Updated•9 years ago
|
Attachment #8655347 -
Attachment description: example.html → Testcase exposing the bug
Comment 4•9 years ago
|
||
Pascal - excellent bug report, thank you! Brian: good next bug for someone?
Flags: needinfo?(bgrinstead)
Priority: -- → P2
Whiteboard: [polish-backlog]
Assignee | ||
Comment 5•9 years ago
|
||
The issue seems to be with two %c strings next to each other. For instance, I believe it styles as expected if I change: From "%c%cgeneral%c %cINFO%c Information message sent to the console" To "%c %cgeneral%c %cINFO%c Information message sent to the console" i.e. console.log( "%c %cgeneral%c %cINFO%c Information message sent to the console", "font-weight: normal", "font-weight: bold", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal" );
Assignee | ||
Comment 6•9 years ago
|
||
Simple test case: console.log("%c%chi", "color: green", "background: red") Should have both a green color and red background but in Firefox it only has green color. At least, I'm guessing that's what it should be doing - this behavior is poorly specced, but we may as well match what other tools are doing.
Assignee | ||
Updated•9 years ago
|
Summary: console.log() formatted output in Firefox devtools is styled incorrectly → console.log() formatted output applies only the second specified style when %c%c is part of the string
Assignee | ||
Comment 7•9 years ago
|
||
The 'styles' packet coming from the server only includes the last one in this case. Which points it to probably being an issue with Console.cpp parsing out the string
Assignee | ||
Comment 8•9 years ago
|
||
I'm pretty sure I tracked down the issue
Assignee: nobody → bgrinstead
Status: NEW → ASSIGNED
Flags: needinfo?(bgrinstead)
Assignee | ||
Comment 9•9 years ago
|
||
Bug 1200551 - Handle multiple %c formatters without a string between them by using only the last one for styling;r=bz,r=past
Attachment #8659358 -
Flags: review?(past)
Attachment #8659358 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 10•9 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #9) > Created attachment 8659358 [details] > MozReview Request: Bug 1200551 - Handle multiple %c formatters without a > string between them by using only the last one for styling;r=bz,r=past > > Bug 1200551 - Handle multiple %c formatters without a string between them by > using only the last one for styling;r=bz,r=past Unfortunately there isn't a spec that I know of for %c handling, but based on what other devtools are doing and what some tools generate (see Comment 0), I think this is the de facto right way to handle the case of: console.log("%c%chi", "color: green", "background: red") <-- Should be `background: red` but we currently show it as `color: green` I've added a test in the patch that handles a variety of %c cases and makes sure it's parsed out as expected
Comment 11•9 years ago
|
||
Comment on attachment 8659358 [details] MozReview Request: Bug 1200551 - Handle multiple %c formatters without a string between them by using only the last one for styling;r=bz,r=past Andrea knows this code much better than I do...
Attachment #8659358 -
Flags: review?(bzbarsky) → review?(amarchesini)
Comment 12•9 years ago
|
||
Comment on attachment 8659358 [details] MozReview Request: Bug 1200551 - Handle multiple %c formatters without a string between them by using only the last one for styling;r=bz,r=past https://reviewboard.mozilla.org/r/18793/#review16823
Attachment #8659358 -
Flags: review?(amarchesini) → review+
Comment 13•9 years ago
|
||
Comment on attachment 8659358 [details] MozReview Request: Bug 1200551 - Handle multiple %c formatters without a string between them by using only the last one for styling;r=bz,r=past https://reviewboard.mozilla.org/r/18793/#review16889 Yeah, let's go with the flow. If you feel ike it, a PR against https://github.com/DeveloperToolsWG/console-object/blob/master/api.md#format-specifiers to explicitly mention this case would be useful.
Attachment #8659358 -
Flags: review?(past) → review+
Assignee | ||
Comment 15•9 years ago
|
||
(In reply to Panos Astithas [:past] from comment #13) > Comment on attachment 8659358 [details] > MozReview Request: Bug 1200551 - Handle multiple %c formatters without a > string between them by using only the last one for styling;r=bz,r=past > > https://reviewboard.mozilla.org/r/18793/#review16889 > > Yeah, let's go with the flow. If you feel ike it, a PR against > https://github.com/DeveloperToolsWG/console-object/blob/master/api.md#format- > specifiers to explicitly mention this case would be useful. Alright, I'll do that
Flags: needinfo?(bgrinstead)
Comment 16•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/ea0f3fa6453f
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox43:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 43
Reporter | ||
Comment 17•9 years ago
|
||
Thanks guys, I confirm that it works now correctly in today's nightly :)
Updated•9 years ago
|
Status: RESOLVED → VERIFIED
Assignee | ||
Comment 18•9 years ago
|
||
Submitted a PR to the console-object repo: https://github.com/DeveloperToolsWG/console-object/pull/34
Flags: needinfo?(bgrinstead)
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•