summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html')
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html86
1 files changed, 86 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html
new file mode 100644
index 0000000000..ec51910619
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-007.html
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<title>Tests that scroll adjustment still applies when using another anchor in default anchor's scroll container</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#needs-scroll-adjustment">
+<link rel="author" href="mailto:xiaochengh@chromium.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/test-common.js"></script>
+
+<style>
+body {
+ margin: 0;
+}
+
+#scroller {
+ width: 400px;
+ height: 400px;
+ overflow: scroll;
+ position: relative;
+}
+
+#spacer {
+ width: 1000px;
+ height: 1000px;
+}
+
+.anchor {
+ width: 50px;
+ height: 50px;
+ position: absolute;
+ background: orange;
+}
+
+#anchor1 {
+ anchor-name: --a1;
+ left: 300px;
+ top: 100px;
+}
+
+#anchor2 {
+ anchor-name: --a2;
+ left: 200px;
+ top: 200px;
+}
+
+#anchor3 {
+ anchor-name: --a3;
+ left: 100px;
+ top: 300px;
+}
+
+/* Uses different anchors in insets instead of the default anchor.
+ * Still scroll-adjusted because they are in the same scroll container. */
+#target {
+ position: fixed;
+ width: 50px;
+ height: 50px;
+ left: anchor(--a3 left);
+ top: anchor(--a1 top);
+ anchor-default: --a2;
+ background: lime;
+}
+</style>
+
+<div id="scroller">
+ <div id="spacer"></div>
+ <div class="anchor" id="anchor1"></div>
+ <div class="anchor" id="anchor2"></div>
+ <div class="anchor" id="anchor3"></div>
+</div>
+<div id="target"></div>
+
+<script>
+promise_test(async () => {
+ await waitUntilNextAnimationFrame();
+ assert_equals(target.getBoundingClientRect().left, 100);
+ assert_equals(target.getBoundingClientRect().top, 100);
+
+ scroller.scrollLeft = 50;
+ await waitUntilNextAnimationFrame();
+ assert_equals(target.getBoundingClientRect().left, 50);
+
+ scroller.scrollTop = 50;
+ await waitUntilNextAnimationFrame();
+ assert_equals(target.getBoundingClientRect().top, 50);
+}, '#target3 is scroll-adjusted in both axises');
+</script>