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-position/sticky/position-sticky-nested-bottom.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.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-position/sticky/position-sticky-nested-bottom.html')
-rw-r--r-- | testing/web-platform/tests/css/css-position/sticky/position-sticky-nested-bottom.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-position/sticky/position-sticky-nested-bottom.html b/testing/web-platform/tests/css/css-position/sticky/position-sticky-nested-bottom.html new file mode 100644 index 0000000000..34fb3b32fc --- /dev/null +++ b/testing/web-platform/tests/css/css-position/sticky/position-sticky-nested-bottom.html @@ -0,0 +1,68 @@ +<!DOCTYPE html> +<title>Nested bottom-constrained position:sticky elements should render correctly</title> + +<link rel="help" href="https://www.w3.org/TR/css-position-3/#sticky-pos" /> +<meta name="assert" content="This test checks that nested position:sticky elements with a bottom constraint render correctly" /> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script src="../resources/sticky-util.js"></script> + +<body></body> + +<script> +test(() => { + const elements = setupNestedStickyTest('bottom', 25, 35); + elements.scroller.scrollTop = 300; + const nonStickyTopY = elements.container.offsetTop + + elements.filler.clientHeight; + assert_equals(elements.sticky.offsetTop, nonStickyTopY); + // The inner sticky should not be offset from the outer. + const nonStickyInnerTopY = elements.sticky.clientHeight - + elements.innerSticky.clientHeight; + assert_equals(elements.innerSticky.offsetTop, nonStickyInnerTopY); +}, 'before reaching the sticking point, neither sticky box should be offset'); + +test(() => { + const elements = setupNestedStickyTest('bottom', 25, 50); + elements.scroller.scrollTop = 150; + const nonStickyTopY = elements.container.offsetTop + + elements.filler.clientHeight; + assert_equals(elements.sticky.offsetTop, nonStickyTopY); + assert_equals(elements.innerSticky.offsetTop, 50); +}, 'the inner sticky can stick before the outer one if necessary'); + +test(() => { + const elements = setupNestedStickyTest('bottom', 25, 35); + elements.scroller.scrollTop = 100; + + const nonStickyTopY = elements.container.offsetTop + + elements.filler.clientHeight; + const nonStickyBottomY = nonStickyTopY + elements.sticky.clientHeight; + const targetBottomY = elements.scroller.clientHeight + + elements.scroller.scrollTop - 25; + const stickyOffset = nonStickyBottomY - targetBottomY; + assert_equals(elements.sticky.offsetTop, nonStickyTopY - stickyOffset); + + // The inner sticky has similar math, but its offsetTop is relative to the + // sticky element and in this test is (height - the difference between the + // top values). + assert_equals(elements.innerSticky.offsetTop, 40); +}, 'both sticky boxes can be stuck at the same time'); + +test(() => { + const elements = setupNestedStickyTest('bottom', 25, 75); + elements.scroller.scrollTop = 0; + assert_equals(elements.sticky.offsetTop, elements.container.offsetTop); + assert_equals(elements.innerSticky.offsetTop, 0); +}, 'neither sticky can escape their containing block'); + +test(() => { + const elements = setupNestedStickyTest('bottom', 25, 300); + elements.scroller.scrollTop = 200; + // It doesn't matter how big the inner sticky offset is, it cannot escape its + // containing block (the outer sticky). + assert_equals(elements.innerSticky.offsetTop, 0); +}, 'the inner sticky cannot be pushed outside the outer sticky'); +</script> |