Exporting ES tests to a webpage environment?

Tom Van Cutsem tomvc.be at gmail.com
Thu Aug 4 13:38:36 UTC 2016

Hi Alex,

Unfortunately I can't give you any advice on how to customize the test
suites you referred to, but I can confirm that it is indeed no accident
that the Reflect and ProxyHandler APIs are alike. They were designed such
that a proxy handler trap can easily perform the "default behavior" of the
intercepted operation, by calling the Reflect method with the same name,
passing along the same arguments. Indeed, the "double lifting" trick [1]
crucially depends on this consistency.


[1] https://gist.github.com/tvcutsem/6536442

2016-07-27 19:20 GMT+02:00 Alex Vincent <ajvincent at gmail.com>:

> I'm wondering how I could test a custom implementation of a ECMAScript
> standard API in a web browser, against existing test suites that might not
> run in a browser.
> <background tldr="true">
> I've been re-exploring implementing a Membrane, which Tom van Cutsem
> introduced to me through blogs and this mailing list a few years ago.
> (Thanks, Tom!)  So at the moment, I'm working on implementing my own module
> code based on the latest published and approved standards, which are
> slightly different than what Tom had to work with.
> Along the way, I happily discovered the Reflect object's API matches the
> ProxyHandler's API.  That can't be by accident. I suspect SpiderMonkey's
> Reflect implementation is probably very close to the standard, given the
> usual high quality of their work and good number of tests they have in
> their codebase. [1]  That, plus the TC39 tests, [2] give me confidence that
> the native Reflect implementation I use in a Firefox-derived application
> will be quite good.  Combined with WeakMap, it should make a basic Membrane
> implementation relatively easy.
> With that said, I think I will run into complications when I try to
> introduce other ideas, such as hiding properties.  So I may have to write a
> custom Reflect implementation.  That implementation will in some cases just
> call the native Reflect API.  But in other cases I suspect I will need a
> little more detailed information, like "Which object in the prototype chain
> actually implements that named property?"
> Plus, I will probably have some debug-logging to do, as Firefox's debugger
> doesn't like to step through proxy handler code.  (I have to look for an
> existing bug on that, or file one.  It's easy to reproduce.)
> </background>
> The good news is, I suspect I can run a custom Reflect against existing
> code, loaded in a webpage, by wrapping it in function(Reflect) { ... }.
> The bad news is, neither test suite linked above makes it obvious how to do
> so.  That's what I'm looking for advice on.
> Alex Vincent
> Hayward, CA, U.S.A.
> [1] https://dxr.mozilla.org/mozilla-esr45/source/js/src/
> tests/ecma_6/Reflect
> [2] https://github.com/tc39/test262/tree/master/test/built-ins/Reflect
> --
> "The first step in confirming there is a bug in someone else's work is
> confirming there are no bugs in your own."
> -- Alexander J. Vincent, June 30, 2001
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160804/2eb9aa0f/attachment.html>

More information about the es-discuss mailing list