Open
Conversation
jedel1043
reviewed
Mar 23, 2026
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); |
Member
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
Author
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.