15 lines
1.0 KiB
TypeScript
15 lines
1.0 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
test("M13-03B enforces sandbox resource budgets in the production worker", async ({ page }) => {
|
|
await page.goto("/");
|
|
const result = await page.evaluate(() => new Promise<Record<string, any>>((resolve, reject) => {
|
|
const worker = new Worker("/src/workers/script-sandbox-budget-test.worker.ts", { type: "module" });
|
|
worker.onmessage = (event: MessageEvent<Record<string, any>>) => { worker.terminate(); resolve(event.data); };
|
|
worker.onerror = (event) => { worker.terminate(); reject(new Error(event.message)); };
|
|
worker.postMessage({});
|
|
}));
|
|
expect(result.accepted).toEqual({ schemaVersion: 1, cpuMs: 1000, wallMs: 5000, memoryBytes: 1048576, maxMessageBytes: 4096, maxOutputBytes: 8192 });
|
|
expect(result.blocked).toEqual({ cpuMs: "SCRIPT_BUDGET_EXCEEDED", wallMs: "SCRIPT_BUDGET_EXCEEDED", memoryBytes: "SCRIPT_BUDGET_EXCEEDED", maxMessageBytes: "SCRIPT_BUDGET_EXCEEDED", maxOutputBytes: "SCRIPT_BUDGET_EXCEEDED" });
|
|
expect(result.execution).toBe("DISABLED");
|
|
});
|