Bug 7924 - Cant create inline function using "new Function()" syntax
Summary: Cant create inline function using "new Function()" syntax
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Macintosh OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-22 18:18 PST by Parag Shah
Modified: 2008-02-22 17:26 PST (History)
2 users (show)

See Also:


Attachments
Testcase exposing bug in question (1.40 KB, text/html)
2006-03-22 18:20 PST, Parag Shah
no flags Details
Test ReadOnly attribute (611 bytes, text/html)
2007-10-13 16:25 PDT, Garrett Smith
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Parag Shah 2006-03-22 18:18:59 PST
See attached (siimplified) testcase for example.

Basically, Safari chokes when trying to assign a new inline function to a variable using "new Function()".

The attached testcase creates a dummy object and then attempts to create a "proxy" object or copy of that object by assigning the prototype of the proxied object to the original object (its simpler than it sounds).

The workaround is to make the assignment using "function() {}" instead.

I.e., this does not work:
var proxyCtor = new Function();

This does work:
var proxyCtor = function() {};

Both cases work in IEv6 and FFv1.5 (both on win and Mac).
Comment 1 Parag Shah 2006-03-22 18:20:29 PST
Created attachment 7243 [details]
Testcase exposing bug in question

Clicking on the link should alert "doit" twice. Safari only alerts once :(
Comment 2 Garrett Smith 2007-10-13 16:25:14 PDT
Created attachment 16654 [details]
Test ReadOnly attribute

FIXED.


The function instance was given a prototype property.

with Function() and new Function(), this property was incorrectly flagged ReadOnly.

This has been fixed in Webkit.
Comment 3 David Kilzer (:ddkilzer) 2008-02-22 17:26:23 PST
Both test cases work for me with a local debug build of Webkit r30458.