summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/wpt/pointerlock/pointerevent_movementxy-manual.html
blob: 5b0edd3c61da0bf817cf2e53bab2a564013872fa (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
93
94
95
96
97
98
99
<!doctype html>
<html>
    <head>
        <title>Pointer Events properties tests</title>
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
        <!-- Additional helper script for common checks across event types -->
        <script type="text/javascript" src="../pointerevent_support.js"></script>
        <style>
          #testContainer {
            touch-action: none;
            user-select: none;
            position: relative;
          }
          #box1 {
            top: 30px;
            left: 50px;
            background: black;
          }
          #box2 {
            top: 70px;
            left: 250px;
            background: red;
          }
          #innerFrame {
            top: 10px;
            left: 100px;
          }
          #square2 {
            visibility: block;
          }
        </style>
        <script>
            var expectedPointerId = NaN;
            var startSummation = false;
            var lastScreenX = 0;
            var lastScreenY = 0;

            function resetTestState() {
                startSummation = false;
                lastScreenX = 0;
                lastScreenY = 0;
            }

            function run() {
                var test_pointerEvent = setup_pointerevent_test("pointerevent attributes", ['mouse', 'touch']);

                [document, document.getElementById('innerFrame').contentDocument].forEach(function(element) {
                  on_event(element, 'pointermove', function (event) {
                    if (startSummation) {
                      test_pointerEvent.step(function() {
                        assert_equals(event.movementX, event.screenX - lastScreenX, "movementX should be the delta between current event's and last event's screenX");
                        assert_equals(event.movementY, event.screenY - lastScreenY, "movementY should be the delta between current event's and last event's screenY");
                      });
                      lastScreenX = event.screenX;
                      lastScreenY = event.screenY;
                    }
                  });
                });
                on_event(document.querySelector('#box1'), 'pointerdown', function(event) {
                  event.target.releasePointerCapture(event.pointerId);
                  test_pointerEvent.step(function() {
                      assert_equals(event.pointerType, expectedPointerType, "Use the instructed pointer type.");
                  });
                  startSummation = true;
                  lastScreenX = event.screenX;
                  lastScreenY = event.screenY;
                });
                on_event(document.querySelector('#box2'), 'pointerup', function(event) {
                  startSummation = false;
                  test_pointerEvent.done();
                });
            }
        </script>
    </head>
    <body onload="run()">
        <h1>Pointer Events movementX/Y attribute test</h1>
        <h2 id="pointerTypeDescription"></h2>
        <h4>
            Test Description: This test checks the properties of pointer events that do not support hover.
            <ol>
                 <li>Press down on the black square.</li>
                 <li>Move your pointer  slowly along a straight line to the red square.</li>
                 <li>Release the pointer when you are over the red square.</li>
            </ol>

            Test passes if the proper behavior of the events is observed.
        </h4>
        <div id="testContainer">
            <div id="box1" class="square"></div>
            <div id="box2" class="square"></div>
            <iframe id="innerFrame" src="resources/pointerevent_movementxy-iframe.html"></iframe>
        </div>
        <div class="spacer"></div>
    </body>
</html>