tor-browser

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

pointerevent_setpointercapture_disconnected.html (3053B)


      1 <!doctype html>
      2 <html>
      3    <head>
      4        <title>setPointerCapture() throws on disconnected node</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        <script src="pointerevent_support.js"></script>
     13        <script type="text/javascript">
     14            var detected_pointertypes = {};
     15            add_completion_callback(showPointerTypes);
     16            var test_setPointerCapture = async_test("setPointerCapture: DOMException InvalidStateError");
     17            var actions_promise;
     18 
     19            function run() {
     20                var target0 = document.getElementById("target0");
     21                var target1 = document.getElementById("target1");
     22 
     23                target1.parentNode.removeChild(target1);
     24 
     25                on_event(target0, "pointerdown", function (event) {
     26                    detected_pointertypes[ event.pointerType ] = true;
     27                    try {
     28                        target1.setPointerCapture(event.pointerId);
     29 
     30                        test_setPointerCapture.step(function() {
     31                            assert_unreached("DOMException: InvalidStateError should have been thrown.");
     32                        });
     33                    } catch (e) {
     34                        // TA: 13.4
     35                        test_setPointerCapture.step(function() {
     36                            assert_equals(e.name, "InvalidStateError", "DOMException should be InvalidStateError");
     37                        });
     38                    }
     39                    // Make sure the test finishes after all the input actions are completed.
     40                    actions_promise.then( () => {
     41                        test_setPointerCapture.done();
     42                    });
     43                });
     44 
     45                // Inject mouse inputs.
     46                actions_promise = new test_driver.Actions()
     47                    .pointerMove(0, 0, {origin: target0})
     48                    .pointerDown()
     49                    .pointerUp()
     50                    .send();
     51            }
     52        </script>
     53    </head>
     54    <body onload="run()">
     55        <h1>Pointer Event: DOMException InvalidStateError</h1>
     56        <h4>Test Description:
     57            When the setPointerCapture method is invoked, if the target node does not participate in its ownerDocument's tree, a DOMException with the name InvalidStateError must be thrown.
     58        </h4>
     59        <br>
     60        <div id="target0">
     61            Use the mouse, touch or pen to contact this box.
     62        </div>
     63        <div id="target1"></div>
     64        <div id="complete-notice">
     65            <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
     66        </div>
     67        <div id="log"></div>
     68    </body>
     69 </html>