Bug 54337 - JS: console.log.apply() broken, throws TypeError
Summary: JS: console.log.apply() broken, throws TypeError
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.6
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-12 01:31 PST by Richard Connamacher
Modified: 2011-02-12 14:02 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Connamacher 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.
Comment 1 Alexey Proskuryakov 2011-02-12 13:25:45 PST
This is probably a duplicate of bug 20141, although it doesn't look exactly the same.
Comment 2 Richard Connamacher 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".