Enabling RenderDocument causes same-origin navigations to swap to a new
RenderFrameHost. However, when a RenderFrameHost is changed, the browser
dispatches synthetic mouse events to ensure the renderer knows where the
mouse cursor is. In web tests using the event_sender API, events are
injected into Blink synchronously so the browser-generated synthetic
events may be processed after test events which can affect test output.
This CL changes the web test runner to ensure all synthetic events have
been flushed and processed before the test is started. It does this by
blocking parsing in a web test until input has been flushed, the order
of events from the perspective of WebTestControlHost:
* Initial-state/Test Finished: Set a `next_nav_is_new_test` bit.
* READY_TO_COMMIT: If `next_nav_is_new_test` - call
BlockTestUntilStart in the renderer which blocks parsing in the
current DocumentLoader, before it starts loading the new document.
* <During CommitPending>: Post a task to generate the synthetic
events.
* DID_FINISH_NAVIGATION: If `next_nav_is_new_test` - clear the bit and
post a task to:
* Flush input - this waits until all input has been IPC'd to the
renderer and ACK'd. Note: input may still be queued in
renderer-side compositor or main thread queues.
* Calls StartTest on the renderer.
* StartTest (in renderer)
* Flushes the compositor queue to ensure all its input has been
processed (this may result in queueing input on the main thread).
* Flushes the main thread event queue.
* Unblocks the parser.
Bug: 1416496
Change-Id: I2ac0c3745e74a0a01055d5e7a474036096b8ec6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4727485
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@google.com>
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1188325}