Bug 33946

Summary: Object.getOwnPropertyDescriptor always returns undefined for JS API objects
Product: WebKit Reporter: Kent Hansen <kent.hansen>
Component: JavaScriptCoreAssignee: Kent Hansen <kent.hansen>
Severity: Normal CC: commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Bug Depends on:    
Bug Blocks: 33947    
Description Flags
Proposed patch none

Description Kent Hansen 2010-01-21 06:22:19 PST
When Object.getOwnPropertyDescriptor is passed an object that was created using the C API JSObjectMake() function, it doesn't return a valid property descriptor, even if the property is defined in the JSClass.
Comment 1 Kent Hansen 2010-01-21 08:38:37 PST
Created attachment 47125 [details]
Proposed patch

Implements the approach suggested by Geoffrey in https://bugs.webkit.org/show_bug.cgi?id=33603#c11.
Descriptors always have enumerable=false, even though that might not be true. It's no worse than before, since Object.prototype.propertyIsEnumerable would also return false (since it calls getOwnPropertyDescriptor(), which wasn't implemented). Like I mention in a comment, it can be made more consistent by calling getPropertyNames and checking if the name is in the result, but I've opted not to add that overhead unless it's requested.
In a full-blown solution (using access descriptors), the implementation would extract the attributes from the JSStaticValues/JSStaticFunctions if possible, but it doesn't look like the functionality can be completely supported without introducing a new callback in JSClassDefinition (i.e., to get attributes of non-static properties).
Comment 2 Geoffrey Garen 2010-01-21 09:44:40 PST
Comment on attachment 47125 [details]
Proposed patch


Comment 3 WebKit Commit Bot 2010-01-21 12:46:09 PST
Comment on attachment 47125 [details]
Proposed patch

Clearing flags on attachment: 47125

Committed r53638: <http://trac.webkit.org/changeset/53638>
Comment 4 WebKit Commit Bot 2010-01-21 12:46:13 PST
All reviewed patches have been landed.  Closing bug.