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