зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1509710 - Prevent dispatching pointermove events targeted at a slider frame to web content, if the scrollbar is being dragged; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D102935
This commit is contained in:
Родитель
9b0eb6b20d
Коммит
b9bee2d7ae
|
@ -114,3 +114,5 @@ support-files =
|
|||
file_pointercapture_xorigin_iframe.html
|
||||
file_pointercapture_xorigin_iframe_pointerlock.html
|
||||
[test_pointercapture_remove_iframe.html]
|
||||
[test_pointermove_drag_scrollbar.html]
|
||||
skip-if = os == 'android' # scrollbar not showed on mobile
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1509710
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1509710</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style>
|
||||
#scroll {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
overflow: scroll;
|
||||
}
|
||||
#scrolled {
|
||||
width: 200px;
|
||||
height: 1000px; /* so the subframe has room to scroll */
|
||||
will-change: transform; /* to force active layers */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1509710">Mozilla Bug 1509710</a>
|
||||
<p id="display"></p>
|
||||
<div id="scroll">
|
||||
<div id="scrolled"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
/** Test for Bug 1509710 **/
|
||||
add_task(async function test_pointer_mouse_event() {
|
||||
await SimpleTest.promiseFocus();
|
||||
|
||||
let subframe = document.getElementById("scroll");
|
||||
if (subframe.clientWidth == 200) {
|
||||
// No scrollbar, abort the test. This can happen e.g. on local macOS runs
|
||||
// with OS settings to only show scrollbars on trackpad/mouse activity.
|
||||
ok(false, "No scrollbars found, cannot run this test!");
|
||||
return;
|
||||
}
|
||||
|
||||
let receivedEvent = {};
|
||||
let handler = function(e) {
|
||||
receivedEvent[e.type] = true;
|
||||
};
|
||||
subframe.addEventListener("pointerdown", handler);
|
||||
subframe.addEventListener("pointermove", handler);
|
||||
subframe.addEventListener("pointerup", handler);
|
||||
subframe.addEventListener("mousedown", handler);
|
||||
subframe.addEventListener("mousemove", handler);
|
||||
subframe.addEventListener("mouseup", handler);
|
||||
|
||||
// synthesize mouse actions on scrollbar.
|
||||
let scrollbarX = (200 + subframe.clientWidth) / 2;
|
||||
synthesizeMouse(subframe, scrollbarX, 30, { type: "mousedown" });
|
||||
synthesizeMouse(subframe, scrollbarX, 40, { type: "mousemove" });
|
||||
synthesizeMouse(subframe, scrollbarX, 40, { type: "mouseup" });
|
||||
|
||||
await new Promise(SimpleTest.executeSoon);
|
||||
|
||||
// Test pointer event
|
||||
ok(receivedEvent.pointerdown, "should receive pointerdown event");
|
||||
ok(!receivedEvent.pointermove, "should not receive pointermove event");
|
||||
ok(receivedEvent.pointerup, "should receive pointerup event");
|
||||
|
||||
// Test mouse event
|
||||
ok(receivedEvent.mousedown, "should receive mousedown event");
|
||||
ok(!receivedEvent.mousemove, "should not receive mousemove event");
|
||||
ok(receivedEvent.mouseup, "should receive mouseup event");
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1460,11 +1460,11 @@ void nsSliderFrame::UnsuppressDisplayport() {
|
|||
}
|
||||
|
||||
bool nsSliderFrame::OnlySystemGroupDispatch(EventMessage aMessage) const {
|
||||
// If we are in a native anonymous subtree, do not dispatch mouse-move events
|
||||
// targeted at this slider frame to web content. This matches the behaviour
|
||||
// of other browsers.
|
||||
return aMessage == eMouseMove && isDraggingThumb() &&
|
||||
GetContent()->IsInNativeAnonymousSubtree();
|
||||
// If we are in a native anonymous subtree, do not dispatch mouse-move or
|
||||
// pointer-move events targeted at this slider frame to web content. This
|
||||
// matches the behaviour of other browsers.
|
||||
return (aMessage == eMouseMove || aMessage == ePointerMove) &&
|
||||
isDraggingThumb() && GetContent()->IsInNativeAnonymousSubtree();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsSliderMediator, nsIDOMEventListener)
|
||||
|
|
Загрузка…
Ссылка в новой задаче