Files
sousa-gecko/testing/web-platform/tests/html/rendering/widgets/textarea-scroll-restoration.html
T
Emilio Cobos Álvarez f4ee9ffe08 Bug 1787062 - Unify how <input> and <textarea> get initialized a bit. r=masayuki,smaug
Make the anonymous content creation synchronously so that we don't need
to update layout after-the-fact, and make editor creation lazy like we
do for <input>.

I think we should try to remove the trailing <br> for <textarea> after
this (just so that editor doesn't insert it). But this is green on try
and fixes the issue so worth landing incrementally.

Differential Revision: https://phabricator.services.mozilla.com/D267252
2025-10-03 09:17:12 +00:00

50 lines
1.2 KiB
HTML

<!doctype html>
<meta charset="utf-8">
<title>Test textarea scroll restoration</title>
<link rel="help" href="https://html.spec.whatwg.org/#the-textarea-element-2">
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="container">
<textarea id="textarea" rows=3>
A
B
C
D
E
F
G
H
I
</textarea>
</div>
<script>
function frame() {
return new Promise(r => {
requestAnimationFrame(() => requestAnimationFrame(r));
});
}
let container = document.getElementById("container");
let textarea = document.getElementById("textarea");
async function test_restoration() {
textarea.scrollTop = 10000;
await frame();
let top = textarea.scrollTop;
assert_not_equals(top, 0, "Should've scrolled down");
container.style.display = "inline-block";
assert_equals(textarea.scrollTop, top, "Should've preserved the scroll position");
container.style.display = "";
}
promise_test(test_restoration);
promise_test(async function() {
textarea.focus();
await frame();
await test_restoration();
}, "after focus");
</script>