// boot() never comes up half-working: when the runtime's Service Worker is missing or // never takes control of the page, CJS would run while every guest import and guest // server 404s, so boot() refuses by name instead. import { test, expect } from "@playwright/test"; test("boot() refuses with ServiceWorkerUncontrolledError when the worker never claims the page", async ({ page, context }) => { // Stand in a worker that activates but ignores both its activate-time claim and the // host's { t: "claim" }, so control never arrives. await context.route("**/dist/runtime/sw.js", (route) => route.fulfill({ contentType: "text/javascript", headers: { "Service-Worker-Allowed": "/", "Cross-Origin-Resource-Policy": "same-origin" }, body: 'self.addEventListener("install", () => self.skipWaiting());', })); await page.goto("/tests/fixtures/boot/"); const result = page.locator("#result"); await expect(result).toContainText("ServiceWorkerUncontrolledError", { timeout: 15_000 }); await expect(result).toContainText("reload the page normally"); await expect(result).toContainText("[ERR_NIB_SW_NOT_CONTROLLING]"); }); test("boot() refuses with ServiceWorkerUnavailableError without Service Workers", async ({ page }) => { await page.addInitScript(() => { delete (Navigator.prototype as { serviceWorker?: unknown }).serviceWorker; }); await page.goto("/tests/fixtures/boot/"); await expect(page.locator("#result")).toContainText("ServiceWorkerUnavailableError", { timeout: 15_000 }); await expect(page.locator("#result")).toContainText("[ERR_NIB_SW_UNAVAILABLE]"); });