near-membrane icon indicating copy to clipboard operation
near-membrane copied to clipboard

Proxy traps to handle `Object` and `Reflect` APIs consistently.

Open jdalton opened this issue 5 years ago • 4 comments

Throwing errors is appropriate for Object methods like Object.defineProperty when run in strict mode code. However, Reflect.defineProperty should return false without throwing an error. The proxy traps need to be constructed in a way to handle this. To solve this in esm I did two things.

Since we own the secure realm though we can monkey-patch Reflect to avoid throwing and return booleans.

jdalton avatar Oct 21 '19 22:10 jdalton

@jdalton do you think is there anything missing here?

caridy avatar Jan 22 '20 17:01 caridy

I'll check and report/back close as necessary.

Update:

Ok, so it's still an issue. I'll look into it.

Update:

We can fix this with a Reflect distortion.

jdalton avatar Jan 22 '20 17:01 jdalton

@jdalton but Reflect does not go through the membrane because it is an intrinsic. Can you elaborate more on the issue?

caridy avatar Jan 22 '20 19:01 caridy

Right now because of our proxy traps for defineProperty, set, deleteProperty some Reflect method calls for Reflect.deleteProperty, Reflect.defineProperty, Reflect.set will throw instead of returning false. The distortion would be to catch the error about to be thrown in the reflect method and check to make sure it should else return false.

jdalton avatar Jan 24 '20 20:01 jdalton