tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

pointerevent_pointerout_after_pointercancel_touch.html (3612B)


      1 <!doctype html>
      2 <html>
      3    <head>
      4        <title>pointerout</title>
      5        <meta name="viewport" content="width=device-width">
      6        <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
      7        <script src="/resources/testharness.js"></script>
      8        <script src="/resources/testharnessreport.js"></script>
      9        <script src="/resources/testdriver.js"></script>
     10        <script src="/resources/testdriver-actions.js"></script>
     11        <script src="/resources/testdriver-vendor.js"></script>
     12        <!-- Additional helper script for common checks across event types -->
     13        <script type="text/javascript" src="pointerevent_support.js"></script>
     14    </head>
     15    <body class="scrollable" onload="run()">
     16        <h2>pointerout</h2>
     17        <h4>Test Description: This test checks if pointerout event triggers after pointercancel. Start touch on the black rectangle and move your touch to scroll in any direction. </h4>
     18        <p>Note: this test is for touch devices only</p>
     19        <div id="target0"></div>
     20        <script>
     21            var test_pointerout = async_test("pointerout event received");
     22            // showPointerTypes is defined in pointerevent_support.js
     23            // Requirements: the callback function will reference the test_pointerEvent object and
     24            // will fail unless the async_test is created with the var name "test_pointerEvent".
     25            add_completion_callback(showPointerTypes);
     26 
     27            var pointercancel_event = null;
     28            var detected_pointertypes = {};
     29 
     30            function run() {
     31                var target0 = document.getElementById("target0");
     32                var actions_promise;
     33 
     34                on_event(target0, "pointercancel", function (event) {
     35                    detected_pointertypes[event.pointerType] = true;
     36                    pointercancel_event = event;
     37                });
     38 
     39                // After firing the pointercancel event the pointerout event must be dispatched.
     40                // TA: 4.3
     41                on_event(target0, "pointerout", function (event) {
     42                    if(event.pointerType == 'touch') {
     43                        if(pointercancel_event != null) {
     44                            test_pointerout.step(function() {
     45                                assert_equals(event.pointerType, pointercancel_event.pointerType, "pointerType is same for pointercancel and pointerout");
     46                                assert_equals(event.isPrimary, pointercancel_event.isPrimary, "isPrimary is same for pointercancel and pointerout");
     47                            });
     48                            // Make sure the test finishes after all the input actions are completed.
     49                            actions_promise.then( () => {
     50                                test_pointerout.done();
     51                            });
     52                        }
     53                        else {
     54                            test_pointerout.step(function() {
     55                                assert_true(false,
     56                                "pointercancel received before pointerout");
     57                            }, "pointercancel received before pointerout");
     58                        }
     59                    }
     60                });
     61 
     62                // Inject touch inputs.
     63                actions_promise = touchScrollInTarget(target0, 'down');
     64            }
     65 
     66        </script>
     67        <h1>Pointer Events pointerout tests</h1>
     68        <div id="complete-notice">
     69            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
     70        </div>
     71        <div id="log"></div>
     72    </body>
     73 </html>