Here is another test case, with [[GetOwnPropertyDescriptor]]:

```js
var target = Object.seal({x: 2});
var proxy = new Proxy(target, {
    getOwnPropertyDescriptor(o, p) {
        var d = Reflect.getOwnPropertyDescriptor(o, p)
        if (d && 'writable' in d)
            d.writable = false
        return d
    }
});

Object.getOwnPropertyDescriptor(proxy, 'x'); // { value: 2, writable: false, 
configurable: false }

Object.defineProperty(proxy, 'x', { value: 3 })

Object.getOwnPropertyDescriptor(proxy, 'x'); // { value: 3, writable: false, 
configurable: false }
```

IMHO, the most robust fix is the following: Both the [[DefineOwnProperty]] and 
the [[GetOwnPropertyDescriptor]] contain the following check:

* If IsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc) 
is false, throw a TypeError exception.

I think there should be also the following check (except when targetDesc is 
undefined, in which case another appropriate check is used):

* If IsCompatiblePropertyDescriptor(extensibleTarget, targetDesc, resultDesc) 
is false, throw a TypeError exception.

That would replace the weaker adhoc check about the [[Configurable]] attribute 
(search for settingConfigFalse) in those algorithms.

(Alternatively, in order to avoid double checks, define an 
AreBothWaysCompatiblePropertyDescriptors(extensibleTarget, desc1, desc2) 
abstract operation.)

—Claude

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to