click-event.htm (1654B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Click event is a PointerEvent</title> 5 <link rel="help" href="https://github.com/w3c/pointerevents/pull/317"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 </head> 9 <body> 10 <div id='clicktarget'></div> 11 <div id="log"></div> 12 <script type="text/javascript"> 13 var clicktarget = document.querySelector("#clicktarget"); 14 var t = async_test("synthetic click event is a PointerEvent"); 15 clicktarget.addEventListener('click', t.step_func(function (e) { 16 assert_equals(e.constructor, window.PointerEvent, "Click is a PointerEvent"); 17 assert_true(e instanceof window.PointerEvent, "Click is an instance of PointerEvent"); 18 // Since this click is not generated by a pointing device, pointerId must have 19 // the reserved value -1, and pointerType must have the default empty string 20 assert_equals(e.pointerId, -1, "Click's pointerId has the default value of -1"); 21 assert_equals(e.pointerType, "", "Click's pointerType has the default value of empty string"); 22 assert_equals(e.screenX, 0, "Click's screenX coordinate should not be set."); 23 assert_equals(e.screenY, 0, "Click's screenY coordinate should not be set."); 24 assert_equals(e.clientX, 0, "Click's clientX coordinate should not be set."); 25 assert_equals(e.clientY, 0, "Click's clientY coordinate should not be set."); 26 assert_equals(e.detail, 0, "element.click click event should not populate click count"); 27 t.done(); 28 })); 29 document.querySelector('#clicktarget').click(); 30 </script> 31 </body> 32 </html>