Checkpoint web parity through Chromium input tasks
This commit is contained in:
23
web/tests/e2e/ply-negative.spec.ts
Normal file
23
web/tests/e2e/ply-negative.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const fixtureRoot = path.join(root, "tests/files/web/m12_ply_negative_v1");
|
||||
const cases = [
|
||||
{ id: "big-endian", file: "big-endian.ply", expected: "PLY_FORMAT_UNSUPPORTED", format: "binary_little_endian" },
|
||||
{ id: "malformed-list", file: "malformed-list-ascii.ply", expected: "PLY_DATA_TRUNCATED", format: "ascii" },
|
||||
{ id: "oversized-count", file: "oversized-count-ascii.ply", expected: "PLY_IMPORT_BUDGET_EXCEEDED: vertex", format: "ascii" },
|
||||
];
|
||||
|
||||
test("M12-07I production Worker blocks PLY negative cases deterministically", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async (input) => Promise.all(input.map((candidate) => new Promise<any>((resolve, reject) => {
|
||||
const worker = new Worker("/src/workers/ply-roundtrip-test.worker.ts", { type: "module" });
|
||||
worker.onmessage = (event: MessageEvent<any>) => { worker.terminate(); resolve({ id: candidate.id, ...event.data }); };
|
||||
worker.onerror = (event) => { worker.terminate(); reject(new Error(event.message)); };
|
||||
const bytes = Uint8Array.from(candidate.bytes).buffer;
|
||||
worker.postMessage({ bytes, format: candidate.format }, [bytes]);
|
||||
}))), cases.map((candidate) => ({ id: candidate.id, format: candidate.format, bytes: Array.from(fs.readFileSync(path.join(fixtureRoot, candidate.file))) })));
|
||||
expect(result.map((item) => ({ id: item.id, ok: item.ok, error: item.error }))).toEqual(cases.map((candidate) => ({ id: candidate.id, ok: false, error: candidate.expected })));
|
||||
});
|
||||
Reference in New Issue
Block a user