mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-01 08:48:25 +02:00
Bug 1959016 - Add WPT to check attributes of a coalesced event of pointerrawupdate r=smaug
There is not test to check `getCoalescedEvents()` of `pointerrawupdate` event so that this add tests for that. Then, I find our bugs: * `.button` value of `pointerrawupdate` event caused by a `mousemove` * `.button` value of coalesced `pointermove` event caused by `mousemove` This patch fixes these bugs too. Differential Revision: https://phabricator.services.mozilla.com/D256224
This commit is contained in:
parent
351fcb86b1
commit
c7bdca40a7
6 changed files with 118 additions and 3 deletions
|
|
@ -38,9 +38,9 @@ SimpleTest.waitForFocus(async () => {
|
|||
function stringifyPointerEvent(event) {
|
||||
return `{ screenX: ${event.screenX}, screenY: ${
|
||||
event.screenY
|
||||
}, clientX: ${event.clientX}, clientY:${event.clientY}, buttons:${
|
||||
event.buttons
|
||||
} }`;
|
||||
}, clientX: ${event.clientX}, clientY:${event.clientY}, button:${
|
||||
event.button
|
||||
}, buttons:${event.buttons} }`;
|
||||
}
|
||||
|
||||
const allEvents = [];
|
||||
|
|
@ -84,6 +84,9 @@ SimpleTest.waitForFocus(async () => {
|
|||
for (const event of allEvents) {
|
||||
info(`${event.type}: ${stringifyPointerEvent(event)}`);
|
||||
}
|
||||
for (const event of coalescedPointerMoveEvents) {
|
||||
info(`Coalesced ${event.type}: ${stringifyPointerEvent(event)}`);
|
||||
}
|
||||
|
||||
ok(!!pointerRawUpdateEvents.length, "At least one pointerrawupdate event should be fired");
|
||||
is(
|
||||
|
|
|
|||
|
|
@ -1604,6 +1604,11 @@ void BrowserChild::HandleMouseRawUpdateEvent(
|
|||
}
|
||||
WidgetMouseEvent mouseRawUpdateEvent(aPendingMouseEvent);
|
||||
mouseRawUpdateEvent.mMessage = eMouseRawUpdate;
|
||||
// PointerEvent.button should always be -1 if the source event is eMouseMove.
|
||||
// PointerEventHandler cannot distinguish whether it's caused by
|
||||
// eMouseDown/eMouseUp or eMouseMove. Therefore, we need to set -1
|
||||
// (eNotPressed) here.
|
||||
mouseRawUpdateEvent.mButton = MouseButton::eNotPressed;
|
||||
mouseRawUpdateEvent.mCoalescedWidgetEvents = nullptr;
|
||||
mouseRawUpdateEvent.convertToPointer = true;
|
||||
// Nobody checks `convertToPointerRawUpdate` of eMouseRawUpdate event.
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ void CoalescedMouseData::Coalesce(const WidgetMouseEvent& aEvent,
|
|||
aEvent);
|
||||
|
||||
event->mMessage = ePointerMove;
|
||||
event->mButton = MouseButton::eNotPressed;
|
||||
event->mPressure = aEvent.ComputeMouseButtonPressure();
|
||||
event->mFlags.mBubbles = false;
|
||||
event->mFlags.mCancelable = false;
|
||||
|
|
|
|||
|
|
@ -7619,6 +7619,15 @@ nsresult PresShell::EnsurePrecedingPointerRawUpdate(
|
|||
WidgetMouseEvent mouseRawUpdateEvent(*mouseEvent);
|
||||
mouseRawUpdateEvent.mMessage = eMouseRawUpdate;
|
||||
mouseRawUpdateEvent.mCoalescedWidgetEvents = nullptr;
|
||||
// PointerEvent.button of `pointerrawupdate` should always be -1 if the
|
||||
// source event is not eMouseDown nor eMouseUp. PointerEventHandler cannot
|
||||
// distinguish whether eMouseRawUpdate is caused by eMouseDown/eMouseUp or
|
||||
// not. Therefore, we need to set the proper value in the latter case here
|
||||
// (In the former case, the copy constructor did it already).
|
||||
if (mouseEvent->mMessage != eMouseDown &&
|
||||
mouseEvent->mMessage != eMouseUp) {
|
||||
mouseRawUpdateEvent.mButton = MouseButton::eNotPressed;
|
||||
}
|
||||
nsEventStatus rawUpdateStatus = nsEventStatus_eIgnore;
|
||||
EventHandler eventHandler(*this);
|
||||
return eventHandler.HandleEvent(aWeakFrameForPresShell,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
[pointerevent_pointerrawupdate_coalesced_events_attributes.https.html?touch]
|
||||
|
||||
[pointerevent_pointerrawupdate_coalesced_events_attributes.https.html?mouse]
|
||||
|
||||
[pointerevent_pointerrawupdate_coalesced_events_attributes.https.html?pen]
|
||||
[Simple test for getCoalescedEvents() of `pointerrawupdate`]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="variant" content="?mouse">
|
||||
<meta name="variant" content="?touch">
|
||||
<meta name="variant" content="?pen">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<title>Simple test for getCoalescedEvents() of `pointerrawupdate`</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<style>
|
||||
div#target {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
addEventListener("load", () => {
|
||||
promise_test(async () => {
|
||||
const target = document.getElementById("target");
|
||||
const compAttrs = [
|
||||
"target",
|
||||
"screenX", "screenY",
|
||||
"clientX", "clientY",
|
||||
"button", "buttons",
|
||||
"pointerId", "pointerType",
|
||||
"shiftKey", "ctrlKey", "altKey", "metaKey",
|
||||
];
|
||||
const waitForAssert = new Promise(resolve => {
|
||||
target.addEventListener("pointerrawupdate", pointerRawUpdateEvent => {
|
||||
const coalescedEvents = pointerRawUpdateEvent.getCoalescedEvents();
|
||||
test(() => {
|
||||
assert_equals(coalescedEvents.length, 1);
|
||||
}, "getCoalescedEvents() of pointerrawupdate should return one event");
|
||||
const coalescedRawEvent = coalescedEvents[0];
|
||||
test(() => {
|
||||
assert_equals(coalescedRawEvent.type, "pointerrawupdate");
|
||||
}, 'type should be "pointerrawupdate"');
|
||||
test(() => {
|
||||
assert_true(coalescedRawEvent.isTrusted);
|
||||
}, "isTrusted should be true");
|
||||
test(() => {
|
||||
assert_false(coalescedRawEvent.bubbles);
|
||||
}, "bubbles should be false");
|
||||
test(() => {
|
||||
assert_false(coalescedRawEvent.cancelable);
|
||||
}, "cancelable should be false");
|
||||
for (const attr of compAttrs) {
|
||||
test(() => {
|
||||
assert_equals(coalescedRawEvent[attr], pointerRawUpdateEvent[attr]);
|
||||
}, `${attr} should be same as the pointerrawupdate event`);
|
||||
}
|
||||
target.addEventListener("pointermove", pointerMoveEvent => {
|
||||
const firstCoalescedMoveEvent = pointerMoveEvent.getCoalescedEvents()[0];
|
||||
for (const attr of compAttrs) {
|
||||
test(() => {
|
||||
assert_equals(coalescedRawEvent[attr], firstCoalescedMoveEvent[attr]);
|
||||
}, `${attr} should be same as the corresponding pointermove event`);
|
||||
}
|
||||
resolve();
|
||||
}, {once: true});
|
||||
}, {once: true});
|
||||
});
|
||||
const shiftKey = "\uE008";
|
||||
await new test_driver.Actions()
|
||||
.addPointer("TestPointer", location.search.substring(1))
|
||||
.pointerMove(0, 0, {origin: document.getElementById("init")})
|
||||
.keyDown(shiftKey)
|
||||
.pointerMove(0, 0, {origin: target})
|
||||
.pointerDown()
|
||||
.pointerMove(1, 1, {origin: target})
|
||||
.pointerUp()
|
||||
.keyUp(shiftKey)
|
||||
.send();
|
||||
await waitForAssert;
|
||||
});
|
||||
}, {once: true});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="init">start</div>
|
||||
<div id="target"></div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue