summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/deviceproperties/pointer-event-has-device-properties-uniqueid-from-pointer-event-init.tentative.html
blob: a37df4b4214501d4f7e5e7803ecfd3672c91b591 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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>