summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/pointerevent_pointerrawupdate.html
blob: bd24daf6171ad765a37a92ffcb3acce0ded25e0f (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
<!doctype html>
<html>
    <head>
        <title>pointerrawupdate</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="/resources/testdriver.js"></script>
        <script src="/resources/testdriver-actions.js"></script>
        <script src="/resources/testdriver-vendor.js"></script>
        <!-- Additional helper script for common checks across event types -->
        <script type="text/javascript" src="pointerevent_support.js"></script>
    </head>
    <body onload="run()">
        <h2>pointerrawupdate</h2>
        <h4>Test Description: This test checks that pointerrawupdate is not dispatched on non-SecureContext. </h4>
        <p>Move your mouse within the black box.</p>
        <p>Press left button down and then press middle button while holding down left button. Then release the buttons</p>
        <div id="target0"></div>
        <script>
            var test_pointerrawupdate = async_test("pointerrawupdate event received");
            var actions_promise;

            var pointerrawupdateReceived = false;
            var pointerdownReceived = false;
            var pointerrawupdateFromButtonChangeReceived = false;

            function run() {
                var target0 = document.getElementById("target0");

                on_event(target0, "pointerrawupdate", function (event) {
                    pointerrawupdateReceived = true;
                    if (pointerdownReceived && event.button != -1)
                      pointerrawupdateFromButtonChangeReceived = true;
                });
                on_event(target0, "pointermove", function (event) {
                    test_pointerrawupdate.step(function() {
                        assert_false(pointerrawupdateReceived,
                                    "Pointerrawupdate event should not have been received before pointermove.");
                        }, "Pointerrawupdate event should have been received before pointermove.");
                });
                on_event(target0, "pointerdown", function (event) {
                    pointerdownReceived = true;
                });
                on_event(target0, "pointerup", function (event) {
                    test_pointerrawupdate.step(function() {
                        assert_false(pointerrawupdateFromButtonChangeReceived,
                                    "Pointerrawupdate event should not have been received from chorded button changes.");
                        }, "Pointerrawupdate event should have been received from chorded button changes.");

                    test_pointerrawupdate.step(function() {
                        assert_false("onpointerrawupdate" in window,
                                    "Window should not have event handler onpointerrawupdate");
                        assert_false("onpointerrawupdate" in window.document,
                                    "Document should not have event handler onpointerrawupdate");
                        assert_false("onpointerrawupdate" in window.document.documentElement,
                                     "Element should not have event handler onpointerrawupdate");
                        }, "onpointerrawupdate should be exposed only in SecureContext");

                    // Make sure the test finishes after all the input actions are completed.
                    actions_promise.then( () => {
                        test_pointerrawupdate.done();
                    });
                });
                var actions = new test_driver.Actions();
                actions_promise = actions.pointerMove(0, 0, {origin: target0, button: actions.ButtonType.LEFT})
                    .pointerDown({button: actions.ButtonType.LEFT})
                    .pointerDown({button: actions.ButtonType.MIDDLE})
                    .pointerUp({button: actions.ButtonType.MIDDLE})
                    .pointerUp({button: actions.ButtonType.LEFT})
                    .send();
            }

        </script>
        <div id="complete-notice">
        </div>
    </body>
</html>