summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/pointerevent_releasepointercapture_onpointerup_mouse-manual.html
blob: 7ba33d9be9a137ed278be9f0829b0fd09c3b2e86 (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
<!doctype html>
<html>
    <head>
        <title>Release capture on pointerup</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 src="pointerevent_support.js"></script>
        <script src="mochitest_support_internal.js"></script>
    </head>
    <body>
        <h1>Pointer Events Capture Test - release capture on pointerup</h1>
        <!--
        <h4>
            Test Description: This test checks if setCapture/releaseCapture functions works properly. Complete the following actions:
            <ol>
                <li> Press and hold left mouse button over "Set Capture" button
                <li> Release left mouse button anywhere over the document. "lostpointercapture" should be logged inside of the black rectangle immediately after "pointerup"
            </ol>
        </h4>
        Test passes if the proper behavior of the events is observed.
        -->
        <div id="target0" style="background:black; color:white"></div>
        <br>
        <input type="button" id="btnCapture" value="Set Capture">
        <script type='text/javascript'>
            var isPointerCapture = false;
            var pointerupGot = false;
            var count=0;

            var detected_pointertypes = {};
            add_completion_callback(showPointerTypes);

            var target0 = document.getElementById('target0');
            var captureButton = document.getElementById('btnCapture');

            setup({ explicit_done: true });

            window.onload = function() {
                on_event(captureButton, 'pointerdown', function(e) {
                    detected_pointertypes[e.pointerType] = true;
                    if(isPointerCapture == false) {
                        isPointerCapture = true;
                        sPointerCapture(e);
                        pointerupGot = false;
                    }
                });

                on_event(target0, 'gotpointercapture', function(e) {
                    log("gotpointercapture", document.getElementById('target0'));
                });

                // If the setPointerCapture method has been invoked on the pointer specified by pointerId,
                // and the releasePointerCapture method has not been invoked,a lostpointercapture event must be
                // dispatched to the element on which the setPointerCapture method was invoked. Furthermore, 
                // subsequent events for the specified pointer must follow normal hit testing mechanisms for
                // determining the event target.
                // TA: 3.7
                on_event(target0, 'lostpointercapture', function(e) {
                    test(function() {
                        assert_true(pointerupGot, "pointerup was received before lostpointercapture")
                    }, "pointerup was received before lostpointercapture");
                    log("lostpointercapture", document.getElementById('target0'));
                    isPointerCapture = false;
                    done();
                });

                on_event(target0, 'pointerup', function(e) {
                    log("pointerup", target0);
                    pointerupGot = true;
                });
            }
        </script>
        <h1>Pointer Events Capture Test</h1>
        <div id="complete-notice">
            <p>Test complete: Scroll to Summary to view Pass/Fail Results.</p>
            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
        </div>
        <div id="log"></div>
    </body>
</html>