Repository navigation
Wait for the reloaded document's focus before the Firefox reload-typing test presses its key - #7151
Merged
Merged
Conversation
… in Firefox The test pressed `r` once the replacement document left `loading`, but Firefox gives that document focus a little later, and a key pressed in between reaches no document of the page: in failing copies the new window logged no keydown (and sometimes only the keyup) before its `focus` event. `document.hasFocus()` alone narrowed the gap but still lost 1 of 48 copies, since it reads true before Firefox fires the window's `focus` event. The test now waits for that event in Firefox, and for `hasFocus()` in Chromium, which fires none on reload and takes the key from the start. The behavior the test protects, a key typed through the reload acting in the restored thread view, is unchanged. `leaf-dev suite flake --copies 24 --workers 4 --load 3`, Firefox: 2 of 24 failed twice before the change; 54 of 54 passed after it. Chromium: 12 of 12. Closes #7143
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 Firefox copy of
test_a_key_typed_through_the_reload_acts_where_the_user_is_put_backpressedrbefore the reloaded document could receive it. The test pressed once the replacement document leftloading. Firefox gives that document focus a little later, and a key pressed in that gap never reaches the page. The test now waits until the document can take the key: in Firefox, for the window'sfocusevent, and in Chromium, fordocument.hasFocus(). What the test protects is unchanged: a key typed through the reload still lands before the runtime has reopened the thread view, and must resolve the thread the user is put back in.This is not a dropped keypress in Leaf. With an init script logging every window input event, each failing copy showed no
keydownin the new document. The press started at 7965 ms, the window'sfocusevent came at 8052 ms, and the window saw only the straykeyupat 8118 ms. In another failure nothing of the key arrived at all. No Leaf code saw the key, so the early key hold (bootstrap.js,holdEarlyKeys) had nothing to hold.Waiting for
document.hasFocus()alone is not enough in Firefox. It still lost 1 of 48 copies, becausehasFocus()already read true while thefocusevent was still pending. Chromium fires no windowfocusevent on reload, and its document took the key from the start, so Chromium keeps thehasFocus()check.Evidence from
leaf-dev suite flake --workers 4 --load 3on the Firefox node:hasFocus()onlyThe Chromium node passed 12 of 12 under the same load.
Closes #7143 — automated triage