Conversation
core/runtime/src/test262.rs
Outdated
| let clock = START | ||
| .get() | ||
| .ok_or_else(|| JsNativeError::typ().with_message("could not get the monotonic clock"))?; | ||
| let clock = START.get_or_init(Instant::now); |
There was a problem hiding this comment.
I don't think this is correct. This will always return 0 or something close to 0 for the first call to monotonic_now, which could fail some tests that assume some amount of time already passed
There was a problem hiding this comment.
Thanks, I think you're right -- looking at the spec for DOMHighResTimeStamp, it does suggest to use worker/binary's start time as the time origin.
I moved initialization of START to the beginning of register_js262() (diff) and tested:
$ ./target/release/boa --test262-object -e '$262.agent.sleep(100); print($262.agent.monotonicNow());'
100
undefined(before it printed 0 as clock got initialized on first use)
test262 tests aren't affected, no regressions either way.
Test262 conformance changes
Broken tests (185):New panics (2):Tested main commit: |
Move `$262` implementation from `tests/tester/src/exec/js262.rs` to `core/runtime/src/test262.rs` behind a new `test262` feature gate (pulls `bus` as optional dep). Add `annex-b` feature to boa_runtime forwarding to `boa_engine/annex-b` for `$262.IsHTMLDDA`. Both cli and boa_tester now use `boa_runtime/test262`, removing the tester's direct `bus` and `boa_gc` deps. CLI registers `$262` when `--test262-object` flag is passed. This change makes CLI more suitable for running test262 via an external harness such as eshost + test262-harness. The exact same `$262` object as used by the internal boa_tester can now be directly accessed in CLI. Existing `$boa` object doesn't expose some of the methods (like IsHTMLDDA, detachArrayBuffer and agent helpers) needed for full test262 support, and would have required users to maintain a custom shim mapping it to `$262`. Fixes boa-dev#5054
test262 tests use print() to signal async completion and errors. The tester has its own print() implementation to catch reported errors, but CLI should just print them, so let's alias it to console.log().
Treat files with .mjs extension as modules without requiring --module flag. Many other JavaScript shells do the same - d8, jsc, graaljs, xs, escargot. A small quality-of-life improvement that among other things simplifies configuration for an external test262 harness. The harness could simply stage module tests into *.mjs and forget about --module flag.
Make boa's cli consistent with the behaviour of other major JavaScript shells (d8, jsc, spidermonkey at least) as well as boa_tester by enabling [[CanBlock]] by default. Add --no-can-block flag to opt out, same as V8 (https://github.com/v8/v8/blob/main/src/d8/d8.cc#L6417). Needed for Atomics tests to pass when using an external test262 harness.
|
Fixed lint errors in lib.rs / test262.rs and rebased. |
This Pull Request fixes/closes #5054
It changes the following:
tests/tester/src/exec/js262.rstocore/runtime/src/test262.rsso it can be reused by both cli and boa_tester--test262-objectflag to CLIprint()to CLI with--test262-object[[CanBlock]]by default in CLI to match boa_tester as well as d8/jsc/sm shells default behavior--no-can-blockflag to CLI to support Atomics CanBlockIsFalse tests (same flag name as d8 has)These changes make it possible to reproduce boa_tester's test262 results using external test262 harnesses with boa cli binary.