Skip to content

Conversation

@matthargett
Copy link

@matthargett matthargett commented Oct 12, 2025

Pulled from @vmoroz 's awesome hermes-windows work that is being upstreamed into Hermes, this pull request runs his now-portable test suite here in JsRuntimeHost. It actually found one bug so far!

The bug was JSC-specific: our JavaScriptCore wrapper previously passed nullptr to JSObjectCallAsFunction when the receiver was undefined, so the VM forcibly substituted the global object even in strict mode. The new implementation always routes through Function.prototype.call, preserving the exact thisArg.

New tests run on macOS and Android simulator. We can add it into the Azure pipelines in a separate PR, unless you all would prefer otherwise.

Note:

  1. Right now, there is no good way to package up the test suite, this is something Vlad, myself, and other collaborators have been discussing with the broader NodeJS community. Feels a little gross to duplicate the files, but we're giving another consumer use case that the packaging choices can be cross-checked against. yay community!

  2. We now have a safety net make bumping NAPI_VERSION to 6 (and beyond) to drive parity and congruence with hermes-windows (and React Native [Windows] itself). Our (rbckr.co) app will need these expanded NAPI capabilities so that we can run the code currently running in web workers in our BabylonJS WebXR app in separate JS domains/worklets that communicate with the main BabylonJS thread.

…ction when the receiver was undefined, so the VM forcibly substituted the global object even in strict mode. The new implementation always routes through Function.prototype.call, preserving the exact thisArg. This only affected JSC: Chakra already pushes recv onto the argv array before invoking JsCallFunction, and V8 hands the raw recv value to Function::Call. Neither engine coerces in strict mode, so no additional fixes were required.
…bug fix in strict mode was actually found by the suite! The failing behavior was exercised by Tests/NodeApi/test/js-native-api/3_callbacks/test.js. New cmake targets emit a node-lite binary and a NodeApiTests binary, all currently enabled tests for currently supported NAPI v5 pass on Mac. Next step is to enable them for running in Android simulator.
@matthargett matthargett changed the title Add N-API compliant tests Add N-API compliance tests Oct 12, 2025
…x handles during instrumentation, causing crashes, and now route console output through the new NodeLiteRuntime::Callbacks. On Android we forward stdout/stderr to logcat via callbacks to work around this for now. Added Android-specific shims (node_lite_android.cpp, child_process_android.cpp) so native module loading uses dlopen and JS child_process.spawnSync safely reports “unsupported”. Extended the Node‑API harness to allow in-process execution: RunNodeLiteScript captures output, SetNodeApiTestEnvironment lets the JNI layer provide a base directory and asset manager, and the GTest registration path uses that configuration instead of shelling out to the node_lite executable
…-- a use-after-free. Will check sanitizers under Android next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant