Draft Browser Spec Conformance · Native vs. Polyfill Testbed

Web + AI Spec Polyfill Testbed

Run 15 live browser conformance tests across three draft web proposals—navigator.modelContext (WebMCP), capability-scoped <web-island> elements with ElementInternals, and Connection-Allowlist egress rules—while separating native browser support from JavaScript polyfill coverage.

Why this matters

Draft browser standards look clean in markdown explainers, but naming conflicts, validation edge cases, and security gaps remain hidden until developers run real conformance assertions in a browser.

What this opens up

Testing draft browser specs early before engines ship them. This harness splits Native vs. Polyfill pass scores, times overhead with PerformanceObserver, and marks the exact line where JavaScript shims stop working.

How the tests work

Run all 15 checks below (5 per spec), register and execute a JSON-Schema-validated tool bound to <web-island>, test a live Connection-Allowlist: (); report-to=allowlist iframe probe, and run two falsification probes proving what JavaScript polyfills cannot fake.

3 Things To Try

Run the conformance checks, invoke a capability-scoped tool, and measure polyfill overhead
01

Run All 3 Spec Conformance Suites

Checks which of the 15 spec rules pass natively in your browser versus via JavaScript polyfills, and reloads the live /probe/connection-allowlist header frame.

02

Register & Execute Live Tool + <web-island>

Registers a schema-validated tool on navigator.modelContext, grants its token on <web-island>, and runs an end-to-end call.

03

Measure Polyfill & Policy Overhead

Times 25 runs of tool setup, JSON-Schema validation, and allowlist evaluation using performance.mark, then opens the results in the Wire Inspector.

Native Browser Pass 0 / 15
Polyfill Pass 0 / 15
Conformance Overhead — ms
Connection-Allowlist Probe Pending

Native vs Polyfill Conformance Matrix

Running initial check…

Interactive Polyfill Workbench

Exercise tool registration, capability gating, header parsing, and engine-only security boundaries live

navigator.modelContext + <web-island>

Register a tool on the active navigator.modelContext polyfill, declare capabilities on the live <web-island> element, and inspect ElementInternals form participation.

Sandboxed <iframe> + CSP-safe adoptedStyleSheets + ElementInternals form contract.
Tool Status
Not registered yet
Capability Gate
—
ElementInternals Validity
—
FormData("island_contract")
—

Connection-Allowlist Header & Egress Guard

Test RFC 9651 Structured Field parsing (including fail-closed empty () and malformed policies) alongside the real /probe/connection-allowlist HTTP response iframe.

Policy not evaluated yet.
Live Edge Probe: GET /probe/connection-allowlist (Connection-Allowlist: (); report-to=allowlist)

What Polyfills Cannot Fake (Engine-Gap Falsification Probes)

JavaScript shims can validate schemas and wrap fetch(), but cannot enforce engine-level pre-connection blocking or process/origin isolation. Run both probes below to observe the falsification boundary directly.

Click a probe to verify where JavaScript polyfills diverge from native browser engine guarantees.

Spec Conformance & Timing Wire Inspector

Mutually exclusive <details name="wire"> panes
1. Conformance Trace, Tool Registry & Egress Decisions
Running conformance suite...
2. HTTP Probe Headers (/api/specs & /probe/connection-allowlist)
Fetching worker endpoint headers...
3. PerformanceObserver Marks & Measures
Collecting PerformanceObserver entries...
How This Is Set Up

Conformance & Polyfill Harness Architecture

Draft specifications such as navigator.modelContext, capability-scoped <web-island> elements, and Connection-Allowlist headers ship on separate engine timelines. This harness feature-detects each surface, installs deterministic polyfills where native APIs are absent, and records PerformanceObserver marks alongside a live Cloudflare Worker probe.

Unverified explainer glue (drift risk)
// Calling draft APIs without feature detection, schema validation, or egress bounds
async function invokePageTool(name, args, container) {
  // Assumes navigator.modelContext exists without schema or AbortSignal guards
  const result = await navigator.modelContext.callTool(name, args);
  // Unscoped iframe + permissive connect-src permits unlisted outbound fetches
  const frame = document.createElement("iframe");
  frame.src = "https://third-party.example/widget";
  container.replaceChildren(frame);
  // No PerformanceObserver marks or conformance assertions for native vs shim
  return result;
}
Conformance-tested polyfill (this lab)
// public/app.js — feature-detected polyfills + 15-assertion conformance suite
import {
  defineWebIslandElement, installModelContextPolyfill, runSpecConformanceSuite
} from "/lib/spec-polyfills.js";

