The Invariants of the Essential Methods are false in case of reentrancy

Claude Pache claude.pache at gmail.com
Wed Aug 10 15:51:53 UTC 2016


Test case:

```js
var results = []

var observe = function (method, object, ...args) {
    results.push({
        method: method
      , object: object
      , args: args
      , output: Reflect[method](object, ...args)
    })
}

var obj = { get x() { 
    Object.defineProperty(this, 'x', { value: 2, configurable: false, writable: false })
    observe('getOwnPropertyDescriptor', this, 'x')
    return 1
} }

observe('get', obj, 'x')

results[0]
// { method: "getOwnPropertyDescriptor", object: obj, args: [ "x" ], output: { value: 2, writable: false, enumerable: true, configurable: false } }
// `obj` is observed to have a nonconfigurable, nonwritable property "x" with value `2`.

results[1] // { method: "get", object: obj, args: [ "x" ], output: 1 }
// Then, `obj.[[Get]]("x") is observed to return `1`.
```

Not sure if it is worrisome. What is sure, the situation could become worse with fanciful proxies.

―Claude


More information about the es-discuss mailing list