Skip to content

feat(script): register the WHATWG URL and text-encoding globals - #88

Closed
pathscale wants to merge 1 commit into
masterfrom
feat/whatwg-url-globals
Closed

pathscale wants to merge 1 commit into
masterfrom
feat/whatwg-url-globals

Conversation

@pathscale

Copy link
Copy Markdown
Owner

boa_runtime implements URL, TextEncoder and TextDecoder, and nothing registered them. Only Console was, so a page received a JavaScript engine with a console and no web platform around it.

The failure does not look like a missing global

@solidjs/router constructs a URL while its module is evaluating. So a router-based application does not break when you navigate — it throws before the first component renders. What you see is a blank page and one line in the log naming the entry chunk, which is why this survived so long.

Found while trying to run fleet sites under qa-inspect-host: none of them could boot.

The change

Registered per extension rather than through boa_runtime::register, which would also install its own setTimeout/setInterval over the ones in timers.rs that are wired to this document's event loop.

Tests

Four, in packages/blitz-script/tests/whatwg_url.rs. Each reads a parsed field rather than checking that a constructor exists, because a constructor that exists and returns a bare object would satisfy the weaker test:

  • component parsing, including a non-default port and a fragment
  • relative resolution against a base (../c against /a/b/d), the half a naive stub gets wrong
  • an invalid URL throws, asserted by error name — new URL("/x") throws whether the constructor is missing or the string is bad, so "it threw" alone would pass against no URL at all
  • TextEncoder round-trips a non-ASCII character, where a byte-per-char stub diverges

With the registration removed, three of the four fail.

Still missing

This does not finish the job. URLSearchParams is absent and boa_runtime's own URL.searchParams throws "not implemented", so a router still cannot boot. Also absent, measured by probe page: matchMedia, fetch/Headers/Request/Response, MutationObserver, ResizeObserver, IntersectionObserver, AbortController, DOMParser, Blob, FormData, localStorage, sessionStorage; document.getElementsByTagName, createTreeWalker, createRange, adoptNode, evaluate; and insertAdjacentHTML, attachShadow, scrollIntoView, animate on elements.

URLSearchParams is the next blocker and belongs in the ps-boa fork rather than here.

`boa_runtime` implements `URL`, `TextEncoder` and `TextDecoder`, and nothing
registered them. Only `Console` was, so a page received a JavaScript engine
with a console and no web platform around it.

The failure this came from does not look like a missing global. `@solidjs/router`
constructs a `URL` during module evaluation, so a router-based application does
not break when you navigate: it throws before the first component renders. What
you see is a blank page and one line in the log naming the entry chunk, which
is why this survived so long.

Registered per extension rather than through `boa_runtime::register`, which
would also install its own `setTimeout`/`setInterval` over the ones in
`timers.rs` that are wired to this document's event loop.

`URLSearchParams` is still missing, and `URL.searchParams` still throws
"not implemented" from `boa_runtime` itself. Both need fixing upstream in the
fork rather than papered over here.
@pathscale

Copy link
Copy Markdown
Owner Author

Folded into #89. The commit is cherry-picked there and its four tests pass on that branch. One branch for the series means one 0.4.x release rather than two.

@pathscale pathscale closed this Sep 8, 2026
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