Skip to content

Title only the live PDF viewer frame during a recompile swap (fixes typst PDF e2e flake) - #873

Merged
cscheid merged 3 commits into
mainfrom
feature/bd-e4q7juv0-pdf-preview-iframe-flake
Oct 20, 2026
Merged

cscheid merged 3 commits into
mainfrom
feature/bd-e4q7juv0-pdf-preview-iframe-flake

Conversation

@cscheid

@cscheid cscheid commented Oct 20, 2026

Copy link
Copy Markdown
Member

Problem

q2-preview-spa/e2e/typst-pdf-preview.spec.ts › "an edit recompiles the PDF" flaked on #848 (all 3 attempts):

strict mode violation: locator('iframe[title="PDF preview"]') resolved to 2 elements

The two iframes are intentional. On every recompile, @quarto/pdf-viewer loads the new PDF into a second iframe underneath the live one. It swaps the new frame in, in a single paint, only once it has drawn a page, so the reader never sees an empty viewer (bd-c72wsugj). Both frames carried title="PDF preview", so the strict locator failed whenever a poll landed in that window. The window is longer on loaded CI runners. Assistive tech also saw two "PDF preview" frames, one hidden and still loading.

Fix

  • A new viewer frame starts with no title, aria-hidden="true" and inert. When it's swapped in, it gets title="PDF preview" and loses the other two. Painting is unchanged: the loading frame is still laid out and drawn underneath, which the swap's readiness check needs. The file header now records that the loading frame must never be hidden with CSS.
  • embed-typst-pdf.spec.ts drops its .first() workaround, since the selector now matches a single frame.

Tests

  • Unit (hub-client/src/pandoc/pdfViewer.test.ts): only the live frame is titled. The loading frame is hidden from assistive tech but not with CSS.
  • E2E repro (typst-pdf-preview.spec.ts): holds the second viewer's viewer.mjs with page.route, so the swap window stays open, then reads the text layer inside it. Against a build without the fix, both this test and the existing "an edit recompiles the PDF" fail locally with the CI error.
  • With the fix: typst-pdf-preview.spec.ts (chromium + firefox) and embed-typst-pdf.spec.ts (embed) pass 20/20, and cargo xtask verify --skip-hub-build passes.

Plan: claude-notes/plans/2026-10-20-pdf-preview-iframe-flake.md · braid: bd-e4q7juv0

🤖 Generated with Claude Code

cscheid and others added 3 commits October 20, 2026 16:30
…ign two-iframe swap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…juv0)

A recompile loads into a second iframe under the live one and replaces it
once it has painted. Both frames carried title="PDF preview", so the e2e
locator hit a strict-mode violation whenever it polled inside the swap
window (long on loaded CI runners), and assistive tech saw two viewers.

A new frame now starts untitled, aria-hidden and inert, and gets the title
on promotion. Painting is unchanged: the pending frame is still laid out
and drawn underneath, which the readiness gate needs.

Tests: a unit test for the live-frame marker, and an e2e repro that holds
the second viewer's script via page.route so the swap window stays open.
Without the fix it fails with the CI error; the embed spec drops its
.first() workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rame (bd-e4q7juv0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@posit-snyk-bot

posit-snyk-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid
cscheid merged commit adc4241 into main Oct 20, 2026
14 checks passed
@cscheid
cscheid deleted the feature/bd-e4q7juv0-pdf-preview-iframe-flake branch October 20, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants