summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/pointerevents/pointerevent_iframe-touch-action-none_touch.html
blob: 109aec8dcd38cfadd8d8055b0a9b7d3b5a6dc791 (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
<html>
  <head>
        <title>iframe touch-action:none attribute</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="/resources/testdriver.js"></script>
        <script src="/resources/testdriver-actions.js"></script>
        <script src="/resources/testdriver-vendor.js"></script>
  </head>
  <body onload="run()">
    <h1>iframe touch-action:none attribute</h1>
    <h2 id="pointerTypeDescription"></h2>
    <h4>Test Description: Drag your finger in the green rectangle below then tap the "Done" button.</h4>
    <br>
    <iframe id="target"
            style="touch-action:none;"
            src="resources/iframe-touch-action-none-subframe.html">
    </iframe>
    <input type="button" id="btnDone" value="Done">
  </body>
  <script>
    var event_log = [];

    function resetTestState() {
        event_log = [];
    }

    function run() {
        var test_pointerEvent = setup_pointerevent_test("iframe received pointercancel",
                                                        ["touch"]);
        var actions_promise;
        var target = document.getElementById("target");

        on_event(document.getElementById("btnDone"), "click", () => {
            test_pointerEvent.step(() => {
                assert_equals(event_log.join(", "), "pointercancel",
                              "exactly one pointercancel received");
            });
            actions_promise.then(() => test_pointerEvent.done());
        });

        on_event(window, "message",  function(event) {
            if (event.source != target.contentWindow) {
              return;
            }
            if (event.data && event.data.type == "subframe-event") {
              event_log.push(event.data.eventType);
            }
        });

        actions_promise = new test_driver.Actions()
            .addPointer("pointer1", "touch")
            .pointerMove(0, 0, {origin: target})
            .pointerDown()
            .pointerMove(25, 25, {origin: target})
            .pointerUp()
            .pointerMove(0, 0, {origin: btnDone})
            .pointerDown()
            .pointerUp()
            .send();
    }
  </script>
</html>