direct_proxies "problem"

David Bruant bruant.d at gmail.com
Wed Jan 9 02:24:41 PST 2013


Le 09/01/2013 06:57, Boris Zbarsky a écrit :
> And specifically, it's not clear what the behavior should be when 
> there are two different scripted proxies for the same WebIDL object.  
> Say it's a DOM node.  One of the proxies gets passed to appendChild.  
> When later getting that node out of the DOM with .firstChild, what 
> should be handed back?  The proxy that was passed in, the JS object 
> that proxy was wrapping, something else (e.g. an exception is thrown)?
The principle of least surprise would say the proxy that was passed in 
(at least for the sake of object identity checking). Proxies are 
supposed to be used as a replacement of their target.
Also if you wrap untrusted code in a membrane [1], you don't want this 
untrusted code to be handed the actual target, but the wrapped object 
(so the proxy).

Regardless of the answer for the specific point you bring up, there are 
hundreds of such questions to be answered before proxies can wrap 
browser objects. W3C specs are nowhere near being ready to explain what 
would happen if a proxy was passed as argument of a method.

Proxies expose the guts of algorithms applied on objects (exact sequence 
of internal methods with arguments). It is true for ECMAScript standard 
objects, it would be equally true for browser objects. Since these guts 
aren't specified in ECMAScript semantics, exposing the guts now would 
lead at best to non-interoperable behaviors, at worst to security issues 
(due to C++ proximity).


I agree with Andreas about the convenience for web developers [2] but I 
doubt it would be practical to have it in the short term both because of 
under-specification and implementation complexity.
Let's wait for a combinaison of 1) authors using proxies, 2) 
implementors move forward on WebIDL compliance and 3) proxies being 
introduced in the spec world (WindowProxy, live objects...). When these 
3 aspects will have moved forward enough, maybe it will be time to think 
about wrapping browser objects, but now, none of the 3 populations seem 
in a mature enough state for this to happen.

David

[1] http://soft.vub.ac.be/~tvcutsem/invokedynamic/js-membranes
[2] I regularly meet developers who aren't aware of the 
ECMAScript/Browser objects divide and call all that JavaScript.


More information about the es-discuss mailing list