Bug 33946 - Object.getOwnPropertyDescriptor always returns undefined for JS API objects
Summary: Object.getOwnPropertyDescriptor always returns undefined for JS API objects
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Kent Hansen
URL:
Keywords:
Depends on:
Blocks: 33947
  Show dependency treegraph
 
Reported: 2010-01-21 06:22 PST by Kent Hansen
Modified: 2010-01-21 12:46 PST (History)
1 user (show)

See Also:


Attachments
Proposed patch (6.43 KB, patch)
2010-01-21 08:38 PST, Kent Hansen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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

Nice.

r=me
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.