Bug 54337

Summary: JS: console.log.apply() broken, throws TypeError
Product: WebKit Reporter: Richard Connamacher <richardconnamacher>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: ap, ggaren, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.6   

Richard Connamacher
Reported 2011-02-12 01:31:00 PST
I created a wrapper function "log()" to check if console.log exists before sending messages to it; this allows my code to run without errors on IE and Firefox (when Firebug is disabled). The function passes its arguments on to console.log() by converting the 'arguments' object to an array and calling: console.log.apply(this, argsArray); On Firefox with Firebug installed this works as intended. In WebKit, however, it raises a TypeError with the unhelpful text description "type error". Reproducing this bug is easy. Just open a JavaScript console and enter: console.log.apply(this, ["Hello World"]); This bug effects console.log.call as well. Replacing 'this' with any other value yields the same result.
Attachments
Alexey Proskuryakov
Comment 1 2011-02-12 13:25:45 PST
This is probably a duplicate of bug 20141, although it doesn't look exactly the same.
Richard Connamacher
Comment 2 2011-02-12 14:02:12 PST
(In reply to comment #1) > This is probably a duplicate of bug 20141, although it doesn't look exactly the same. It does look like a duplicate, though on further testing I learned that the bug itself is invalid. The code does work in Firefox, but the code itself had a problem. I marked it "RESOLVED INVALID".
Note You need to log in before you can comment on or make changes to this bug.