Last Comment Bug 692550 - console.log("%s", null); should log "null"
: console.log("%s", null); should log "null"
Status: RESOLVED FIXED
[fixed-in-fx-team]
:
Product: Firefox
Classification: Client Software
Component: Developer Tools (show other bugs)
: unspecified
: All All
: -- normal (vote)
: Firefox 10
Assigned To: David Chan [:dchan]
:
: J. Ryan Stinnett [:jryans] (use ni?)
Mentors:
: 704014 715077 720462 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-06 12:24 PDT by Ted Mielczarek [:ted.mielczarek]
Modified: 2012-01-25 15:31 PST (History)
7 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
convert arg to string (801 bytes, patch)
2011-10-06 13:16 PDT, David Chan [:dchan]
mihai.sucan: feedback+
Details | Diff | Splinter Review
[in-fx-team] added testcase (1.56 KB, patch)
2011-10-06 14:37 PDT, David Chan [:dchan]
mihai.sucan: review+
Details | Diff | Splinter Review

Description User image Ted Mielczarek [:ted.mielczarek] 2011-10-06 12:24:50 PDT
Currently console.log("%s", null); raises an error. It should just log "null".
Comment 1 User image David Chan [:dchan] 2011-10-06 13:00:29 PDT
I'm assuming we would also want this to work for undefined?

console.log("%s", undefined) -> "undefined"
Comment 2 User image David Chan [:dchan] 2011-10-06 13:16:06 PDT
Created attachment 565332 [details] [diff] [review]
convert arg to string

This should work.

String(undefined) -> "undefined"
String(null) -> "null"
Comment 3 User image Mihai Sucan [:msucan] 2011-10-06 13:22:48 PDT
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.
Comment 4 User image David Chan [:dchan] 2011-10-06 14:37:39 PDT
Created attachment 565361 [details] [diff] [review]
[in-fx-team] 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".
Comment 5 User image Panos Astithas [:past] 2011-10-06 23:57:48 PDT
(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 6 User image Mihai Sucan [:msucan] 2011-10-07 02:44:44 PDT
Comment on attachment 565361 [details] [diff] [review]
[in-fx-team] added testcase

Thank you for your quick fix! Much appreciated.
Comment 7 User image Rob Campbell [:rc] (:robcee) 2011-10-07 05:31:06 PDT
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!
Comment 8 User image Rob Campbell [:rc] (:robcee) 2011-10-11 12:55:35 PDT
https://hg.mozilla.org/mozilla-central/rev/6c66a420067c
Comment 9 User image Mardeg 2011-12-23 03:17:37 PST
*** Bug 704014 has been marked as a duplicate of this bug. ***
Comment 10 User image Panos Astithas [:past] 2012-01-04 06:57:30 PST
*** Bug 715077 has been marked as a duplicate of this bug. ***
Comment 11 User image Paul Libbrecht 2012-01-25 15:31:42 PST
*** Bug 720462 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.