Commit 47740515 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fix flaky SyntheticMouseEventTest.MouseEventAck

Reland https://chromium-review.googlesource.com/804357. This time ensure
that we are using a MouseDown event instead of MouseMove event as
MouseMove events can be sent from the UI synthetically and that causes
the InputMsgWatcher to be in a different state sometimes.

Devtools was not correctly handling input that is not generated by itself
and invoking callbacks when the input wasn't actually processed.

Add a modifier indicating content was injected using the debugger so that
we can then query for that to determine if we should release the event.
This is a stop gap solution until we can actually bind callbacks into the
sending of events and devtools wouldn't need its own queues of callbacks.

BUG=789869
TBR=pfeldman@chromium.org

Change-Id: Id769fa9363debb196d787a73920f24e3a409c68f
Reviewed-on: https://chromium-review.googlesource.com/811833
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522417}
parent 7f13c93d
...@@ -514,11 +514,19 @@ class SyntheticKeyEventTest : public DevToolsProtocolTest { ...@@ -514,11 +514,19 @@ class SyntheticKeyEventTest : public DevToolsProtocolTest {
class SyntheticMouseEventTest : public DevToolsProtocolTest { class SyntheticMouseEventTest : public DevToolsProtocolTest {
protected: protected:
void SendMouseEvent(const std::string& type, int x, int y, bool wait) { void SendMouseEvent(const std::string& type,
int x,
int y,
const std::string& button,
bool wait) {
std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
params->SetString("type", type); params->SetString("type", type);
params->SetInteger("x", x); params->SetInteger("x", x);
params->SetInteger("y", y); params->SetInteger("y", y);
if (!button.empty()) {
params->SetString("button", button);
params->SetInteger("clickCount", 1);
}
SendCommand("Input.dispatchMouseEvent", std::move(params), wait); SendCommand("Input.dispatchMouseEvent", std::move(params), wait);
} }
}; };
...@@ -582,20 +590,20 @@ IN_PROC_BROWSER_TEST_F(SyntheticKeyEventTest, KeyboardEventAck) { ...@@ -582,20 +590,20 @@ IN_PROC_BROWSER_TEST_F(SyntheticKeyEventTest, KeyboardEventAck) {
EXPECT_EQ(3u, result_ids_.size()); EXPECT_EQ(3u, result_ids_.size());
} }
IN_PROC_BROWSER_TEST_F(SyntheticMouseEventTest, DISABLED_MouseEventAck) { IN_PROC_BROWSER_TEST_F(SyntheticMouseEventTest, MouseEventAck) {
NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
Attach(); Attach();
ASSERT_TRUE(content::ExecuteScript( ASSERT_TRUE(content::ExecuteScript(
shell()->web_contents()->GetRenderViewHost(), shell()->web_contents()->GetRenderViewHost(),
"document.body.addEventListener('mousemove', () => {debugger;});")); "document.body.addEventListener('mousedown', () => {debugger;});"));
auto filter = std::make_unique<InputMsgWatcher>( auto filter = std::make_unique<InputMsgWatcher>(
RenderWidgetHostImpl::From( RenderWidgetHostImpl::From(
shell()->web_contents()->GetRenderViewHost()->GetWidget()), shell()->web_contents()->GetRenderViewHost()->GetWidget()),
blink::WebInputEvent::kMouseMove); blink::WebInputEvent::kMouseDown);
SendCommand("Debugger.enable", nullptr); SendCommand("Debugger.enable", nullptr);
SendMouseEvent("mouseMoved", 15, 15, false); SendMouseEvent("mousePressed", 15, 15, "left", false);
// We expect that the debugger message event arrives *before* the input // We expect that the debugger message event arrives *before* the input
// event ack, and the subsequent command response for // event ack, and the subsequent command response for
......
...@@ -66,7 +66,7 @@ int GetEventModifiers(int modifiers, ...@@ -66,7 +66,7 @@ int GetEventModifiers(int modifiers,
bool auto_repeat, bool auto_repeat,
bool is_keypad, bool is_keypad,
int location) { int location) {
int result = 0; int result = blink::WebInputEvent::kFromDebugger;
if (auto_repeat) if (auto_repeat)
result |= blink::WebInputEvent::kIsAutoRepeat; result |= blink::WebInputEvent::kIsAutoRepeat;
if (is_keypad) if (is_keypad)
...@@ -293,6 +293,9 @@ void InputHandler::OnInputEvent(const blink::WebInputEvent& event) { ...@@ -293,6 +293,9 @@ void InputHandler::OnInputEvent(const blink::WebInputEvent& event) {
void InputHandler::OnInputEventAck(InputEventAckSource source, void InputHandler::OnInputEventAck(InputEventAckSource source,
InputEventAckState state, InputEventAckState state,
const blink::WebInputEvent& event) { const blink::WebInputEvent& event) {
if ((event.GetModifiers() & blink::WebInputEvent::kFromDebugger) == 0)
return;
if (blink::WebInputEvent::IsKeyboardEventType(event.GetType()) && if (blink::WebInputEvent::IsKeyboardEventType(event.GetType()) &&
!pending_key_callbacks_.empty()) { !pending_key_callbacks_.empty()) {
pending_key_callbacks_.front()->sendSuccess(); pending_key_callbacks_.front()->sendSuccess();
......
...@@ -246,6 +246,11 @@ class WebInputEvent { ...@@ -246,6 +246,11 @@ class WebInputEvent {
// not actual physical movement of the pointer // not actual physical movement of the pointer
kRelativeMotionEvent = 1 << 22, kRelativeMotionEvent = 1 << 22,
// Indication this event was injected by the devtools.
// TODO(dtapuska): Remove this flag once we are able to bind callbacks
// in event sending.
kFromDebugger = 1 << 23,
// The set of non-stateful modifiers that specifically change the // The set of non-stateful modifiers that specifically change the
// interpretation of the key being pressed. For example; IsLeft, // interpretation of the key being pressed. For example; IsLeft,
// IsRight, IsComposing don't change the meaning of the key // IsRight, IsComposing don't change the meaning of the key
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment