diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-scroll-snap/selection-target.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-scroll-snap/selection-target.html')
-rw-r--r-- | testing/web-platform/tests/css/css-scroll-snap/selection-target.html | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-scroll-snap/selection-target.html b/testing/web-platform/tests/css/css-scroll-snap/selection-target.html new file mode 100644 index 0000000000..1c8435ea6e --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/selection-target.html @@ -0,0 +1,49 @@ +<!doctype html> +<meta charset=utf-8> +<title>scroll-padding is respected when typing into an out-of-view textfield</title> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1701928"> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#scroll-padding"> +<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez"> +<link rel="author" href="https://mozilla.org" title="Mozilla"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script src="/resources/testdriver-actions.js"></script> +<style> + body { + margin: 0; + } + :root { + scroll-padding-top: 100px; + } +</style> +<div style="height: 300vh;"></div> +<input type="text"> +<div style="height: 300vh;"></div> +<script> +function tick() { + return new Promise(resolve => { + requestAnimationFrame(() => requestAnimationFrame(resolve)); + }); +} + +promise_test(async function() { + let input = document.querySelector("input"); + input.focus(); + await tick(); + // Scroll out of view. + scrollTo(0, document.scrollingElement.scrollHeight); + await tick(); + assert_not_equals(window.scrollY, 0); + assert_true(input.getBoundingClientRect().bottom < 0, "Should be offscreen"); + // NOTE(emilio): Using test_driver.Actions() instead of test_driver.send_keys + // because the later scrolls the target into view which would defeat the + // point of the test... + await new test_driver.Actions().keyDown('a').send(); + await tick(); + // We assert the bottom rather than the top because Gecko scrolls the + // selection bounds into view, not the whole input. + assert_true(input.getBoundingClientRect().bottom > 100, "Scroll-padding should be respected"); +}, "Test scrolling into view when typing"); +</script> |