helper_bug1638441_fixed_pos_hit_test.html (2091B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1638441 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <title>Test for Bug 1638441</title> 10 <script src="/tests/SimpleTest/paint_listener.js"></script> 11 <script src="/tests/SimpleTest/EventUtils.js"></script> 12 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 13 <script type="application/javascript" src="apz_test_utils.js"></script> 14 <style> 15 #target { 16 position: fixed; 17 bottom: 50px; 18 width: 100px; 19 height: 100px; 20 } 21 </style> 22 </head> 23 <body> 24 <div id="target"> 25 <script type="application/javascript"> 26 27 async function test() { 28 let utils = SpecialPowers.getDOMWindowUtils(window); 29 30 // Do a large visual scroll to scroll the visual viewport to the bottom 31 // of the layout viewport. 32 let visualScrollPromise = new Promise(resolve => { 33 window.visualViewport.addEventListener("scroll", resolve, { once: true }); 34 }); 35 utils.scrollToVisual(0, 900, utils.UPDATE_TYPE_MAIN_THREAD, 36 utils.SCROLL_MODE_INSTANT); 37 await visualScrollPromise; 38 await promiseApzFlushedRepaints(); 39 40 // Tap the position-fixed element which is near the bottom of the 41 // layout viewport (and therefore visible now that the visual 42 // viewport is scrolled to the bottom of the layout viewport). 43 // The intention is to test that the visual-to-layout transform 44 // is applied correctly during the hit test. 45 let target = document.getElementById("target"); 46 let mouseDownEvent = null; 47 let mouseDownPromise = new Promise(resolve => { 48 target.addEventListener("mousedown", function(e) { 49 mouseDownEvent = e; 50 resolve(); 51 }); 52 }); 53 54 await synthesizeNativeTap(target, 10, 10); 55 await mouseDownPromise; 56 57 is(mouseDownEvent.target, target, "mousedown event targeted the correct element"); 58 } 59 60 SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(2.0); 61 waitUntilApzStable() 62 .then(test) 63 .then(subtestDone, subtestFailed); 64 65 </script> 66 </body> 67 </html>