Most current Proxy-as-implemented test suite?

David Bruant bruant.d at gmail.com
Wed May 1 14:17:17 PDT 2013


Le 01/05/2013 22:26, Kevin Reid a écrit :
> In Caja we have several uses for Proxies, some of which involve
> reimplementing or modifying the Proxy API.
Out of curiosity, how are you modifying it? for which use case?

> We are currently following
> the original harmony:proxies (rather than direct or notification
> proxies) since that's what is available in browsers.
Firefox implements and shipped direct proxies as part of Firefox 18 [1]. 
At this occasion, I moved the old proxy design MDN documentation in its 
own page [2].
Last I heard, V8 was waiting on the spec to stabilize before moving 
forward on implementation [3].

The API on the table for now is direct proxies. Notification proxies are 
being discussed but haven't met consensus yet (are there news on this 
front, TC39ers?).
If anything, I would recommend to move away from the initial proxy 
design for Caja, because the harmony:proxies API is meant to never see 
light in the spec (and should probably be removed from Firefox). Among 
other things, harmony:proxies would have requires to ~double the memory 
to check ES5 invariants regarding non-extensibility and 
non-configurability. Direct proxies make the check on the target (and 
make the forwarding proxy first-class which enables optimizations that 
probably couldn't have been possible in the previous design). 
Notification proxies guarantee the invariants by design, but force a 
slightly different programming style.

Tom Van Cutsem wrote a direct proxies shim that runs on top of current 
browser implementations [4]. If you want to move to direct proxies, it 
might be something to consider.

> What is the most current test suite available for this variant of proxies?  So far I have found <http://hg.ecmascript.org/tests/harmony/>, which seems to be a more
> recent version of what we are currently using, but has it been
> superseded by something else?
I have started an unofficial test suite for direct proxies [4][5]. It's 
incomplete, but if you want to move to direct proxies, that would be a 
good start I guess. Review the tests before fully trusting them, so far 
it's been only me working on that.

David

[1] 
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Proxy
[2] https://developer.mozilla.org/en-US/docs/JavaScript/Old_Proxy_API
[3] http://code.google.com/p/v8/issues/detail?id=1543#c28
[4] https://github.com/tvcutsem/harmony-reflect/blob/master/reflect.js
[5] https://github.com/DavidBruant/ProxyTests
[6] http://davidbruant.github.io/ProxyTests/


More information about the es-discuss mailing list