defineWebIslandElement(window); // Attaches ElementInternals + FormData contract
installModelContextPolyfill(navigator, { performance });

navigator.modelContext.registerTool({
  name: "lookup_spec",
  inputSchema: { type: "object", required: ["query"], properties: { query: { type: "string", minLength: 2 } } },
  execute: ({ query }) => ({ query, specs: ["webmcp", "connection-allowlists"] })
}, { signal: abortController.signal });

const report = await runSpecConformanceSuite({ navigator, window, performance, PerformanceObserver });
Complete Page Setup: Verbatim Assertions, Custom Element & Worker Probe Wiring

Mount elements in public/index.html, the 15-assertion SPEC_PROPOSALS check list, <web-island> ElementInternals contract, navigator.modelContext tool descriptor, PerformanceObserver collection, and Worker /probe/connection-allowlist response headers.

<!-- 1. Page HTML Setup (public/index.html) -->
<form id="island-demo-form" class="island-form">
  <web-island id="live-island" name="island_contract" island-id="sandbox-1"
    capabilities="theme resize tool:lookup_spec tool:search" sandbox-policy="allow-scripts"></web-island>
</form>
<div id="suites-container" class="suites-grid"></div>
<iframe id="allowlist-probe-frame" class="probe-frame" title="Connection-Allowlist HTTP Header Probe"></iframe>
<script type="module" src="/app.js"></script>

// 2. 15-Assertion Conformance Suite, Tool Descriptor & ElementInternals Contract (public/lib/spec-polyfills.js)
// SPEC_PROPOSALS declares 3 specs x 5 assertions = 15 checks:
// - navigator-modelcontext: mc-surface-detect, mc-register-and-list, mc-schema-valid-exec,
//   mc-schema-invalid-reject, mc-lifecycle-abort-and-provide
// - web-island-element: wi-registry-define, wi-element-internals, wi-capability-parse,
//   wi-form-participation, wi-frame-contract-serialize
// - declarative-egress-guard: egress-empty-fail-closed, egress-malformed-fail-closed,
//   egress-response-origin-match, egress-csp-connect-src, egress-guarded-fetch-block
class WebIslandElement extends env.HTMLElement {
  static formAssociated = true;
  static observedAttributes = ["capabilities", "island-id", "src", "sandbox-policy", "name"];
  _syncInternals() {
    this._internals.role = "region";
    this._internals.setFormValue(JSON.stringify({ islandId, sandboxPolicy, capabilities: parsed.tokens }));
    this._internals.setValidity(parsed.valid ? {} : { customError: true }, "Invalid capability token(s)");
  }
}
const lookupToolDescriptor = {
  name: "lookup_spec",
  description: "Query matching spec proposal metadata via <web-island> capability tool:lookup_spec.",
  inputSchema: {
    type: "object",
    properties: { query: { type: "string", minLength: 2 } },
    required: ["query"],
    additionalProperties: false
  },
  execute: async ({ query }) => ({
    toolName: "lookup_spec",
    query,
    islandCapabilityGranted: getLiveIsland().allows("tool:lookup_spec")
  })
};

