console.log(message) doesn't show leading whitespace in message



8 years ago
10 months ago


(Reporter: ianbicking, Assigned: past)


Firefox 7

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [fixed-in-devtools])


(1 attachment, 2 obsolete attachments)



8 years ago
I sometimes want to do:

  console.log('Some stuff:');
  console.log('  example:', foo);
  console.log('  also:', foo2);

But the leading whitespace is not displayed.  I wouldn't put those spaces there if I didn't want them to be there ;)

Comment 1

8 years ago
IMHO, I think this is an extreme edge case. Most people won't care.
Posted patch Patch v1 (obsolete) — Splinter Review
This has been bugging me as well, so I cooked up this patch that seems to fix it. It breaks lots of tests though that need fixing as well. Mihai do you have any less invasive ideas?
Assignee: nobody → past
Attachment #540050 - Flags: feedback?(mihai.sucan)

Comment 3

8 years ago
In my opinion, preserving spaces in the debug console is the right thing to do. Easily formatted debug strings can make output more useful and palatable. Sure, it's not really important, but I can't think of any down side.

Along the lines of Panos's patch, would it be easier just to change

    aBody = aBody instanceof Ci.nsIDOMNode ?
            aBody : aDocument.createTextNode(aBody);


    aBody = aBody instanceof Ci.nsIDOMNode ?
            aBody : aDocument.createTextNode(aBody.replace(/ /g, "\xa0"));

In my inexperience, I have no idea how this would affect any tests.
Comment on attachment 540050 [details] [diff] [review]
Patch v1

There must be a styling-based approach. Maybe:

Try white-space: pre-wrap to see if it works.
Attachment #540050 - Flags: feedback?(mihai.sucan)
Posted patch Patch v2Splinter Review
Bingo! Works as advertised, thanks!
Attachment #540050 - Attachment is obsolete: true
Attachment #540440 - Flags: review?(mihai.sucan)
Comment on attachment 540440 [details] [diff] [review]
Patch v2

Great to see it works!
Attachment #540440 - Flags: review?(mihai.sucan) → review+
Comment on attachment 540440 [details] [diff] [review]
Patch v2

Thanks Mihai! Requesting peer review from dao.
Attachment #540440 - Flags: review?(dao)
It's somewhat arguable whether that kind of rule belongs in the theme. Does the webConsole have a content stylesheet?
Comment on attachment 540440 [details] [diff] [review]
Patch v2

This belongs in content CSS. Unfortunately, the webconsole is mingled in the browser window's DOM rather than being a separate iframe.
Attachment #540440 - Flags: review?(dao) → review-
Posted patch Patch v3 (obsolete) — Splinter Review
I wasn't aware of the distinction, thanks. I guess that browser.css is the proper place, then?
Attachment #540440 - Attachment is obsolete: true
Attachment #540707 - Flags: review?(
Well, no, ideally there would be a webConsole.css somewhere in toolkit/components/console/, and ideally that stylesheet would be loaded in an iframe rather than browser.xul.
Comment on attachment 540707 [details] [diff] [review]
Patch v3

Indeed, this isn't really the proper place, but there are several things about the current web console code that aren't "proper". You could add a note to bug 635359, and also reference it in a comment here, but maybe it'd be cleaner to just add it to the theme for now and fix everything in bug 635359 (rather than expanding the set of things that need cleaning up to include browser.css).
Attachment #540707 - Flags: review?( → review?(dao)
Comment on attachment 540440 [details] [diff] [review]
Patch v2

I'm still waiting for cleanup from the early days of the "heads up display" :/
Attachment #540440 - Attachment is obsolete: false
Attachment #540440 - Flags: review- → review+
Attachment #540707 - Attachment is obsolete: true
Attachment #540707 - Flags: review?(dao)
Thank you both. I added a comment to bug 635359 referencing comment 11 here.
Whiteboard: [land-in-devtools]
Whiteboard: [land-in-devtools] → [fixed-in-devtools]
backed out to try to clear some orange:

should be able to reland.
Whiteboard: [fixed-in-devtools] → [backed-out][land-in-devtools]
Last Resolved: 8 years ago
Resolution: --- → FIXED
Whiteboard: [backed-out][land-in-devtools] → [fixed-in-devtools]
Target Milestone: --- → Firefox 7

Comment 18

8 years ago
Mozilla/5.0 (X11; Linux i686; rv:7.0a1) Gecko/20110627 Firefox/7.0a1

Verified issue on Ubuntu 11.04, Mac OS X 10.6, WinXP, Win7 using the steps to reproduce from Comment 0.

Setting status to Verified Fixed.


10 months ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.