It is possible for devtools clients to simulate various input events. But there is no way to know if a particular event has been processed, other than waiting for some specific outcome of that event. This is a big inconvenience for the clients, and I'd like to discuss whether we should address it.
In detail, the problem is:
- Devtools input commands are handled in the browser process, where they generate usual input event IPCs; devtools response is sent immediately.
- In the renderer input event IPCs are first examined on the compositor thread, and then posted to the main thread.
This means that the next devtools command might get to DevToolsAgent before the input event is handled on the main thread.
A lot of chromedriver end-to-end tests in chrome/test/chromedriver/test/run_py_tests.py are flaky because of this. To reproduce failures you can add a bit of delay in InputEventFilter::ForwardToHandler.
I suppose that this problem also affects many chromedriver users.
One way to fix the tests is to change common pattern "someElement.Click(); assertTrue(someCondition())" to "someElement.Click(); assertTrue(WaitForCondition(someCondition))".
The other way is to send the response only after handling the input event. This will require adding a possibility to request ACKs for all input events, and a way for devtools' InputHandler to be notified by InputRouterImpl when ACK for a specific event is received.
It seems to me that the latter is the right way to go. What do you think?