#55441: test: start the unresponsive-event hang before sending the key
Description of Change
The suspend and no-suspend unresponsive event specs sometimes timed out on Windows ARM64 CI waiting for unresponsive.
hangAndPoke() started the page's busy loop with executeJavaScript() without waiting for it, slept 200 ms, then sent a keyDown. If the page hadn't entered the loop by then, it handled and acked the key. With no pending ack, the hang monitor never armed, and unresponsive never came.
The loop can start late for two reasons:
executeJavaScript()first waits fordid-stop-loading, which can come afterloadURL()resolves.- The renderer can be slow to run the script.
The page now spins in a keydown listener, installed by an awaited executeJavaScript() before the key is sent. So the key itself starts the hang and can't be acked first. The key is still unacked from the moment it is sent, so the suspend spec's timing assertion is unchanged.
The hidden-window spec's server-controlled sync XHR (#55229) isn't reused here. The simulated suspend is broadcast to the network service, whose sockets fail pending reads with ERR_NETWORK_IO_SUSPENDED, and that ends the hang.
Validation on Linux under Xvfb, with retries off:
- Delaying the page's loop by 1 s makes main's version time out in both specs, which is the CI symptom. With this change the key's own handler starts the hang, so that race can't happen.
- The three
unresponsive eventspecs passed 15/15 runs with the first version of this change, and 5/5 with the final one.
Not run on Windows.
🤖 Generated with Claude Code
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- tests are changed or added
Release Notes
Notes: none
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron