Exporting ES tests to a webpage environment?
Alex Vincent
ajvincent at gmail.com
Wed Jul 27 17:20:23 UTC 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160727/4580d5aa/attachment.html>
More information about the es-discuss
mailing list