pointerevent_releasepointercapture_invalid_pointerid.html (4445B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Pointer Event: releasePointerCapture DOMException - NotFoundError</title> 5 <meta name="timeout" content="long"> 6 <meta name="assert" content="releasePointerCapture DOMException - NotFoundError"/> 7 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> 8 <link rel="author" title="Microsoft" href="http://www.microsoft.com/"/> 9 <link rel="help" href="http://www.w3.org/wiki/PointerEvents/TestAssertions"> 10 <meta name="assert" content="When the releasePointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name NotFoundError must be thrown."/> 11 <link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> 12 <!-- /resources/testharness.js --> 13 <script src="/resources/testharness.js"></script> 14 <script src="/resources/testharnessreport.js"></script> 15 <script src="/resources/testdriver.js"></script> 16 <script src="/resources/testdriver-actions.js"></script> 17 <script src="/resources/testdriver-vendor.js"></script> 18 <!-- Additional helper script for common checks across event types --> 19 <script type="text/javascript" src="pointerevent_support.js"></script> 20 <script type="text/javascript"> 21 var detected_pointertypes = {}; 22 var test_pointerEvent = async_test("releasePointerCapture: DOMException NotFoundError"); // set up test harness 23 // showPointerTypes is defined in pointerevent_support.js 24 // Requirements: the callback function will reference the test_pointerEvent object and 25 // will fail unless the async_test is created with the var name "test_pointerEvent". 26 add_completion_callback(showPointerTypes); 27 28 var INVALID_POINTERID = 314159265358973923; 29 var actions_promise; 30 31 function run() { 32 var target0 = document.getElementById("target0"); 33 target0.style["touchAction"] = "none"; 34 var listener = document.getElementById("listener"); 35 36 // try to release pointer capture with an invalid id 37 on_event(listener, "pointermove", function (event) { 38 detected_pointertypes[event.pointerType] = true; 39 40 test_pointerEvent.step(function() { 41 assert_throws_dom("NotFoundError", function(){ listener.releasePointerCapture(INVALID_POINTERID); }, 42 "It should not be possible to release capture an invalid pointer id"); 43 }); 44 45 // Make sure the test finishes after all the input actions are completed. 46 actions_promise.then( () => { 47 test_pointerEvent.done(); 48 }); 49 }); 50 51 // set pointer capture 52 on_event(target0, "pointerdown", function (event) { 53 detected_pointertypes[event.pointerType] = true; 54 listener.setPointerCapture(event.pointerId); 55 }); 56 57 // Inject mouse inputs. 58 actions_promise = new test_driver.Actions() 59 .pointerMove(0, 0, {origin: target0}) 60 .pointerDown() 61 .pointerMove(10, 0, {origin: target0}) 62 .pointerUp() 63 .send(); 64 } 65 </script> 66 </head> 67 <body onload="run()"> 68 <div id="listener"></div> 69 <h1> Pointer Event: releasePointerCapture() DOMException - NotFoundError</h1> 70 <h4> 71 Test Description: 72 Upon invocation of the releasePointerCapture method, if the provided pointerId value does not match any of the 73 active pointers, a DOMException with the name NotFoundError must be thrown. 74 </h4> 75 <br /> 76 <div id="target0"> 77 Use the mouse, touch or pen to move over or contact this box. 78 </div> 79 <div id="complete-notice"> 80 <p>Test complete: Scroll to Summary to view Pass/Fail Results.</p> 81 <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p> 82 <p>Refresh the page to run the tests again with a different pointer type.</p> 83 </div> 84 <div id="log"></div> 85 </body> 86 </html>