Files
workinf_Blender_Wasm/web/tests/e2e/wasm-threading-capability.spec.ts
mes123456 7c16b279ae
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Advance M7 workflows and release operations
2026-08-15 17:43:53 -04:00

52 lines
2.6 KiB
TypeScript

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" },
]);
});