Browser tests: how to wait for simulated input events?

40 views
Skip to first unread message

Václav Brožek

unread,
Jun 5, 2014, 3:56:30 AM6/5/14
to chromi...@chromium.org
The test PasswordManagerBrowserTest.PasswordValueAccessible in chrome/browser/password_manager/password_manager_browsertest.cc has been flaky recently (http://crbug.com/346297).

The reason, given local testing with log messages, seems to be the following sequence:

  content::SimulateMouseClick(
      WebContents(), 0, blink::WebMouseEvent::ButtonLeft);
  /* ... */
  CheckScriptReturnValue(check_password, true);

In there, the simulated mouse click is supposed to have an effect on the page's DOM, and the javascript code then verifies the effect. The problem is that the SimulatedMouseClick seems to get delayed. More precisely, the call to WebViewImpl::handleInputEvent associated to the simulated script is done after the script finishes.

My question: what should I wait for to make sure the simulated click is processed before the script?

I tried so far content::RunAllPendingInMessageLoop() (no effect), and also waiting for NOTIFICATION_FOCUS_CHANGED_IN_PAGE. The focus change notification did not seem to be fired even when I manually clicked in the test browser window and changed focus to various elements on the page.

Any advice welcome. :)

Thanks,
Vaclav

Bartosz Fabianowski

unread,
Jun 5, 2014, 4:57:02 AM6/5/14
to va...@chromium.org, chromi...@chromium.org
You could modify the JS snippet that verifies the effect: Instead of
chrome.send()ing the status of the page's DOM immediately, it could
check whether the DOM has taken the expected shape yet. If the DOM does
not appear to have changed yet, the JS could set up an appropriate
listener so that it gets notified when the mouse click arrives and the
DOM changes.

>
> Thanks,
> Vaclav
>

Michael Thiessen

unread,
Jun 5, 2014, 12:34:30 PM6/5/14
to bar...@google.com, va...@chromium.org, chromi...@chromium.org
Take a look at ExtensionTestMessageListener, it may be what you're looking for.

It allows your test to wait on a message from JS, so you can send the message the test waits for in the inputEvent handler you expect to trigger. This way your test will only resume once the mouse event has been processed.





Thanks,
Vaclav


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:    http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

Reply all
Reply to author
Forward
0 new messages