// 3. Page Bootstrap, PerformanceObserver Runner & Edge Probe Headers (public/app.js + src/worker.ts)
defineWebIslandElement(window);
state.modelContextInstall = installModelContextPolyfill(navigator, { performance });
navigator.modelContext.registerTool(lookupToolDescriptor, { signal: controller.signal });
const globalPerfObserver = new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    state.perfHistory.push({ entryType: entry.entryType, name: entry.name, startTime: entry.startTime, duration: entry.duration });
  }
});
globalPerfObserver.observe({ entryTypes: ["mark", "measure"] });
const result = await runSpecConformanceSuite({ navigator, window, document, customElements: window.customElements, HTMLElement: window.HTMLElement, performance, PerformanceObserver: window.PerformanceObserver, ReportingObserver: window.ReportingObserver, origin: window.location.origin, probeResult: state.lastProbePayload || undefined });
// src/worker.ts GET /probe/connection-allowlist headers:
// "Connection-Allowlist": "(); report-to=allowlist"
// "Reporting-Endpoints": `allowlist="${url.origin}/api/egress-report"`
// "Content-Security-Policy": `default-src 'none'; connect-src 'self'; script-src 'sha256-${scriptHash}'; style-src 'sha256-${styleHash}'; frame-ancestors 'self' https://aifoc.us https://*.aifoc.us`
Browser + Edge Egress Contract (RFC 9651 Allowlist, CSP Intersection & Marks)
// src/worker.ts (/probe/connection-allowlist) & public/lib/spec-polyfills.js
// Worker emits fail-closed RFC 9651 empty allowlist + Reporting-Endpoints:
headers.set("Connection-Allowlist", "(); report-to=allowlist");
headers.set("Reporting-Endpoints", `allowlist="${url.origin}/api/egress-report"`);

// public/lib/spec-polyfills.js: runSpecConformanceSuite() + createEgressGuard()
const guard = createEgressGuard({
  responseOrigin: url.origin,
  headerValue: "()", // Denies unlisted outbound fetch() when native enforcement is absent
  cspHeader: "connect-src 'self'",
  enforce: true
});
const obs = new PerformanceObserver((list) => list.getEntries());
obs.observe({ entryTypes: ["mark", "measure"] });
performance.mark("spec:suite:start"); // Measured across 15 deterministic assertions
Eliminated assumptions

Unchecked feature assumptions from draft explainers, global shims lacking AbortSignal cleanup, and unverified cross-origin iframe message bridges.

Explicit runtime contracts

JSON-Schema-validated navigator.modelContext tools, ElementInternals form participation on <web-island>, fail-closed Connection-Allowlist: () parsing, and PerformanceObserver latency deltas.

Current engine gaps

Native Connection-Allowlist: () pre-connect blocking and ReportingObserver delivery for "connection-allowlist" are absent in standard browsers, requiring guardedFetch() and the live Worker probe until engines ship.

Architecture Proposal contracts, polyfill conformance runtime & live edge probe
Browser Runtime + Cloudflare Edge Probe Boundary
01 / Proposal Contracts

Spec Registry GET /api/specs

SPEC_PROPOSALS (3 specs × 5 checks)
  • navigator.modelContext tool lifecycle & JSON Schema
  • <web-island> sandboxed <iframe> + ElementInternals
  • Connection-Allowlist: (); report-to=allowlist
02 / Polyfill & Edge Probe

Conformance Runtime spec-polyfills.js

  1. Check native navigator.modelContext (ignoring isPolyfill)
  2. Mount <web-island> with adoptedStyleSheets + opaque /island-frame
  3. Load GET /probe/connection-allowlist to test browser egress blocking
  4. Intersect RFC 9651 allowlist with CSP connect-src in guardedFetch()
03 / Matrix

Native vs Polyfill Split

Native Browser Pass · Polyfill Pass

Separates engine-enforced assertions from JavaScript polyfill coverage.

Telemetry

Wire & Timing Inspector

PerformanceObserver · ReportingObserver

Captures mark/measure overhead and capped POST /api/egress-report deliveries.

Architecture boundary: Worker endpoints emit live Connection-Allowlist: (); report-to=allowlist and spec metadata while spec-polyfills.js separates native engine detection from polyfill conformance assertions.
Key terms & further reading
WebMCP (navigator.modelContext)
A draft browser API allowing web pages to register structured, schema-validated tools that agents can invoke directly.
Custom Elements & ElementInternals
Browser primitives letting a custom HTML tag like <web-island> participate in form submission, validation, and ARIA roles.
Connection-Allowlist header
A draft HTTP response header that enforces which origins a document may contact at the browser networking layer, failing closed on empty () or invalid syntax.
RFC 9651 Structured Fields
The strict syntax specification for HTTP header inner lists and parameters used by Connection-Allowlist.
PerformanceObserver marks & measures
A browser timing interface used here to record exact millisecond durations for polyfill setup and policy evaluation.
Speculative prefetch (<link rel="prefetch">)
A browser-initiated network fetch triggered by HTML markup that bypasses JavaScript fetch() wrappers, demonstrating what only native engine rules can block.