42 lines
2.0 KiB
TypeScript
42 lines
2.0 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test("gates only the pthread WASM engine on its three platform requirements", async ({ page }) => {
|
|
await page.goto("/");
|
|
const gates = await page.evaluate(async () => {
|
|
const { gateWasmThreadingCapability } = await import("/src/platform/capabilities.ts");
|
|
return {
|
|
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.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" },
|
|
]);
|
|
});
|