test_bug1710509.html (1400B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Bug 1710509</title> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <script src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script> 6 <script src="/tests/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js"></script> 7 <link rel="stylesheet" href="/tests/SimpleTest/test.css" /> 8 9 <style> 10 #container { 11 width: 100px; 12 height: 100px; 13 touch-action: none; 14 } 15 </style> 16 17 <div id="container"></div> 18 19 <script> 20 /** 21 * @template {keyof HTMLElementEventMap} K 22 * @param {HTMLElemnt} target 23 * @param {K} eventName 24 * @return {HTMLElementEventMap[K]} 25 */ 26 function waitForEvent(target, eventName) { 27 return new Promise(resolve => { 28 target.addEventListener(eventName, resolve, { once: true }); 29 }); 30 } 31 32 add_task(async function testPenDrag() { 33 await SpecialPowers.pushPrefEnv({ 34 set: [ 35 ["dom.w3c_pointer_events.dispatch_by_pointer_messages", false], 36 ], 37 }); 38 39 await SimpleTest.promiseFocus(); 40 const container = document.getElementById("container"); 41 const touchMovePromise = waitForEvent(container, "touchmove"); 42 await promiseNativePointerDrag(container, "pen", 50, 50, -50, -50); 43 44 const touchmove = await touchMovePromise; 45 const [touch] = touchmove.touches; 46 is(touch.radiusX, 1, ".radiusX"); 47 is(touch.radiusY, 1, ".radiusX"); 48 }); 49 </script>