import fs from "node:fs"; import path from "node:path"; import { test } from "@playwright/test"; const root = path.resolve(import.meta.dirname, "../../.."); test("capture web engine worker replies on the page", async ({ page }) => { test.setTimeout(180_000); await page.addInitScript(() => { const scope = window as unknown as { __replies: unknown[] }; scope.__replies = []; const original = Worker.prototype.addEventListener; Worker.prototype.addEventListener = function (type: string, listener: EventListenerOrEventListenerObject, options?: unknown) { if (type === "message") { const record = (event: Event) => { const data = (event as MessageEvent).data as { kind?: string; error?: { code?: string; message?: string; detail?: string } } | undefined; if (data && data.error) scope.__replies.push({ code: data.error.code, message: String(data.error.message).slice(0, 400), detail: String(data.error.detail ?? "").slice(0, 400) }); if (scope.__replies.length > 60) scope.__replies.shift(); }; original.call(this, "message", record, options as AddEventListenerOptions); } return original.call(this, type, listener, options as AddEventListenerOptions); } as typeof Worker.prototype.addEventListener; }); await page.goto("/"); await page.waitForTimeout(12000); await page.evaluate(() => ((window as unknown as { __replies: unknown[] }).__replies = [])); await page.getByTestId("blend-file-input").setInputFiles(path.join(root, "blender-5.2.0/tests/files/sequence_editing/sequence.blend")); await page.waitForTimeout(35000); const replies = await page.evaluate(() => (window as unknown as { __replies: unknown[] }).__replies); fs.writeFileSync("/tmp/seq-open-pagehook.json", JSON.stringify(replies, null, 2)); });