Bug 1299195 - [Pointer Events] Filter double click event (input source=touch) to prevent dispatching extra mousedown and pointerdown events to content. r=kats

--HG--
rename : gfx/layers/apz/test/mochitest/test_bug1285070.html => gfx/layers/apz/test/mochitest/test_group_pointerevents.html
extra : rebase_source : cc47f2ead72bf332faac2b5a76b45036e5085937
This commit is contained in:
Stone Shih 2016-09-20 10:48:11 +08:00
parent 783b510c3c
commit 2df4b9dc8d
4 changed files with 52 additions and 3 deletions

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test pointer events are dispatched once for touch tap</title>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script type="application/javascript">
/** Test for Bug 1299195 **/
function runTests() {
let target0 = document.getElementById("target0");
let mouseup_count = 0;
let mousedown_count = 0;
let pointerup_count = 0;
let pointerdown_count = 0;
target0.addEventListener("mouseup", () => {
++mouseup_count;
if (mouseup_count == 2) {
is(mousedown_count, 2, "Double tap with touch should fire 2 mousedown events");
is(mouseup_count, 2, "Double tap with touch should fire 2 mouseup events");
is(pointerdown_count, 2, "Double tap with touch should fire 2 pointerdown events");
is(pointerup_count, 2, "Double tap with touch should fire 2 pointerup events");
subtestDone();
}
});
target0.addEventListener("mousedown", () => {
++mousedown_count;
});
target0.addEventListener("pointerup", () => {
++pointerup_count;
});
target0.addEventListener("pointerdown", () => {
++pointerdown_count;
});
synthesizeNativeTap(document.getElementById('target0'), 100, 100);
synthesizeNativeTap(document.getElementById('target0'), 100, 100);
}
waitUntilApzStable().then(runTests);
</script>
</head>
<body>
<div id="target0" style="width: 200px; height: 200px; background: green"></div>
</body>
</html>

View File

@ -29,6 +29,7 @@ support-files =
helper_touch_action_complex.html
helper_tap_fullzoom.html
helper_bug1162771.html
helper_bug1299195.html
tags = apz
[test_bug982141.html]
[test_bug1151663.html]
@ -63,7 +64,7 @@ skip-if = (toolkit == 'android') || (toolkit == 'cocoa') # wheel events not supp
skip-if = (os == 'android') || (os == 'b2g') # uses wheel events which are not supported on mobile
[test_group_zoom.html]
skip-if = (toolkit != 'android') # only android supports zoom
[test_bug1285070.html]
[test_group_pointerevents.html]
# Windows touch injection doesn't work in automation, but this test can be run locally on a windows touch device.
# On OS X we don't support touch events at all.
skip-if = (toolkit == 'windows') || (toolkit == 'cocoa')

View File

@ -12,7 +12,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1285070
<script type="application/javascript">
var subtests = [
{'file': 'helper_bug1285070.html', 'prefs': [["dom.w3c_pointer_events.enabled", true]]}
{'file': 'helper_bug1285070.html', 'prefs': [["dom.w3c_pointer_events.enabled", true]]},
{'file': 'helper_bug1299195.html', 'prefs': [["dom.w3c_pointer_events.enabled", true]]}
];
if (isApzEnabled()) {

View File

@ -1143,7 +1143,7 @@ WinUtils::GetIsMouseFromTouch(EventMessage aEventMessage)
const uint32_t MOZ_T_I_SIGNATURE = TABLET_INK_TOUCH | TABLET_INK_SIGNATURE;
const uint32_t MOZ_T_I_CHECK_TCH = TABLET_INK_TOUCH | TABLET_INK_CHECK;
return ((aEventMessage == eMouseMove || aEventMessage == eMouseDown ||
aEventMessage == eMouseUp) &&
aEventMessage == eMouseUp || aEventMessage == eMouseDoubleClick) &&
(GetMessageExtraInfo() & MOZ_T_I_SIGNATURE) == MOZ_T_I_CHECK_TCH);
}