Skip to content

Commit f821fa7

Browse files
sahirvchromium-wpt-export-bot
authored andcommitted
Introduce PointerEvent.deviceProperties
This change replaces deviceId on the PointerEvent interface with a new interface, deviceProperties. DeviceProperties contains one member, uniqueId, which functionally behaves the same as the outgoing deviceId. Spec: w3c/pointerevents#495 This change also removes the setting of deviceId when creating a PointerCancel event, as there is no current application for device/unique id for a PointerCancel. Bug: 330760871 Change-Id: I0f1a9f7d5589f790d94f498a38bfdf55b6f51073
1 parent 99147c8 commit f821fa7

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<script src="/resources/testdriver.js"></script>
5+
<script src="/resources/testdriver-actions.js"></script>
6+
<script src="/resources/testdriver-vendor.js"></script>
7+
8+
<style>
9+
div {
10+
user-select: none; // Prevents text selection on drag.
11+
}
12+
</style>
13+
<div id="logger" draggable="false"></div>
14+
<div id="console"></div>
15+
<!-- This test verifies that if the PointerEventDeviceId flag is enabled,
16+
pointerEvent.deviceProperties.uniqueId is -1. If not, it is undefined. -->
17+
<script>
18+
function CheckDeviceId(event) {
19+
eventFired++;
20+
assert_equals(event.deviceProperties.uniqueId, -1, "deviceId is -1");
21+
}
22+
23+
window.addEventListener("pointerdown", CheckDeviceId, false);
24+
window.addEventListener("pointermove", CheckDeviceId, false);
25+
26+
promise_test(async () => {
27+
if (!window.internals)
28+
return;
29+
eventFired = 0;
30+
let actions = new test_driver.Actions()
31+
.addPointer("TestPointer", "pen")
32+
.pointerDown()
33+
.pointerMove(100, 100)
34+
.pointerUp();
35+
36+
await actions.send();
37+
38+
assert_true(eventFired == 2);
39+
}, 'PointerEvent.deviceProperties.uniqueId');
40+
</script>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<div id="console"></div>
5+
6+
<!-- This test verifies that if the kPointerEventDeviceId flag is enabled,
7+
pointerEvent.deviceProperties.uniqueId can be set via PointerEventInit. If not, it is
8+
undefined. -->
9+
<script>
10+
function CheckDeviceId(event) {
11+
assert_equals(event.deviceProperties.uniqueId, 1001, "uniqueId is populated");
12+
}
13+
14+
promise_test(async () => {
15+
if (!window.internals)
16+
return;
17+
var deviceProps = new DeviceProperties({
18+
uniqueId: 1001
19+
});
20+
var downEvent = new PointerEvent("pointerdown",
21+
{pointerId: 1,
22+
bubbles: true,
23+
cancelable: true,
24+
pointerType: "pen",
25+
width: 100,
26+
height: 100,
27+
isPrimary: true,
28+
deviceProperties: deviceProps
29+
});
30+
CheckDeviceId(downEvent);
31+
var moveEvent = new PointerEvent("pointermove",
32+
{pointerId: 1,
33+
bubbles: true,
34+
cancelable: true,
35+
pointerType: "pen",
36+
width: 100,
37+
height: 100,
38+
isPrimary: true,
39+
deviceProperties: deviceProps
40+
});
41+
CheckDeviceId(moveEvent);
42+
var upEvent = new PointerEvent("pointerup",
43+
{pointerId: 1,
44+
bubbles: true,
45+
cancelable: true,
46+
pointerType: "pen",
47+
width: 100,
48+
height: 100,
49+
isPrimary: true,
50+
deviceProperties: deviceProps
51+
});
52+
CheckDeviceId(upEvent);
53+
}, 'PointerEvent.deviceId via PointerEventInit');
54+
</script>

0 commit comments

Comments
 (0)