Closed Bug 692550 Opened 13 years ago Closed 13 years ago

console.log("%s", null); should log "null"

Categories

(DevTools :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 10

People

(Reporter: ted, Assigned: dchanm+bugzilla)

References

Details

(Whiteboard: [fixed-in-fx-team])

Attachments

(1 file, 1 obsolete file)

Currently console.log("%s", null); raises an error. It should just log "null".
I'm assuming we would also want this to work for undefined?

console.log("%s", undefined) -> "undefined"
Assignee: nobody → dchan+bugzilla
Attached patch convert arg to string (obsolete) — Splinter Review
This should work.

String(undefined) -> "undefined"
String(null) -> "null"
Attachment #565332 - Flags: feedback?
Comment on attachment 565332 [details] [diff] [review]
convert arg to string

Looks good. Thank you!

Please add a test so we won't cause regressions down the road.
Attachment #565332 - Flags: feedback? → feedback+
HUDService.jsm doesn't appear to be affected by this bug. I didn't see any reference to the format specifics in the code. Fixing ConsoleAPI.js also fixed the errors that were appearing in WebConsole "args.shift() is null".
Attachment #565332 - Attachment is obsolete: true
Attachment #565361 - Flags: review?(mihai.sucan)
(In reply to David Chan [:dchan] from comment #4)
> Created attachment 565361 [details] [diff] [review] [diff] [details] [review]
> added testcase
> 
> HUDService.jsm doesn't appear to be affected by this bug. I didn't see any
> reference to the format specifics in the code. Fixing ConsoleAPI.js also
> fixed the errors that were appearing in WebConsole "args.shift() is null".

That's right, parameter substitution is implemented completely in ConsoleAPI.js. This bug is really my fault from bug 614586, so thank you for fixing it!
Comment on attachment 565361 [details] [diff] [review]
[in-fx-team] added testcase

Thank you for your quick fix! Much appreciated.
Attachment #565361 - Flags: review?(mihai.sucan) → review+
Whiteboard: [land-in-fx-team]
Whiteboard: [land-in-fx-team] → [fixed-in-fx-team]
Comment on attachment 565361 [details] [diff] [review]
[in-fx-team] added testcase

https://hg.mozilla.org/integration/fx-team/rev/6c66a420067c

Thanks for the fix, David!
Attachment #565361 - Attachment description: added testcase → [in-fx-team] added testcase
https://hg.mozilla.org/mozilla-central/rev/6c66a420067c
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 10
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: