helper_doubletap_zoom_noscroll.html (2110B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=2100"/> 6 <title>Check that double tapping something tall that we are already zoomed to doesn't scroll (it zooms out)</title> 7 <script src="apz_test_native_event_utils.js"></script> 8 <script src="apz_test_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <script> 11 12 function within(a, b, tolerance) { 13 return (Math.abs(a-b) < tolerance); 14 } 15 16 async function test() { 17 let useTouchpad = (location.search == "?touchpad"); 18 19 let resolution = await getResolution(); 20 let initial_resolution = resolution; 21 ok(resolution > 0, 22 "The initial_resolution is " + resolution + ", which is some sane value"); 23 24 ok(window.scrollY == 0, "window not scrolled"); 25 info("window.scrollY " + window.scrollY); 26 27 // Check that double-tapping once zooms in 28 await doubleTapOn(document.getElementById("target"), 10, 10, useTouchpad); 29 let prev_resolution = resolution; 30 resolution = await getResolution(); 31 ok(resolution > prev_resolution, "The first double-tap has increased the resolution to " + resolution); 32 ok(window.scrollY == 0, "window not scrolled"); 33 info("window.scrollY " + window.scrollY); 34 35 let x = document.getElementById("target").getBoundingClientRect().width/2; 36 let y = window.visualViewport.height - 20; 37 // Check that near the bottom doesn't scroll but zooms out 38 await doubleTapOn(document.getElementById("target"), x, y, useTouchpad); 39 prev_resolution = resolution; 40 resolution = await getResolution(); 41 ok(resolution < prev_resolution, "The second double-tap has decreased the resolution to " + resolution); 42 // slight float inaccuracy, not sure why 43 ok(within(resolution, initial_resolution, 0.0002), "The second double-tap has restored the resolution to " + resolution); 44 ok(window.scrollY == 0, "window not scrolled"); 45 info("window.scrollY " + window.scrollY); 46 } 47 48 waitUntilApzStable() 49 .then(test) 50 .then(subtestDone, subtestFailed); 51 52 </script> 53 </head> 54 <body> 55 56 <div id="target" style="background: grey; width: 50vw; height: 300vh;"> 57 58 </body> 59 </html>