Skip to content

test(runtime): keep a hardened browser bundle runnable - #359

Open
DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:test/runtime-browser-consumer-contract
Open

DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:test/runtime-browser-consumer-contract

Conversation

@DeryFerd

@DeryFerd DeryFerd commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

The runtime shield is injected into browser bundles too, but no test executed a hardened browser bundle with browser globals only. browser-bundle.ts decides which JavaScript artifacts cannot host the Node integrity bindings, and runtime-shield.ts guards each process access with typeof process !== "undefined"; the guard was reviewed but never exercised as a consumer contract.

A regression there would not show up in the Node-based consumer tests because those provide process, require and module.

What changed

  • tests/runtime-browser-consumer-contract.test.ts hardens a small bundle that reads document.title and window.name, runs the output in node:vm with only those globals plus console, and asserts the original side effect.
  • The test also asserts that the runtime-shield marker is present, so the vm run actually covers the injected path rather than an untouched bundle.

Compatibility

Test only. No production code changes.

Verification

  • npx vitest run tests/runtime-browser-consumer-contract.test.ts passes.
  • npx tsc --noEmit is clean.

Execute a hardened browser bundle in a vm context with no process/require and assert its original side effect survives, so the guarded runtime-shield path is covered by a real consumer contract.
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