summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html')
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html b/testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html
new file mode 100644
index 0000000000..fa383154da
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning Test: Dynamically change the anchor-center position</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-center">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ }
+ #anchor {
+ width: 100px;
+ height: 100px;
+ anchor-name: --anchor;
+ }
+ #anchored {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ position-anchor: --anchor;
+ align-self: anchor-center;
+ left: anchor(--unknown right, 0px);
+ }
+</style>
+<div id="cb">
+ <div id="anchor"></div>
+ <div id="anchored"></div>
+</div>
+<script>
+ test(() => {
+ assert_equals(anchored.offsetLeft, 0);
+ assert_equals(anchored.offsetTop, 0);
+ }, "Anchored initially have the same width as the anchor");
+
+ test(() => {
+ anchor.style.height = "200px";
+ assert_equals(anchored.offsetLeft, 0);
+ assert_equals(anchored.offsetTop, 50);
+ }, "Increase the height of the anchor to move the anchor-center offset");
+</script>