Fix flaky WebViewTest.SpatialNavigationJavascriptAPI.

Two reasons for flakiness were identified:

* Occasional lack of sync between the C++ and JS sides of the test.
Sometimes, the JS side emitted signals before the C++ code was ready to
listen to them, or the C++ side emitted keystrokes before listeners were
ready in JS code. Fixed with slight changes in the order of the test

* When checking the spatial navigation status immediately after changing
it, the wrong state could be reported. When the system is under heavy
load, it could happen that the changed state is reported before the
change has been made effective in the render process. Fixed sending a
message to the guest render process with postMessage, which uses the
same IPC channel; when the message is answered we can be sure that the
SetSpatialNavigationEnabled operation is complete.

Bug: 884306
Change-Id: Iae227098cd36980357d8b747ddcb527df2317fa1
Reviewed-by: Lucas Gadani <>
Commit-Queue: Jacobo Aragunde Pérez <>
Cr-Commit-Position: refs/heads/master@{#609241}
2 files changed