Object.getOwnPropertyDescriptor can return just about anything

Jason Orendorff jason.orendorff at gmail.com
Tue Apr 29 15:43:04 PDT 2014

The [[Origin]] field of Property Descriptor Records is not yet
implemented in Firefox. Eric Faust is looking at implementing it.[1]
We noticed two interesting cases:

1. Suppose handler.getOwnPropertyDescriptor returns ({value: 0}). Then
9.5.5 Proxy.[[GetOwnProperty]] calls
CompletePropertyDescriptor, and all the fields of the Property
Descriptor Record are populated. But the object itself is not
populated. This means Object.getOwnPropertyDescriptor will return an
object that is missing most of the fields the caller wants to know
about. This seems strange.

2. The object returned by the handler can have getters. It can answer
ToPropertyDescriptor's queries one way, and then say something else
afterwards, making it look like language invariants have been broken.

Come to think of it, [[GetOwnProperty]] is a weird API. It computes
two results: a set of Property Descriptor fields, and an [[Origin]]
object. The ES language itself relies exclusively on the former.
Scripts are only allowed to see the latter. That seems really weird to

What is an example of a concrete use case for this [[Origin]] feature?
Is it to avoid allocating a new object here?


    [1] https://bugzilla.mozilla.org/show_bug.cgi?id=999156

More information about the es-discuss mailing list