summaryrefslogtreecommitdiffstats
path: root/dom/events/test/pointerevents/pointerevent_pointermove_pointertype-manual.html
blob: 5db76ac1e576b11f073de89b470f8acf170411df (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
<!doctype html>
<html>
    <head>
        <title>pointerType conservation</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 onload="run()">
        <!--
        <h1>pointerType conservation</h1>
        <h4>Test Description: This test checks if pointerType attribute defined properly.</h4>
        <div id="instructions">
            Press and move a mouse button, touch contact or pen contact on the black rectangle. Only use one device per test run.
        </div>
        <p>Note: This test may be run with different pointer devices, however only one device should be used per test run.
        <p>
        -->
        <div id="target0"></div>
        <script>
            var eventTested = false;
            var pointerTypeGot = false;
            var pointerdown_event;
            var detected_pointertypes = {};

            setup({ explicit_done: true });

            add_completion_callback(showPointerTypes);

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

                on_event(target0, "pointerover", function(event) {
                    detected_pointertypes[ event.pointerType ] = true;
                });

                // The pointerType attribute of a pointermove event must have the same value as the pointerType attribute of the last pointerdown event with the same pointerId attribute.
                // TA: 5.1
                on_event(target0, "pointerdown", function (event) {
                    pointerdown_event = event;
                    pointerTypeGot = true;
                });

                on_event(target0, "pointermove", function (event) {
                    if(pointerTypeGot == true) {
                        if(!eventTested) {
                            test(function() {
                                assert_equals(event.pointerId, pointerdown_event.pointerId, "pointer IDs are equal: ");
                                assert_equals(event.pointerType, pointerdown_event.pointerType, "pointerType of pointermove event matches pointerdown event: ");
                            }, "pointerType is dispatched properly");
                        }
                        done();
                    }
                });
            }
        </script>
        <h1>Pointer Events pointerType conservation tests</h1>
        <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>