summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-manual.html
blob: d103804dc5393d04dc1674dd9fa6935cdb997822 (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
<!doctype html>
<html>
    <head>
        <title>Lostpointercapture fires on document when target is removed</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 - lostpointercapture when capturing element is removed</h1>
        <h4>
            Test Description:
            This test checks if lostpointercapture is fired at the document when the capturing node is removed from the document.
            Complete the following actions:
            <ol>
                <li>Press and hold left mouse button over "Set Capture" button. "gotpointercapture" should be logged inside of the black rectangle.
                <li>"lostpointercapture" should be logged inside of the black rectangle after a short delay.
            </ol>
        </h4>
        -->
        <div id="target0"></div>
        <div id="target1" style="background:black; color:white"></div>
        <br>
        <input type="button" id="btnCapture" value="Set Capture">
        <script type='text/javascript'>
            var isDisconnected = false;
            var count = 0;

            var detected_pointertypes = {};
            add_completion_callback(showPointerTypes);

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

            var test_lostpointercapture = async_test("lostpointercapture event received");

            window.onload = function() {
                on_event(captureButton, 'pointerdown', function(event) {
                    detected_pointertypes[event.pointerType] = true;
                    sPointerCapture(event);
                });

                on_event(target0, 'gotpointercapture', function(e) {
                    log("gotpointercapture", target1);
                    setTimeout(function() {
                        isDisconnected = true;
                        target0.parentNode.removeChild(target0);
                    }, 250);
                });

                on_event(target0, 'lostpointercapture', function(e) {
                    log("lostpointercapture on element", target1);
                    test(function() {
                        // TA: 11.3
                        assert_unreached("lostpointercapture must be fired on the document, not the capturing element");
                    }, "lostpointercapture must not be dispatched on the disconnected node");
                });

                on_event(document, 'lostpointercapture', function(e) {
                    log("lostpointercapture on document", target1);
                    test(function() {
                        // TA: 11.3
                        assert_true(isDisconnected, "lostpointercapture must be fired on the document");

                    }, "lostpointercapture is dispatched on the document");
                    test_lostpointercapture.done();
                });
            }
        </script>
        <h1>Pointer Events Capture Test</h1>
        <div id="complete-notice">
            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
        </div>
        <div id="log"></div>
    </body>
</html>