andreubotella / deno_test262 Goto Github PK
View Code? Open in Web Editor NEWA runner for Test262, the ECMAScript test suite, in Deno.
License: MIT License
A runner for Test262, the ECMAScript test suite, in Deno.
License: MIT License
$262
is a host-defined object that must exist as a property of the global object in test262 tests, and which allows it to test a number of things in the TC39 specification that can't be merely triggered from JS alone:
$262.createRealm()
. Not currently implementable because Deno doesn't support realms.$262.detachArrayBuffer()
. #28$262.evalScript()
. #22$262.gc()
$262.global
$262.IsHTMLDDA
. Not implementable because Deno doesn't support the DOM or document.all
.$262.agent.start()
. #30$262.agent.broadcast()
. #55$262.agent.getReport()
$262.agent.sleep()
$262.agent.monotonicNow()
Test262's $262.agent
APIs deal with running code in a different agent, in order to test SharedArrayBuffer
, Atomics
and similar APIs. In Deno the only way to have multiple agents is with workers.
The $262.agent.start()
function must start an agent and block until the script passed as the first parameter is running in the agent. The only way to block until the worker is running is by sending a SharedArrayBuffer
with worker.postMessage()
and using Atomics.wait()
to block on it โ with the worker only running the code in the message
event listener, after unblocking and notifying the main thread.
Since the global object inside agents created with $262.agent.start()
must also be modified before the code can run (see #31), it would seem like the best solution for both things is to have an agent-setup.js
file that serves as the workers' main module, and which sets up the global object and listens for the message
event. The code to run in the agent is then passed as part of the first message, along with the SharedArrayBuffer
.
The built-ins/Object/defineProperties/15.2.3.7-2-18.js
test fails with:
Test262Error {
message: 'Expected TypeError, got ReferenceError: Access to "location", run again with --location <href>.'
}
This is because the test runs Object.defineProperties(obj, this)
, where this
is the global object, and Object.defineProperties()
gets all of the second argument's properties, including globalThis.location
, which throws when getting if the --location
argument isn't passed.
This can't be worked around by deleting globalThis.location
in the test runner because globalThis.location
is non-configurable (due to the LegacyUnforgeable
WebIDL attribute). The only way to work around this seems to be to set the --location
flag to a dummy URL, like http://example.com
Transferring ArrayBuffer
objects was enabled in denoland/deno#11840, and it will land on Deno 1.14. This will allow detaching ArrayBuffer
s, which will let us implement this host-defined function required by test262.
Here's an example of detaching an ArrayBuffer
in the current Deno canary:
> let buffer = new ArrayBuffer(1024);
undefined
> structuredClone(undefined, {transfer: [buffer]})
undefined
> new Uint8Array(buffer)
Uncaught TypeError: Cannot perform Construct on a detached ArrayBuffer
at new Uint8Array (<anonymous>)
at <anonymous>:2:1
And the corresponding agent function $262.agent.receiveBroadcast()
.
Inside an agent created with $262.agent.start()
, there is a $262.agent
object, but its properties are different functions from those in the main agent's $262.agent
:
$262.agent.receiveBroadcast()
. Counterpart to the main agent's $262.agent.broadcast()
. #55$262.agent.report()
. Counterpart to the main agent's $262.agent.getReport()
.$262.agent.sleep()
. Same as the main agent's $262.agent.sleep()
.$262.agent.leaving()
$262.agent.monotonicNow()
. Same as the main agent's $262.agent.monotonicNow()
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.