summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/interaction/focus/processing-model/textarea-scroll-selection.html
blob: c8e252f7da6e3dc66691ce10b69528949105a079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!doctype html>
<title>programatic focus() scrolls selection into view including ancestors</title>
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1644366">
<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>