A DOM use case that can't be emulated with direct proxies

David Bruant bruant.d at gmail.com
Wed Dec 12 13:23:04 PST 2012

Le 12/12/2012 21:42, Kevin Reid a écrit :
> On Wed, Dec 12, 2012 at 12:35 PM, David Bruant <bruant.d at gmail.com 
> <mailto:bruant.d at gmail.com>> wrote:
>     I was a bit too strong in my statement, sorry. Let me rephrase:
>     the internal [[Target]] can't be changed, but a proxy can emulate
>     changing of "fake" target as long as what happens with this "fake"
>     target doesn't involve invariant checking.
>     That's the reason I was suggesting that WindowProxies could (maybe
>     depending on how the object reference was obtained) throw whenever
>     invariant checks are involved.
> 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.

I think throwing is the correct behavior here. The handler can't tell 
the truth about non-configurable properties (because a later different 
target may not have the same non-configurable properties), but also 
can't lie, because lies involves throwing... well, since I say that 
throwing is the correct behavior, I guess lying is too in a way.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121212/4418b7aa/attachment.html>

More information about the es-discuss mailing list