diff --git a/packages/runtime-playground/src/editor-command-runners.ts b/packages/runtime-playground/src/editor-command-runners.ts index 844671d3..32311461 100644 --- a/packages/runtime-playground/src/editor-command-runners.ts +++ b/packages/runtime-playground/src/editor-command-runners.ts @@ -887,9 +887,8 @@ export async function captureEditorPresentation(page: import("playwright").Page, if (!canvas) continue if (frame) sawCanvas = true const capture = await canvas.evaluate(({ canvasDocumentType, iframeCount }) => { - if (document.readyState !== "complete" || document.fonts?.status === "loading") return null + if (document.readyState !== "complete") return null const stylesheets = Array.from(document.querySelectorAll('link[rel~="stylesheet"]')) - if (stylesheets.some((stylesheet) => !stylesheet.disabled && !stylesheet.sheet)) return null return { documentIdentity: `${location.href}\n${performance.timeOrigin}`, documentAgeMs: performance.now(), diff --git a/tests/browser-routed-command-security.test.ts b/tests/browser-routed-command-security.test.ts index 8ab8e871..7ade09a8 100644 --- a/tests/browser-routed-command-security.test.ts +++ b/tests/browser-routed-command-security.test.ts @@ -22,6 +22,7 @@ const REPLACED_CANVAS_PRESENTATION_IDENTITY = "d".repeat(64) const DELAYED_CANVAS_PRESENTATION_IDENTITY = "e".repeat(64) const PARENT_CANVAS_PRESENTATION_IDENTITY = "f".repeat(64) const SLOW_PRESENTATION_IDENTITY = "1".repeat(64) +const PENDING_STYLES_PRESENTATION_IDENTITY = "2".repeat(64) const matchedPresentationMarkup = `
Matched presentation
` const editorShell = `` const delayedCanvasEditorHtml = `${editorShell}
Transition
` const slowPresentationEditorHtml = `${editorShell}` +const pendingStylesEditorHtml = `${editorShell}` test("real browser commands sanitize console, artifacts, stdout, and failure stderr", async () => { const httpServer = createServer((request, response) => { @@ -68,6 +70,8 @@ test("real browser commands sanitize console, artifacts, stdout, and failure std ? delayedCanvasEditorHtml : request.url?.startsWith("/slow-presentation") ? slowPresentationEditorHtml + : request.url?.startsWith("/pending-styles") + ? pendingStylesEditorHtml : editorHtml) }) const serverUrl = await listenLocalHttpServer(httpServer) @@ -223,6 +227,18 @@ test("real browser commands sanitize console, artifacts, stdout, and failure std assert.deepEqual(output.summary.editorPresentation.generatedPresentationIdentities, [SLOW_PRESENTATION_IDENTITY]) }) + await withTempDir("wp-codebox-real-editor-pending-styles-security-", async (artifactRoot) => { + const result = await runEditorOpenCommand({ + artifactRoot, + runPlaygroundCommand, + runtimeSpec, + server, + spec: { command: "wordpress.editor-open", args: [`url=http://routed.test/pending-styles?token=${TOKEN}`, "route-host=routed.test", "capture=steps", "wait-timeout=5s"] }, + }) + const output = JSON.parse(result.output) as { summary: { editorPresentation: { generatedPresentationIdentities: string[] } } } + assert.deepEqual(output.summary.editorPresentation.generatedPresentationIdentities, [PENDING_STYLES_PRESENTATION_IDENTITY]) + }) + await withTempDir("wp-codebox-real-editor-canvas-security-", async (artifactRoot) => { const result = await runEditorCanvasProbeCommand({ artifactRoot,