Le 12/12/2012 22:30, Kevin Reid a écrit :
On Wed, Dec 12, 2012 at 1:23 PM, David Bruant <[email protected]
<mailto:[email protected]>> wrote:
Le 12/12/2012 21:42, Kevin Reid a écrit :
Exactly. So a user-defined switching proxy needs only to:
1. refuse to commit to any invariant (non-configurable property
or preventExtensions)
2. even if its switchable-target has an invariant, do not expose
that invariant (i.e. pretend each property is configurable)
Pretend that something non-configurable actually is configurable
is an invariant violation. To be more concrete:
* There is an webpage with an iframe
* The same window object is proxied by 2 WindowProxy instances.
One outside the iframe, one inside.
* Inside of the iframe, scripts can add a non-configurable
property "azerty" to their global.
* Outside the iframe, what happens when
Object.getOwnPropertyDescriptor(iframeWindow, 'azerty') is called?
You're suggesting that {configurable: true} is returned. The
problem is that on the actual Window instance, there is a
non-configurable property, so if the WindowProxy handler tries to
do that, an error will be thrown because of invariant checks.
The JS runtime won't know that the proxy has anything to do with the
actual Window instance. The Proxy's formal target will be just {};
This target, even if dummy, is the one that will be used for invariants
checks. You can't get away from this by design. This is one of the most
important part of the direct proxies design.
Even if you switch of fake target, the engine will still perform checks
on the dummy internal [[Target]].
I feel we're cycling in what we say and I feel I can't find the right
words to explain my point. One idea would be for you to implement a
target-switching proxy based on direct proxies (Firefox has them
natively or you can use Tom's shim [1]). I'm confident you'll understand
my point through this exercise.
David
[1] https://github.com/tvcutsem/harmony-reflect
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss