# web + ai spec polyfill testbed

- Status: `experiment`
- Track: [crawler visibility, model cutoffs & quality evals](https://aifoc.us/labs/platform-observability/)
- Layer: 8. Crawler Visibility, Model Cutoffs & Quality Evals
- Updated: 1 December 2026
- Live demo: https://spec-polyfill-browser.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/spec-polyfill-browser

## Inspired by

- [webmcp is the new web intents ... maybe](https://aifoc.us/webmcp-is-the-new-web-intents/)
- [embedding is the web's composability superpower](https://aifoc.us/embedding/)
- [the browser is the sandbox](https://aifoc.us/the-browser-is-the-sandbox/)

## Why this matters

Draft browser standards like [`navigator.modelContext`](https://webmachinelearning.github.io/webmcp/) (WebMCP), isolated `<web-island>` elements, and [`Connection-Allowlist`](https://wicg.github.io/connection-allowlists) read cleanly in markdown explainers, but API ergonomics, schema validation edge cases, and security boundaries remain hidden until teams execute concrete conformance checks in a real browser.

## What this opens up

Testing draft browser specs early before engines ship native implementations. The testbed separates Native Browser Pass vs. Polyfill Pass scores, times polyfill overhead via [`PerformanceObserver`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver), and demonstrates the exact boundary where JavaScript shims cannot emulate browser-engine isolation.

## How the tests work

1. Click **Run Conformance Suite** to run all 15 assertions (5 per spec) and compare Native Browser Pass counts against Polyfill Pass counts.
2. Click **Register & Execute Tool** (or edit the tool name, query, and `<web-island capabilities>` fields) to test JSON-Schema validation, `AbortSignal` cleanup, and `ElementInternals` form participation live.
3. Test RFC 9651 fail-closed header parsing (`()`, malformed strings, `response-origin`) beside the live `GET /probe/connection-allowlist` edge iframe.
4. Run the two **What Polyfills Cannot Fake** probes (`<link rel="prefetch">` egress bypass and Shadow DOM vs. opaque `<iframe>`) and inspect `PerformanceObserver` marks in the Wire Inspector.


## Hypothesis

- **Claim:** Running executable 15-assertion conformance suites across draft Web + AI proposals (`navigator.modelContext`, `<web-island>` + `ElementInternals`, and `Connection-Allowlist`) with explicit Native vs. Polyfill score splits surfaces naming conflicts and engine-only security boundaries far earlier than reading explainer docs.
- **Confirms it:** All 15 assertions run reproducibly with `PerformanceObserver` mark/measure timing, report accurate Native vs. Polyfill score splits without miscounting shims as native, and verify live HTTP `Connection-Allowlist: (); report-to=allowlist` headers.
- **Bounds or disproves it:** The `<link rel="prefetch">` and Shadow DOM vs. opaque `<iframe>` probes prove that JavaScript shims cannot block declarative browser prefetching, pre-connect handshakes, or cross-origin paint/DOM boundaries without native engine hooks.


## Under the hood

[Spec Polyfill Testbed](https://spec-polyfill-browser.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/spec-polyfill-browser)) splits its modular polyfills across `public/lib/model-context.js`, `public/lib/web-island.js`, `public/lib/egress-guard.js`, and `public/lib/conformance-runner.js`. Every polyfill marks itself with `isPolyfill` so the conformance runner never mistakes a JavaScript shim for native engine support, outputting independent **Native Browser Pass** and **Polyfill Pass** totals.

On the edge, `src/worker.ts` serves `/api/specs`, `/island-frame` (a sandboxed `connect-src 'none'` iframe document), `/probe/connection-allowlist` (emitting `Connection-Allowlist: (); report-to=allowlist` and `Reporting-Endpoints`), `/api/egress-report` (with a streaming byte cap), and `/api/prefetch-canary` so the `<link rel="prefetch">` probe proves whether a declarative browser request still reached the origin despite JavaScript `guardedFetch()` enforcement.


## Key terms & further reading

- [WebMCP (navigator.modelContext)](https://webmachinelearning.github.io/webmcp/) — A draft browser API allowing web pages to register structured, schema-validated tools that agents can invoke directly.
- [Custom Elements & ElementInternals](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) — Standard DOM primitives letting custom elements participate in native form submission, constraint validation, and ARIA roles.
- [Connection-Allowlist header](https://wicg.github.io/connection-allowlists) — A proposed HTTP header enforcing which network origins a document may contact at the browser networking layer, failing closed on `()` or syntax errors.
- [RFC 9651 Structured Fields](https://www.rfc-editor.org/rfc/rfc9651.html) — The strict syntax specification for HTTP header inner lists and parameters used by `Connection-Allowlist`.
- [PerformanceObserver marks & measures](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver) — A browser timing API recording sub-millisecond durations for polyfill setup, schema validation, and policy checks.
- [Speculative prefetch (<link rel="prefetch">)](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel/prefetch) — A declarative browser fetch that bypasses JavaScript `fetch()` wrappers, exposing where only native engine enforcement holds.

## Open questions to iterate on

- Which polyfill assertions fail ONLY because of missing engine hooks (such as pre-connect allowlists or cross-origin intrinsic sizing)?
- Can this testbed generate WPT-shaped conformance cases cleanly as drafts stabilize?

## Iteration log

- **2026-12-01:** Shipped 15-assertion interactive polyfill suite across WebMCP, `<web-island>`, and `Connection-Allowlist` with live header probe.
- **2026-12-01:** Moved the 15-assertion conformance matrix and polyfill workbench ahead of setup docs for 700px embeds, added CSP-safe DOM syntax highlighting to code and JSON wire panes, hardened responsive wrapping, and routed all static assets through the Worker with `Cache-Control: no-cache` and 19 passing tests.
- **2026-12-02:** Moved into Track 8 (`platform-observability`), fixed `isPolyfill` detection with explicit Native vs. Polyfill pass score splits, updated the live probe header to `Connection-Allowlist: (); report-to=allowlist`, unified `<web-island>` registration into modular polyfill files, added the 'What Polyfills Cannot Fake' prefetch probe, and shipped dark mode, `?embed=1` height bridging, and `@container` diagrams.

## Primitives tested

- `Custom Elements v1 (<web-island>)`
- `ElementInternals`
- `navigator.modelContext Polyfill`
- `PerformanceObserver`
- `Connection-Allowlist (report-to)`
- `Prefetch Boundary Probe`

## Connected labs in other tracks

- [model-gap live conformance probe](https://aifoc.us/labs/platform-observability/model-gap-live-harness/) — Measures live browser support gaps against shipped platform baselines.
- [agent containment lab](https://aifoc.us/labs/browser-containment/agent-containment-lab/) — Tests deep `Connection-Allowlist` tiers with SQLite Durable Object canaries.
- [<web-island> multi-origin host shell](https://aifoc.us/labs/hypermedia-and-islands/web-island-host-shell/) — Runs real cross-origin `<web-island>` widgets over `MessageChannel`.

---
Canonical: https://aifoc.us/labs/platform-observability/spec-polyfill-browser/
