Skip to content

js: upstream the browser page driver (#59's browser half) - #71

Merged
lann merged 1 commit into
mainfrom
browser-driver-glue
Aug 7, 2026
Merged

js: upstream the browser page driver (#59's browser half)#71
lann merged 1 commit into
mainfrom
browser-driver-glue

Conversation

@lann

@lann lann commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

The remaining half of #59. The thrice-copied browser-leg machinery (webcrypto scripts/browser-page-driver.mjs + worker pool, websocket run-browser.mjs, webrtc run-browser.mjs) moves upstream as three pieces:

  • ./browser-driver (node-only): runPageHarness — the webcrypto primitive generalized with a routes hook (webrtc's mailbox reverse-proxy shape) and a package self-mount (/__component-test) so pages and workers reach the harness core without each repo's import.meta.resolve path math; buildHarnessPage (import map + embedded config + page-runner bootstrap); componentTestImportMap; findChrome (the CHROME_PATH → system → Playwright-cache ladder). The caller passes its own playwright-core, as before.
  • js/viewer/page-runner.mjs (browser-safe): the in-page per-suite worker-pool loop with suite-order restoration and heartbeats.
  • js/viewer/browser-worker.mjs (browser-safe): the generic shard worker — cores by URL (module workers cannot see import maps), the consumer's import object via its own suiteImports(env) module, optional Context override, fresh instance per case.
  • resolveTestsExport relocates to the harness (browser-safe; the worker needs it, and three consumers kept inline copies while it was node-only). ./node-runner re-exports it, so js: upstream the node suite-runner loop (#59's node half) #70 adopters are unaffected.

Per-consumer residue, deliberately: SUT imports module, env/config, proxy routes, pool sizing, results frame.

Verification: unit tests for the page builder / self-mount map / Chrome-ladder env override (in verify-imports), syntax checks on the in-page halves, verify-node goldens + viewer selftest for the harness relocation. The integration gate is the first consumer: polymorph-tls#32 (jco-browser targets), which follows immediately and is the seam test this design was deferred for.

Three consumers carry near-identical copies of the browser leg's
machinery: a static server over the repository root, an import map
for this package's bare specifiers, a Playwright engine launch with
the Gecko JSPI pref, heartbeat-based stall detection, the
Chrome-binary ladder, an in-page worker pool, and a shard worker
compiling cores and running the case loop. The skeleton moves
upstream:

- ./browser-driver (node-only): runPageHarness — the webcrypto
  primitive, generalized with a routes hook (reverse proxies, health
  checks) and a package self-mount at /__component-test so pages and
  workers reach the harness core without per-repo path math —
  buildHarnessPage, componentTestImportMap, and findChrome.
- js/viewer/page-runner.mjs (browser-safe): the in-page pool loop —
  per-suite worker pools, suite-order restoration, heartbeats, one
  results payload per suite.
- js/viewer/browser-worker.mjs (browser-safe): the generic shard
  worker; module workers cannot see import maps, so every module
  reference arrives as a URL, and the consumer's import object comes
  from its own module's suiteImports(env).
- resolveTestsExport moves to the harness (it is pure logic the
  browser worker needs; three consumers kept inline copies because it
  shipped node-only) — node-runner re-exports it.

What stays per-consumer: the SUT imports module, env/config, proxy
routes, pool sizing, and the results frame.

Unit tests cover the page builder, the self-mount map, and the Chrome
ladder's env override; the in-page halves are syntax-checked here and
integration-gated by the consumers' browser legs.
@lann
lann merged commit dd2c989 into main Aug 7, 2026
3 checks passed
@lann
lann deleted the browser-driver-glue branch August 7, 2026 21:39
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