"Proxy handler's getOwnPropertyDescriptor trap violates invariant: cannot return undefined for a property on the target which is a non-configurable property"
);
});
test("cannot return undefined for an existing property if the target is non-extensible",()=>{
"Proxy handler's getOwnPropertyDescriptor trap violates invariant: cannot report a property as being undefined if it exists as an own property of the target and the target is non-extensible"
"Proxy handler's getOwnPropertyDescriptor trap violates invariant: invalid property descriptor for existing property on the target"
);
expect(()=>{
Object.getOwnPropertyDescriptor(
newProxy(o,{
getOwnPropertyDescriptor(){
return{enumerable:false};
},
}),
"v2"
);
}).toThrowWithMessage(
TypeError,
"Proxy handler's getOwnPropertyDescriptor trap violates invariant: invalid property descriptor for existing property on the target"
);
expect(()=>{
Object.getOwnPropertyDescriptor(
newProxy(o,{
getOwnPropertyDescriptor(){
return{value:10};
},
}),
"v3"
);
}).toThrowWithMessage(
TypeError,
"Proxy handler's getOwnPropertyDescriptor trap violates invariant: invalid property descriptor for existing property on the target"
);
expect(()=>{
Object.getOwnPropertyDescriptor(
newProxy(o,{
getOwnPropertyDescriptor(){
return{value:10,writable:true};
},
}),
"v4"
);
}).toThrowWithMessage(
TypeError,
"Proxy handler's getOwnPropertyDescriptor trap violates invariant: invalid property descriptor for existing property on the target"
);
});
test("cannot report a property as non-configurable if it does not exist or is non-configurable",()=>{
leto={};
Object.defineProperty(o,"v",{configurable:true});
expect(()=>{
Object.getOwnPropertyDescriptor(
newProxy(o,{
getOwnPropertyDescriptor(){
return{configurable:false};
},
}),
"v"
);
}).toThrowWithMessage(
TypeError,
"Proxy handler's getOwnPropertyDescriptor trap violates invariant: cannot report target's property as non-configurable if the property does not exist, or if it is configurable"