summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/deviceproperties/get-device-properties-uniqueid-from-pointer-event.tentative.html
blob: dc6b9379c11403baab12d5ac65032bdd766b1643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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>