helper_zoomToFocusedInput_content_visibility_auto.html (1264B)
1 <!doctype HTML> 2 <html> 3 <meta charset="utf8"> 4 <meta name="viewport" content="width=device-width,initial-scale=1"> 5 <title>Tests that zoom-to-focused-input works for an element in `content-visibility: auto` subtree</title> 6 <script src="apz_test_utils.js"></script> 7 <script src="/tests/SimpleTest/paint_listener.js"></script> 8 <style> 9 .spacer { 10 height: 200vh; 11 } 12 .auto { 13 content-visibility: auto; 14 } 15 </style> 16 <body> 17 <div class="spacer"></div> 18 <div class=auto><input id=target type="text"/></div> 19 <div class="spacer"></div> 20 <script> 21 async function test() { 22 is(window.scrollY, 0, "The initial scroll offset should be 0"); 23 24 // Focus to the input element without scrolling. 25 const input = document.querySelector("#target"); 26 const focusPromise = new Promise(resolve => { 27 input.addEventListener("focus", resolve); 28 }); 29 input.focus({ preventScroll: true }); 30 await focusPromise; 31 is(document.activeElement, input, "The input element has been focused"); 32 33 // Invoke zoom-to-focused-input. 34 const utils = SpecialPowers.getDOMWindowUtils(window); 35 utils.zoomToFocusedInput(); 36 37 ok(window.scrollY > 0, `The scroll offset have been changed: ${window.scrollY}`); 38 } 39 40 waitUntilApzStable() 41 .then(test) 42 .then(subtestDone, subtestFailed); 43 </script> 44 </body> 45 </html>