Skip to content

Make the restored-frame-tab test's frame delay actually reach the frame - #771

Merged
max-sixty merged 1 commit into
mainfrom
fix/gallery-frame-delay-init-script
Sep 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/gallery-frame-delay-init-script

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

test_interaction_gallery_waits_for_a_restored_frame_tab names the arrangement it needs — a remembered chrome demo whose inner Leaf page is slow to arrive — and then never makes it. Its init script was written as a bare arrow function, and add_init_script takes source rather than a function Playwright calls, so the document evaluates the arrow, discards it, and Element.prototype.append is never patched. Wrapping it in the IIFE the suite's other init scripts use makes the delay real.

Measured on the frame after the reload, with a counter added to the script body: the arrow form reports patched False, delayed 0 and the demo is ready 4.8s in; the IIFE form reports patched True, delayed 2 and ready at 7.7s — the two contained <script> appends each held back the stated 2s. The test passes either way, so nothing was red; it was simply proving the ordinary path twice rather than the slow one it is named for.

This is the only add_init_script call in the suite written that way — the others pass plain statements or (() => { … })(). The same string form is correct for evaluate, which is where the rest of the tree's """() => …""" blocks live, and which is presumably where this one came from.

Found while diagnosing the nightly failure in #770; the two changes are independent.

Verification

uv run pytest tests/test_site.py::test_interaction_gallery_waits_for_a_restored_frame_tab -n0 --run-nightly passes on repeat runs with the delay in force, and pre-commit run --files tests/test_site.py is clean. test_site.py is nightly-only, so the everyday gate is unaffected.

@max-sixty
max-sixty merged commit 1ffc8fc into main Sep 18, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/gallery-frame-delay-init-script branch September 18, 2026 05:45
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