Repository navigation
Wait for first paint before reading a page's pre-runtime geometry - #807
Merged
Merged
Conversation
`test_a_restored_auxiliary_surface_has_final_geometry_before_runtime_loads` read `body > main` while the render-blocking theme was still in flight, so it compared the user agent's own layout of the authored HTML with the themed page and reported the whole theme as restoration moving the shell. A forced layout — `bounding_box`, and `to_be_visible` with it — answers from the stylesheets that have arrived, while the paint waits for the rest, so element visibility is not the fact a pre-runtime measurement needs. `displayed` waits on first contentful paint, the browser's own record that the render-blocking head has been applied and what it composed is on screen. The four measurements taken before the runtime lands take it first: the restored auxiliary surface, the held authored paint beside it, and the two site shells, which carried the same latent failure. `tests/CLAUDE.md` states the rule beside the readiness stamps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_a_restored_auxiliary_surface_has_final_geometry_before_runtime_loads[saved0-…]failed on main's nightly fordd8e0debecause its first geometry reading was taken before the page's render-blocking theme applied: it compared the user agent's own layout of the authored HTML against the themed page and reported the difference — the whole theme — as restoration moving the shell. The four pre-runtime measurements in the suite now wait for first contentful paint, through one new harness helper.A box is not a paint.
bounding_box, and Playwright'sto_be_visiblewith it, force a layout that answers from the stylesheets that have arrived so far; a render-blocking stylesheet still in flight holds the paint back but not that forced layout. Soexpect(page.locator("h1")).to_be_visible()returns with a box the theme has never touched, and the reading behind it is the user agent's. Holdingtheme.cssopen on this page produces the nightly's two numbers exactly:displayed(page)waits onfirst-contentful-paint, which is the browser's own record that the render-blocking head has been applied and what it composed is on screen. That is the state each of these tests means to measure, since each one asks what a reader sees before the runtime loads — so the wait states the test's own premise rather than adding a tolerance to its assertion. Three other tests took the same reading behind element visibility alone and carried the same latent failure:test_authored_html_paints_while_runtime_startup_is_heldbeside it, and the two site shells intest_site.py. All four take the wait now, andtests/CLAUDE.mdstates the rule next toBOTH_STAMPS, where the readiness facts a test may consume are already listed.No product code changes. The page's pre-runtime geometry was already right: every one of these tests passes once the theme has applied.
Bug-back and checks
The window is small enough that the case passes on a warm rerun, so the bug-back widens it with the browser rather than with repetition: 400ms of CDP-emulated latency on every response, applied to a copy of the failing test parameterized on whether it takes the wait. Without
displayedit fails with the nightly's exact reading (x 136.5 vs 8 ± 1,y 42 vs 21.4375 ± 1,width 768 vs 1584 ± 1); with it, it passes. Held-route probing gave the reading above, which is where the numbers came from. Both were re-run on78f9ba7a, this branch's base, after the theme change landed there.uv run pytest tests/test_render_startup.py --run-nightly: 95 passed.uv run pytest tests/test_site.py -n0 --run-nightly -k "paints_in_its_final_position or every_stage_of_site_startup": 2 passed.uv run pre-commit runover the four changed files: passed.uv run pytest tests, on the same diff overdd8e0de: 1136 passed, 5 failed. Those five are this sandbox's: threetest_interact_session.pycases andtest_staged_writes_honor_umask_without_copying_a_replaced_symlink_modefail on a read-only/tmpand on the file mode this container returns, andtest_live_shell_artifact.pywantsworker/'s node modules, which are not installed here. None of them load a browser.The same nightly carried one more failure,
test_a_refused_reopen_preserves_a_filter_typed_during_restoration, refused by the delivered page's CSP. That is #782's, and nothing here touches it.