Bug 16498

Summary: ''.constructor.toString() gives [function]
Product: WebKit Reporter: Christopher Schmidt <crschmidt>
Component: JavaScriptCoreAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal Keywords: HasReduction
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.4   
URL: http://crschmidt.net/projects/webkit/tostring.html
Attachments:
Description Flags
patch oliver: review+

Description Christopher Schmidt 2007-12-17 20:53:10 PST
''.constructor.toString() gives back "[function]" in Safari. In FF and Opera (and I believe IE) this returns:

>>> ''.constructor.toString()
function String() { [native code] }

or something similar.

(Test.AnotherWay uses this as a way to determine what type of object something is for some reason I'm not sure I understand, which is how I bumped into it.)
Comment 1 David Kilzer (:ddkilzer) 2007-12-18 05:49:57 PST
Confirmed difference to Firefox and Opera with a local debug build of WebKit r28774 with Safari 3.0.4 (523.12) on Mac OS X 10.4.11 (8S165).

Is the format of the returned string for native functions covered by any spec?

Comment 2 Eric Seidel (no email) 2008-01-01 12:32:30 PST
If this is still an issue, it's easy enough to fix.  We just need a good test case (w/o an alert, DRT compatible).  Ideally one which uses the standard fast/js/ style of just being a .js file and using shouldBe, etc.
Comment 3 Darin Adler 2008-01-26 08:48:22 PST
functionProtoFuncToString already has a case that dumps in this format, with "native code" in the string. We just need to trigger it at the right time.
Comment 4 Darin Adler 2008-01-26 10:02:30 PST
Created attachment 18709 [details]
patch
Comment 5 Darin Adler 2008-01-27 00:57:54 PST
Committed revision 29817.