helper_doubletap_zoom_hscrollable.html (2397B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=2100"/> 6 <title>Check that tall element wider than the viewport doesn't scroll to the top</title> 7 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 8 <script type="application/javascript" src="apz_test_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <script type="application/javascript"> 11 12 // Although this test has hscrollable in the name, it does not test any 13 // horizontal scrolling. Rather it is the mere presence of horizontally 14 // scrollable content that triggers this bug (it confused the code that 15 // picked a rect to zoom to). 16 17 async function test() { 18 let useTouchpad = (location.search == "?touchpad"); 19 20 let resolution = await getResolution(); 21 ok(resolution > 0, 22 "The initial_resolution is " + resolution + ", which is some sane value"); 23 24 // instant scroll down 25 window.scrollTo({ 26 top: window.innerHeight * 2, 27 left: 0, 28 behavior: 'auto' 29 }); 30 31 await promiseApzFlushedRepaints(); 32 33 let scrollPos = window.scrollY; 34 ok(scrollPos > window.innerHeight * 2 - 50, "window scrolled down"); 35 36 info("window.scrollY " + window.scrollY); 37 38 info("window.innerHeight " + window.innerHeight); 39 40 info("document.documentElement.scrollHeight " + document.documentElement.scrollHeight); 41 42 let target = document.getElementById("target"); 43 44 let x = 20; 45 let y = scrollPos + window.innerHeight / 2; 46 47 // Check that second double tap does not scroll up 48 info("sending second double tap"); 49 await doubleTapOn(target, x, y, useTouchpad); 50 prev_resolution = resolution; 51 resolution = await getResolution(); 52 ok(resolution == prev_resolution, "After double-tap the resolution is the same: " + resolution); 53 54 ok(window.scrollY > window.innerHeight * 2 - 50, "window is still scrolled down"); 55 ok(Math.abs(window.scrollY - scrollPos) < 1, "window didnt scroll"); 56 info("window.scrollY " + window.scrollY); 57 } 58 59 waitUntilApzStable() 60 .then(test) 61 .then(subtestDone, subtestFailed); 62 63 </script> 64 <style> 65 .spacer { 66 background-color: #eee; 67 height: 800vh; 68 width: 200vw; 69 } 70 .rect { 71 width: 90vw; 72 height: 30px; 73 background-color: #aaa; 74 } 75 </style> 76 </head> 77 <body> 78 <div id="firsttarget" class="rect"> 79 </div> 80 81 <div id="target" class="spacer"> 82 </div> 83 84 </body> 85 </html>