Description
- Version: master
- Platform: all
- Subsystem: vm
This is a case of "I understand why it acts this way but it still feels weird." Maybe we could put this in the documentation, but filing it here so it's recorded somewhere at least.
> vm.runInNewContext('this', new Proxy({}, {})).Object
[Function: Object]
> vm.runInNewContext('this', new Proxy({}, { get: Reflect.get })).Object
undefined
One might expect them to both return the Object
function.
This is probably because of the fact that VM checks whether or not the sandbox object has the requested property. In the first case, it can just check the target object, since V8 knows nothing funny is going on with [[Get]]. In the second, even though Reflect.get
should act the same way as not specifying a trap, V8 doesn't know that, since unlike [[GetOwnProperty]]/getOwnPropertyDescriptor
[[Get]]/get
has no way of differentiating between an undefined
-valued property and a nonexistent property.
Code-wise,
Lines 1064 to 1116 in 35c01d8
after being initialized to true, was_found
can only be set to false if the get
trap is undefined, and prototype lookup for the Proxy target reveals nothing with that property name.