Repository navigation
test: read the swap watch's boxes without a ResizeObserver, so it raises and hides no loop errors - #5898
Merged
Conversation
…ses and hides no loop errors The swap watch, which the browser fixture injects into every page a browser test opens, read flex rows with its own ResizeObserver. When a page ResizeObserver on a deeper box resized a row the watch observed, the browser left the watch's observation undelivered and raised "ResizeObserver loop completed with undelivered notifications", an error the page didn't cause. That error fails test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection] in most of main's push runs; instrumented, the skipped observation was the watch's own, on .lf-fab-bar. The same observer also hid loop errors pages do raise, since its shallow deliveries let a page's deeper observers deliver where the browser would otherwise leave them undelivered. The watch now reads boxes from an IntersectionObserver in the update after anything that may change one (a DOM write, text included, a resize, an image or font arriving, hover, a press, focus or typing) and in each update while an animation runs. It converts each painted box back to its layout box, so it judges the sizes it judged before. Behaviour this changes, each now a test: - a page observer that swaps a standing row's occupant in its delivery is judged with no loop error, and a loop error the page raises reaches the test; - an occupant shown for one frame is judged in that frame, from the boxes it painted; - an occupant that arrives and moves on before a frame takes no seat; - a row under a transform is judged in layout pixels, as its padding is. A box changed by something none of the triggers announce, such as a script setting a field's value or editing a style sheet, is read only after the next trigger.
leaf-agent
approved these changes
Nov 12, 2026
This was referenced Nov 13, 2026
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.
The browser tests' swap watch (
tests/swap_watch.js, injected into every page a browser test opens) read flex rows with its own ResizeObserver. When a page ResizeObserver on a deeper box resized a row the watch observed, the browser left the watch's observation undelivered and raised a loop error the page didn't cause. That is the teardown error failingtest_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection]in most of main's push runs (#3985); instrumented, the skipped observation was the watch's own, on.lf-fab-bar. The same observer also hid loop errors pages raise themselves: its shallow deliveries let a page's deeper observers deliver where the browser would otherwise leave them undelivered (reproduced in Chromium and Firefox).The watch now reads boxes from an IntersectionObserver in the update after anything that may change one (a DOM write, text included, a resize, an image or font arriving, hover, a press, focus or typing) and in each update while an animation runs. It converts each painted box back to its layout box, so it judges the same sizes as before.
What to weigh:
valueor editing a style sheet, is read only at the next trigger, so a swap in its row before then is judged against the old size. Leaf's own UI sets no textarea value. Reading every frame instead would close this, but keeps every test page rendering continuously.leaf-dev flake) on either watch.leaf-dev bench's 256-ask page (5,400 watched boxes), main-thread CPU per input against main's watch: keystroke 11.4 vs 8.6 ms in Chromium and 16.7 vs 11.9 ms in Firefox, wheel step 10.7 vs 7.8 ms in Chromium and level in Firefox. Each reading walks every watched box.#5754's 19 cases plus a transition case: main's watch judges 7 wrong, 4 of them with loop errors; this one judges all 20 right in both engines, over repeated runs. The cases two review rounds added pass too, except the two the first point describes. The failing test errored in 3 of 3 runs under
taskpolicy -bbefore, and has passed all 8 since, 2 of them on this head. The new tests intest_render_swap_watch.pyeach fail on main's watch or on this one with the mechanism they cover removed. #5754 asks for main's cost too, so it stays open for the cost above.Part of #5754. Requested by Max in a dispatched session; reviewed in two rounds by a separate agent.