Commit 5c76d364 authored by lanwei's avatar lanwei Committed by Commit Bot

Do not send fake mousemove event to the DOM

We send a fake mousemove event to check if there is any change of the
element underneath the mouse cursor, but we should not send the mousemove
event to the DOM, because the mouse does not move.

Bug: 333623
Change-Id: I037ce8f56605afc4b21031095425bdeee8b0aa0c
Reviewed-on: https://chromium-review.googlesource.com/537514Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481919}
parent 18c51c84
......@@ -26,7 +26,7 @@ eventSender.mouseMoveTo(10, 10);
const testCases = {
'contextmenu': _ => eventSender.gestureTwoFingerTap(10, 10), // contextmenu event dispatched as a result of two finger tap
'mousemove': _ => document.scrollingElement.scrollTop = 400 // mousemove dispatched as a result of scrolling (with 100ms delay)
'scroll': _ => document.scrollingElement.scrollTop = 400 // scroll dispatched as a result of scrolling (with 100ms delay)
};
for (let eventName in testCases)
......
<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<style type="text/css">
#test {
width: 250px;
height: 250px;
background-color: red;
}
</style>
<body>
<div id="test">
<script type="text/javascript">
var mouse_move_count = 0;
var last_mouse_position_x = 0;
var last_mouse_position_y = 0;
var test = document.getElementById("test");
var targetRect = test.getBoundingClientRect();
var offset = 100;
var x = targetRect.left + offset;
var y = targetRect.top + offset;
function mouseMoveHandler(event) {
mouse_move_count++;
test.style.display = 'none';
document.elementFromPoint(event.clientX, event.clientY);
test.style.display = 'block';
testNoMouseMove.step(function () {
assert_not_equals(last_mouse_position_x, event.clientX);
assert_not_equals(last_mouse_position_y, event.clientY);
});
last_mouse_position_x = event.clientX;
last_mouse_position_y = event.clientY;
}
function callbackValidMouseMove() {
testNoMouseMove.step(function () {
assert_equals(1, mouse_move_count);
});
testNoMouseMove.done();
}
function testNoMouseMoveActions() {
if (window.chrome && chrome.gpuBenchmarking) {
var pointerActions =
[{source: "mouse",
actions: [
{ name: "pointerMove", x: x, y: y },
{ name: 'pause', duration: 1 }]}];
chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackValidMouseMove);
}
}
var testNoMouseMove = async_test('Tests that no mousemove event is fired after the mouse moves over to the red area and does not move any more.');
test.addEventListener('mousemove', mouseMoveHandler);
testNoMouseMoveActions();
</script>
</body>
pointermove
mousemove
pointermove
mousemove
Verifies that fake mouse events have correct pointer type for pointer events.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......@@ -10,8 +8,6 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
--- move mouse into target ---
1 Received pointermove mouse
2 Received mousemove
3 Received pointermove mouse
4 Received mousemove
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -18,14 +18,17 @@ async_test(function(t) {
eventSender.gestureShowPress(coords[0], coords[1]);
eventSender.gestureTap(coords[0], coords[1]);
assert_false(video.paused);
assert_true(isControlsPanelVisible(video));
// And then hover the control with the mouse.
eventSender.mouseMoveTo(0, 0);
eventSender.mouseMoveTo(coords[0], coords[1]);
// And the controls should remain visible.
runAfterHideMediaControlsTimerFired(t.step_func_done(function() {
assert_true(isControlsPanelVisible(video));
// And then hover the control with the mouse.
eventSender.mouseMoveTo(0, 0);
eventSender.mouseMoveTo(coords[0], coords[1]);
// And the controls should remain visible.
runAfterHideMediaControlsTimerFired(t.step_func_done(function() {
assert_true(isControlsPanelVisible(video));
}), video);
}), video);
});
......
......@@ -519,6 +519,14 @@ WebInputEventResult PointerEventManager::SendMousePointerEvent(
EventTarget* effective_target = GetEffectiveTargetForPointerEvent(
pointer_event_target, pointer_event->pointerId());
// Do not send the fake mouse move event to the DOM, because the mouse does
// not move.
if ((mouse_event_type == EventTypeNames::mousemove) &&
mouse_event.GetModifiers() &
WebInputEvent::Modifiers::kRelativeMotionEvent) {
return WebInputEventResult::kNotHandled;
}
WebInputEventResult result =
DispatchPointerEvent(effective_target, pointer_event);
......
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