import { expect, test } from "@playwright/test"; test("gates only the pthread WASM engine on its three platform requirements", async ({ page }) => { const documentResponse = await page.goto("/"); expect(documentResponse).not.toBeNull(); await expect.poll(async () => (await documentResponse!.allHeaders())["cross-origin-opener-policy"]).toBe("same-origin"); await expect.poll(async () => (await documentResponse!.allHeaders())["cross-origin-embedder-policy"]).toBe("require-corp"); await expect.poll(async () => (await documentResponse!.allHeaders())["cross-origin-resource-policy"]).toBe("same-origin"); const gates = await page.evaluate(async () => { const { detectBrowserCapabilities, gateWasmThreadingCapability } = await import("/src/platform/capabilities.ts"); return { actual: gateWasmThreadingCapability(detectBrowserCapabilities()), ready: gateWasmThreadingCapability({ crossOriginIsolated: true, sharedArrayBuffer: true, worker: true }), noIsolation: gateWasmThreadingCapability({ crossOriginIsolated: false, sharedArrayBuffer: true, worker: true }), noSharedArrayBuffer: gateWasmThreadingCapability({ crossOriginIsolated: true, sharedArrayBuffer: false, worker: true }), noWorker: gateWasmThreadingCapability({ crossOriginIsolated: true, sharedArrayBuffer: true, worker: false }), none: gateWasmThreadingCapability({ crossOriginIsolated: false, sharedArrayBuffer: false, worker: false }), }; }); expect(gates.actual).toMatchObject({ capability: "WASM_PTHREAD_ENGINE", status: "READY", issues: [], }); expect(gates.ready).toEqual({ taskId: "M6-02", capability: "WASM_PTHREAD_ENGINE", status: "READY", issues: [], }); expect(gates.noIsolation.issues.map(({ code, path }) => ({ code, path }))).toEqual([ { code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "crossOriginIsolated" }, ]); expect(gates.noSharedArrayBuffer.issues.map(({ code, path }) => ({ code, path }))).toEqual([ { code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "sharedArrayBuffer" }, ]); expect(gates.noWorker.issues.map(({ code, path }) => ({ code, path }))).toEqual([ { code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "worker" }, ]); expect(gates.none).toMatchObject({ taskId: "M6-02", capability: "WASM_PTHREAD_ENGINE", status: "BLOCKED", }); expect(gates.none.issues.map(({ code, path }) => ({ code, path }))).toEqual([ { code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "crossOriginIsolated" }, { code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "sharedArrayBuffer" }, { code: "PLATFORM_CAPABILITY_UNAVAILABLE", path: "worker" }, ]); });