summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/pointerevent_pointerrawupdate.html
blob: 74c14d932ff583b0a418ad38c9fda4e35e3555d4 (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
<!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 if pointerrawupdate is dispatched correctly. </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_true(pointerrawupdateReceived,
                                    "Pointerrawupdate event should 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_true(pointerrawupdateFromButtonChangeReceived,
                                    "Pointerrawupdate event should have been received from chorded button changes.");
                        }, "Pointerrawupdate event should have been received from chorded button changes.");
                    // 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>