textarea-scroll-selection.html (1344B)
1 <!doctype html> 2 <title>programatic focus() scrolls selection into view including ancestors</title> 3 <link rel="author" href="https://mozilla.org" title="Mozilla"> 4 <link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez"> 5 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1644366"> 6 <script src=/resources/testharness.js></script> 7 <script src=/resources/testharnessreport.js></script> 8 <div style="overflow: auto; height: 100px"> 9 <textarea style="overflow: hidden; height: 200px"> 10 Some text 11 That is surely more 12 Than 100px tall 13 For sure. 14 For sure. 15 For sure. 16 For sure. 17 For sure. 18 For sure. 19 For sure. 20 For sure. 21 For sure. 22 For sure. 23 For sure. 24 For sure. 25 For sure. 26 For sure. 27 For sure. 28 For sure. 29 For sure. 30 For sure. 31 </textarea> 32 </div> 33 <script> 34 promise_test(async function(t) { 35 await new Promise(resolve => window.addEventListener("load", resolve)); 36 let textarea = document.querySelector("textarea"); 37 textarea.setSelectionRange(textarea.value.length, textarea.value.length); 38 textarea.focus(); 39 40 await new Promise(resolve => { 41 requestAnimationFrame(() => requestAnimationFrame(resolve)); 42 }); 43 44 assert_not_equals(textarea.parentNode.scrollTop, 0, "Should've scrolled ancestor to show the selection"); 45 }); 46 </script>