Object.getOwnPropertyDescriptor can return just about anything

Jason Orendorff jason.orendorff at gmail.com
Wed Apr 30 14:46:11 PDT 2014

On Wed, Apr 30, 2014 at 4:06 PM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> On May 1, 2014, at 2:50 AM, Jason Orendorff <jason.orendorff at gmail.com> wrote:
>> As specified, proxies can do this:
>>  js> Object.isFrozen(proxy)
>>  true
>>  js> Object.getOwnPropertyDescriptor(proxy).configurable
>>  true
> No, that is not the intent.

André got it right. Here is the proxy I had in mind:

    var proxy = new Proxy(Object.freeze({prop: undefined}), {
        ownKeys: function () {
            return ["prop"];
        getOwnPropertyDescriptor: function name() {
            let n = 0;
            return {get configurable() { return n++ > 0; }, enumerable: true};

Currently in SpiderMonkey:

    js> Object.isFrozen(proxy)
    js> Object.getOwnPropertyDescriptor(proxy, "prop").configurable
    false  // but only because we don't implement [[Origin]]

> Also note that Object.isFrozen is specified to operates at the level of the MOP operations and property descriptor records, not at the Object.getOwnPropertyDescriptor/descriptor object level. It never looks at the object that is passed through [[Origin]].


> It isn’t clear exactly what you intend by the above snippet (does proxy have a ‘getOwnPropertyDescriptorHandler’? did you really mean to use undefined as the property key?).

Oh. No to the latter. Sorry for the typo!

> In either case, if the object passes the criteria for isFrozen then then the con configurable attribute of the resulting descriptor (if the property exists) must be false and consistent with the target.

The only inconsistency here is that Object.getOwnPropertyDescriptor is
returning an [[Origin]] object which is then tricking the end user.


More information about the es-discuss mailing list