Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/interaction/focus/processing-model/textarea-scroll-selection.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>programatic focus() scrolls selection into view including ancestors</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div style="overflow: auto; height: 100px">
<textarea style="overflow: hidden; height: 200px">
Some text
That is surely more
Than 100px tall
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
For sure.
</textarea>
</div>
<script>
promise_test(async function(t) {
await new Promise(resolve => window.addEventListener("load", resolve));
let textarea = document.querySelector("textarea");
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
textarea.focus();
await new Promise(resolve => {
requestAnimationFrame(() => requestAnimationFrame(resolve));
});
assert_not_equals(textarea.parentNode.scrollTop, 0, "Should've scrolled ancestor to show the selection");
});
</script>