summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/pointerlock/pointerevent_getPredictedEvents_when_pointerlocked-manual.html
blob: aba08f14b80b037b297adf7b67f749374ac1397f (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
<!doctype html>
<html>
    <head>
        <title>Pointer Events pointer lock 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>
        <script type="text/javascript" src="pointerevent_support.js"></script>
        <style>
          #testContainer {
            touch-action: none;
            user-select: none;
            position: relative;
          }
        </style>
        <script>
            var lock_change_count = 0;
            var move_event_count = 0;
            var mouseeventMovements = []
            var pointereventMovements = []

            function resetTestState() {
            }

            function run() {
                var test_pointerEvent = setup_pointerevent_test("pointermove getPredictedEvents when lock test", ['mouse']);
                var div1 = document.getElementById("target");

                on_event(div1, 'pointerdown', function(event) {
                    div1.requestPointerLock();
                });
                on_event(div1, 'pointermove', function(event) {
                    if (document.pointerLockElement == div1) {
                        test_pointerEvent.step(function() {
                            if (event.getPredictedEvents().length > 0) {
                                 for (var i=0; i<event.getPredictedEvents().length; i++) {
                                    var predictedEvent = event.getPredictedEvents()[i];
                                    test_pointerEvent.step(function() {
                                        assert_equals(predictedEvent.pointerId, event.pointerId, "getPredictedEvents()[" + i + "].pointerId");
                                        assert_equals(predictedEvent.pointerType, event.pointerType, "getPredictedEvents()[" + i + "].pointerType");
                                        assert_equals(predictedEvent.target, document.pointerLockElement, "getPredictedEvents()[" + i + "].target");
                                        assert_equals(predictedEvent.clientX, event.clientX, "getPredictedEvents()[" + i + "].clientX");
                                        assert_equals(predictedEvent.clientY, event.clientY, "getPredictedEvents()[" + i + "].clientY");
                                    });
                                }
                                document.exitPointerLock();
                                test_pointerEvent.done();
                            } else {
                                assert_less_than(++move_event_count, 20, "pointermove have no predicted event in 20 moves")
                            }
                        });
                    }
                });
            }
        </script>
    </head>
    <body onload="run()">
        <h1>PointerMove getPredictedEvent in locked state test</h1>
        <h2 id="pointerTypeDescription"></h2>
        <h4>
            Test Description: This test checks if pointerevent.getPredictedEvent work correctly when pointer is locked.
            <ol>
                 <li>Press left button down on the green rectangle to lock pointer.</li>
                 <li>Move the mouse</li>
            </ol>
            </ol>

            Test passes if the proper behavior of the events is observed.
        </h4>
        <div id="testContainer">
            <div id="target" style="width:800px;height:250px;background:green"></div>
        </div>
        <div class="spacer"></div>
    </body>
</html>