summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/wpt/pointerevent_boundary_events_in_capturing-manual.html
blob: 0de4d55ed13ed67229cc4a6a0f77635fad815d01 (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
<!doctype html>
<html>
    <head>
        <title>Pointer Events boundary events in capturing 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>
        <script>
            var detected_pointertypes = {};
            var eventList = All_Pointer_Events;
            PhaseEnum = {
              WaitingForDown:       "down",
              WaitingForFirstMove:  "firstMove",
              WaitingForSecondMove: "secondMove",
              WaitingForUp:         "up"
            }
            var phase = PhaseEnum.WaitingForDown;
            var eventsRecieved = [];

            function resetTestState() {
                eventsRecieved = [];
                phase = PhaseEnum.WaitingForDown;
            }
            function run() {
                var test_pointerEvent = setup_pointerevent_test("pointerevent boundary events in capturing", ALL_POINTERS);
                var target = document.getElementById("target0");
                var listener = document.getElementById("listener");

                eventList.forEach(function(eventName) {
                    on_event(target, eventName, function (event) {
                        if (phase == PhaseEnum.WaitingForDown) {
                            if (eventName == 'pointerdown') {
                              listener.setPointerCapture(event.pointerId);
                              phase = PhaseEnum.WaitingForFirstMove;
                            }
                        } else if (phase == PhaseEnum.WaitingForUp) {
                            if (event.type == 'pointerup')
                                test_pointerEvent.done();
                        } else {
                            eventsRecieved.push(event.type + '@target');
                            if (phase == PhaseEnum.WaitingForSecondMove && event.type == 'pointermove') {
                                test(function () {
                                    checkPointerEventType(event);
                                    assert_array_equals(eventsRecieved, ['lostpointercapture@listener', 'pointerout@listener', 'pointerleave@listener', 'pointerover@target', 'pointerenter@target', 'pointermove@target'],
                                        'lostpointercapture and pointerout/leave should be dispatched to the capturing target and pointerover/enter should be dispatched to the hit-test element before the first pointermove event after releasing pointer capture');
                                }, expectedPointerType + " pointer events boundary events when releasing capture"); 
                                phase = PhaseEnum.WaitingForUp;
                            }
                        }
                    });
                    on_event(listener, eventName, function (event) {
                        if (phase == PhaseEnum.WaitingForDown)
                          return;
                        eventsRecieved.push(event.type + '@listener');
                        if (phase == PhaseEnum.WaitingForFirstMove && eventName == 'pointermove') {
                          test(function () {
                              checkPointerEventType(event);
                              assert_array_equals(eventsRecieved, ['pointerout@target', 'pointerleave@target', 'pointerover@listener', 'pointerenter@listener', 'gotpointercapture@listener', 'pointermove@listener'],
                                 'pointerout/leave should be dispatched to the previous target and pointerover/enter and gotpointercapture should be dispatched to the capturing element before the first captured pointermove event');
                          }, expectedPointerType + " pointer events boundary events when receiving capture");
                          listener.releasePointerCapture(event.pointerId);
                          eventsRecieved = [];
                          phase = PhaseEnum.WaitingForSecondMove;
                        }
                    });
                });
            }
        </script>
    </head>
    <body onload="run()">
        <h1>Pointer Events boundary events in capturing</h1>
        <h2 id="pointerTypeDescription"></h2>
        <h4>
            Test Description: This test checks the boundary events of pointer events while the capturing changes. If you are using hoverable pen don't leave the range of digitizer while doing the instructions.
            <ol>
                 <li>Move your pointer over the black square</li>
                 <li>Press down the pointer (i.e. press left button with mouse or touch the screen with finger or pen).</li>
                 <li>Drag the pointer within the black square.</li>
                 <li>Release the pointer.</li>
            </ol>

            Test passes if the proper behavior of the events is observed.
        </h4>
        <div id="target0" class="touchActionNone">
        </div>
        <div id="listener">Do not hover over or touch this element. </div>
        <div id="complete-notice">
            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
            <p>Refresh the page to run the tests again with a different pointer type.</p>
        </div>
        <div id="log"></div>
    </body>
</html>