summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/deviceproperties
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /testing/web-platform/tests/pointerevents/deviceproperties
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/pointerevents/deviceproperties')
-rw-r--r--testing/web-platform/tests/pointerevents/deviceproperties/get-device-properties-uniqueid-from-pointer-event.tentative.html45
-rw-r--r--testing/web-platform/tests/pointerevents/deviceproperties/pointer-event-has-device-properties-uniqueid-from-pointer-event-init.tentative.html92
-rw-r--r--testing/web-platform/tests/pointerevents/deviceproperties/unique-id-is-unique-manual.tentative.html142
3 files changed, 279 insertions, 0 deletions
diff --git a/testing/web-platform/tests/pointerevents/deviceproperties/get-device-properties-uniqueid-from-pointer-event.tentative.html b/testing/web-platform/tests/pointerevents/deviceproperties/get-device-properties-uniqueid-from-pointer-event.tentative.html
new file mode 100644
index 0000000000..dc6b9379c1
--- /dev/null
+++ b/testing/web-platform/tests/pointerevents/deviceproperties/get-device-properties-uniqueid-from-pointer-event.tentative.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<!--
+ Tentative; contingent on merge of:
+ https://github.com/w3c/pointerevents/pull/495
+-->
+<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 {
+ user-select: none; // Prevents text selection on drag.
+ }
+</style>
+<div id="logger" draggable="false"></div>
+<div id="console"></div>
+<!-- This test verifies that pointerEvent.deviceProperties.uniqueId is 0
+ by default for a pointer with an invalid hardware id - in this case
+ a testdriver generated event, which does not support hardware id. -->
+<script>
+ function CheckDeviceId(event) {
+ eventFired++;
+ assert_equals(event.deviceProperties.uniqueId, 0, "deviceId is 0");
+ }
+
+ window.addEventListener("pointerdown", CheckDeviceId, false);
+ window.addEventListener("pointermove", CheckDeviceId, false);
+
+ promise_test(async () => {
+ if (!window.internals)
+ return;
+ eventFired = 0;
+ let actions = new test_driver.Actions()
+ .addPointer("TestPointer", "pen")
+ .pointerDown()
+ .pointerMove(100, 100)
+ .pointerUp();
+
+ await actions.send();
+
+ assert_true(eventFired == 2);
+ }, 'PointerEvent.deviceProperties.uniqueId');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/pointerevents/deviceproperties/pointer-event-has-device-properties-uniqueid-from-pointer-event-init.tentative.html b/testing/web-platform/tests/pointerevents/deviceproperties/pointer-event-has-device-properties-uniqueid-from-pointer-event-init.tentative.html
new file mode 100644
index 0000000000..a37df4b421
--- /dev/null
+++ b/testing/web-platform/tests/pointerevents/deviceproperties/pointer-event-has-device-properties-uniqueid-from-pointer-event-init.tentative.html
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<!--
+ Tentative; contingent on merge of:
+ https://github.com/w3c/pointerevents/pull/495
+-->
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="console"></div>
+
+<!-- This test verifies that pointerEvent.deviceProperties.uniqueId
+ can be set via PointerEventInit. -->
+<script>
+ const UNIQUE_ID = 1001;
+ const INVALID_UNIQUE_ID = 0;
+
+ function CheckDeviceId(event, uniqueId) {
+ assert_equals(event.deviceProperties.uniqueId, uniqueId, "uniqueId is populated");
+ }
+
+ promise_test(async () => {
+ if (!window.internals)
+ return;
+ var deviceProps = new DeviceProperties({
+ uniqueId: 1001
+ });
+ var downEvent = new PointerEvent("pointerdown",
+ {pointerId: 1,
+ bubbles: true,
+ cancelable: true,
+ pointerType: "pen",
+ width: 100,
+ height: 100,
+ isPrimary: true,
+ deviceProperties: deviceProps
+ });
+ CheckDeviceId(downEvent, UNIQUE_ID);
+ var moveEvent = new PointerEvent("pointermove",
+ {pointerId: 1,
+ bubbles: true,
+ cancelable: true,
+ pointerType: "pen",
+ width: 100,
+ height: 100,
+ isPrimary: true,
+ deviceProperties: deviceProps
+ });
+ CheckDeviceId(moveEvent, UNIQUE_ID);
+ var upEvent = new PointerEvent("pointerup",
+ {pointerId: 1,
+ bubbles: true,
+ cancelable: true,
+ pointerType: "pen",
+ width: 100,
+ height: 100,
+ isPrimary: true,
+ deviceProperties: deviceProps
+ });
+ CheckDeviceId(upEvent, UNIQUE_ID);
+ }, 'PointerEvent.deviceProperties via DevicePropertiesInit');
+
+ promise_test(async () => {
+ if (!window.internals)
+ return;
+ var emptyDeviceProps = new DeviceProperties({});
+ var downEventEmptyProps = new PointerEvent("pointerdown",
+ {pointerId: 1,
+ bubbles: true,
+ cancelable: true,
+ pointerType: "pen",
+ width: 100,
+ height: 100,
+ isPrimary: true,
+ deviceProperties: emptyDeviceProps
+ });
+ CheckDeviceId(downEventEmptyProps, INVALID_UNIQUE_ID);
+ }, 'PointerEvent.deviceProperties via empty DevicePropertiesInit');
+
+ promise_test(async () => {
+ if (!window.internals)
+ return;
+ var downEventEmptyProps = new PointerEvent("pointerdown",
+ {pointerId: 1,
+ bubbles: true,
+ cancelable: true,
+ pointerType: "pen",
+ width: 100,
+ height: 100,
+ isPrimary: true,
+ });
+ CheckDeviceId(downEventEmptyProps, INVALID_UNIQUE_ID);
+ }, 'No deviceProperties in PointerEventInit');
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/pointerevents/deviceproperties/unique-id-is-unique-manual.tentative.html b/testing/web-platform/tests/pointerevents/deviceproperties/unique-id-is-unique-manual.tentative.html
new file mode 100644
index 0000000000..55db05353f
--- /dev/null
+++ b/testing/web-platform/tests/pointerevents/deviceproperties/unique-id-is-unique-manual.tentative.html
@@ -0,0 +1,142 @@
+<!DOCTYPE html>
+<!--
+ Tentative; contingent on merge of:
+ https://github.com/w3c/pointerevents/pull/495
+
+ This manual test validates the behavior of PointerEvent.deviceProperties.uniqueId.
+ Specifically, this test ensures that pointing devices get their own unique id, and
+ that the unique id is persistent over the session.
+
+ In order to run this test, it is necessary to have multiple pointing devices; such as a
+ pen and a mouse. Please follow the instructions exactly as written in order to ensure
+ the correct results are obtained.
+-->
+<title>DeviceProperties.uniqueId is unique for pointer events from different devices</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ #instructions {
+ display: inline-block;
+ border-right: 1px solid black;
+ padding-right: 10px;
+ width: 600px;
+ }
+ #testcontainer {
+ display: inline-block;
+ width: 300px;
+ touch-action: none;
+ }
+
+ #currentuniqueid {
+ display: inline-block;
+ }
+
+ .point1 {
+ height: 50px;
+ width: 50px;
+ background-color: #00eeee;
+ display: inline-block;
+ }
+ .point2 {
+ height: 50px;
+ width: 50px;
+ background-color: #aa33aa;
+ display: inline-block;
+ float: right;
+ }
+
+ .testarea {
+ border: 1px solid #000000;
+ margin-bottom: 50px;
+ width: 100%;
+ }
+
+ p {
+ padding-bottom: 10px;
+ }
+
+ html {
+ font-family: Arial, Helvetica, sans-serif;
+ }
+</style>
+<html>
+<div id="instructions">
+<h2>Instructions</h2>
+<p>1. With one pointing device (pointing device #1), drag the pointer from A to B</p>
+<p>2. With another pointing device (pointing device #2), drag the pointer from C to D</p>
+<p>3. Repeat step 1.</p>
+<p>4. Repeat step 2.</p>
+<p>5. Click finish and verify the test passes. There should be 4 passing test cases. </p>
+</div>
+<div id="testcontainer">
+ <div>
+ Current pointer's unique id: <p id="currentuniqueid"></p>
+ </div>
+ <div class="testarea" id="device1">
+ <div class="point1">A</div>
+ <div class="point2">B</div>
+ </div>
+ <div class="testarea" id="device2">
+ <div class="point1">C</div>
+ <div class="point2">D</div>
+ </div>
+
+ <p>Click on the button below after completing. If a "PASS" result appears the test
+ passes, otherwise it fails</p>
+ <button onclick="Finish()">Finish Test</button>
+</div>
+</html>
+
+<script>
+ let device1Ids = [];
+ let device2Ids = [];
+
+ setup({explicit_timeout: true, explicit_done: true});
+
+ function LogDeviceId(event, list) {
+ if (event.deviceProperties) {
+ const uniqueId = event.deviceProperties.uniqueId;
+ currentuniqueid.innerText = uniqueId ? uniqueId : "Unknown";
+ if (!uniqueId) {
+ return;
+ }
+ list.push(uniqueId);
+ }
+ }
+
+ function LogDeviceId1(event) {
+ LogDeviceId(event, device1Ids);
+ }
+
+ function LogDeviceId2(event) {
+ LogDeviceId(event, device2Ids);
+ }
+
+ function Finish() {
+ let device1UniqueIds = new Set(device1Ids);
+ let device2UniqueIds = new Set(device2Ids);
+
+ test(function () {
+ assert_greater_than(device1Ids.length, 1, "Events from Device 1 have uniqueIds.");
+ assert_equals(device1UniqueIds.size, 1, "Device 1 has a consistent uniqueId.");
+ }, "uniqueId is consistent for device 1");
+ test(function () {
+ assert_greater_than(device2Ids.length, 1, "Events from Device 2 have uniqueIds.");
+ assert_equals(device2UniqueIds.size, 1, "Device 2 has a consistent uniqueId.");
+ }, "uniqueId is consistent for device 2");
+ test(function () {
+ // Ensure the two sets are different.
+ assert_equals(device1UniqueIds.intersection(device2UniqueIds).size, 0, "Device 1 and 2 have different uniqueIds.");
+ }, "uniqueId is unique to device 1 and device 2");
+ done();
+ }
+
+ device1.addEventListener("pointerdown", LogDeviceId1, false);
+ device1.addEventListener("pointermove", LogDeviceId1, false);
+ device1.addEventListener("pointerup", LogDeviceId1, false);
+
+ device2.addEventListener("pointerdown", LogDeviceId2, false);
+ device2.addEventListener("pointermove", LogDeviceId2, false);
+ device2.addEventListener("pointerup", LogDeviceId2, false);
+
+</script>