Open
Description
- Version: v12.13.1
- Platform: Windows 10
The in
operator does not work correctly when using a Proxy as a VM context.
var o = {};
var p = new Proxy(o, {
has(target, key) {
console.log('has', key);
return Reflect.has(target, key);
},
get(target, key, receiver) {
console.log('get', key);
return Reflect.get(target, key, receiver);
},
});
vm.createContext(p);
vm.runInContext(`this.abcInThis = 'abc' in this`, p);
console.log(JSON.stringify(o)); // Prints {"abcInThis":false}
In the above code, the expected output is:
has abc
{"abcInThis":false}
but the actual output is:
get abc
{"abcInThis":true}
If we remove the get(target, key, receiver)
function, the still incorrect output is:
{"abcInThis":false}