summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /testing/web-platform/tests/css/css-anchor-position
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-anchor-position')
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-center-offset-change.html41
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll-ref.html15
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll.html38
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-fallback-invalidation.html53
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-inherited.html63
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-invalid-fallback.html234
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-001.html (renamed from testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-001.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-002.html (renamed from testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-002.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-003.html (renamed from testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-003.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-004.html (renamed from testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-004.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-fallback.html (renamed from testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden-ref.html37
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden.html67
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-013.html66
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-014.html69
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor-ref.html42
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor.html55
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/at-position-try-cssom.html138
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/base-style-invalidation.html64
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/chrome-336164421-crash.html13
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/chrome-336322507-crash.html15
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/inset-area-function.html71
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/inset-area-in-position-try.html188
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-computed.tentative.html2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-parsing.tentative.html2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-try-backdrop.html33
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-try-order-inset-area.html196
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-add-no-overflow.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-add-no-overflow.tentative.html)4
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-valid.tentative.html2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-in.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-in.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-out.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-out.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed-ref.html5
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed.tentative.html38
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-001.html73
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-002.html66
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-003.html77
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004-ref.html34
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004.html80
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-anchor.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-anchor.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-css-visibility.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-css-visibility.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-css-visibility.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-css-visibility.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-non-intervening-container.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-non-intervening-container.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-stacked-child.html60
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-with-position.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-with-position.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-scroll.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-scroll.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-stacked-child.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-stacked-child.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-anchors-visible.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-anchors-visible.tentative.html)2
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-no-overflow.html (renamed from testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-no-overflow.tentative.html)4
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor-dynamic.html62
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor.html56
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-001-ref.html (renamed from testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-001.tentative-ref.html)0
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-002-ref.html (renamed from testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-002.tentative-ref.html)0
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-004-ref.html (renamed from testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-004.tentative-ref.html)0
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-fallback-ref.html (renamed from testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-fallback.tentative-ref.html)0
56 files changed, 2072 insertions, 25 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>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll-ref.html b/testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll-ref.html
new file mode 100644
index 0000000000..d2638491ce
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title>CSS Test Reference</title>
+<body style="margin:0">
+ <div id="scroller" style="width:400px;height:400px;overflow:auto;background:orange">
+ <div style="height:100px"></div>
+ <div style="width:100px;height:100px;background:pink">
+ <div style="height:25px"></div>
+ <div style="width:50px;height:50px;background:purple"></div>
+ </div>
+ <div style="height:1000px"></div>
+ </div>
+</body>
+<script>
+ scroller.scrollTop = 100;
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll.html b/testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll.html
new file mode 100644
index 0000000000..29b5e06e2a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-center-scroll.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning Test: scroll adjusted anchor-center</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-center">
+<link rel="match" href="anchor-center-scroll-ref.html">
+<style>
+ body { margin: 0; }
+ #scroller {
+ width: 400px;
+ height: 400px;
+ overflow: auto;
+ background: orange;
+ }
+ #anchor {
+ margin-top: 100px;
+ width: 100px;
+ height: 100px;
+ background: pink;
+ anchor-name: --anchor;
+ }
+ #anchored {
+ position: absolute;
+ position-anchor: --anchor;
+ align-self: anchor-center;
+ width: 50px;
+ height: 50px;
+ background: purple;
+ }
+ #filler { height: 1000px; }
+</style>
+<div id="scroller">
+ <div id="anchor"></div>
+ <div id="anchored"></div>
+ <div id="filler"></div>
+</div>
+<script>
+ scroller.offsetTop;
+ scroller.scrollTop = 100;
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-fallback-invalidation.html b/testing/web-platform/tests/css/css-anchor-position/anchor-fallback-invalidation.html
new file mode 100644
index 0000000000..a066c2da55
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-fallback-invalidation.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: Invalidation when the anchor*() fallback matches old style</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/">
+<link rel="help" href="https://issues.chromium.org/issues/333858786">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: 1px solid black;
+ }
+
+ #anchor {
+ anchor-name: --a;
+ position: absolute;
+ width: 40px;
+ height: 30px;
+ left: 75px;
+ top: 75px;
+ background: coral;
+ }
+
+ #anchored {
+ position: absolute;
+ background: seagreen;
+ width: 50px;
+ height: 50px;
+ }
+
+ #anchored.change {
+ /* The fallbacks match what the unchanged style says, but we shouldn't
+ take the fallbacks here. */
+ width: anchor-size(--a width, 50px);
+ height: anchor-size(--a height, 50px);
+ }
+</style>
+<div id=cb>
+ <div id=anchor></div>
+ <div id=anchored>X</div>
+</div>
+<script>
+ test(() => {
+ assert_equals(anchored.offsetWidth, 50);
+ assert_equals(anchored.offsetHeight, 50);
+
+ anchored.classList.toggle('change');
+
+ assert_equals(anchored.offsetWidth, 40);
+ assert_equals(anchored.offsetHeight, 30);
+ }, 'Correct invalidation when fallbacks match the old style');
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-inherited.html b/testing/web-platform/tests/css/css-anchor-position/anchor-inherited.html
new file mode 100644
index 0000000000..0f84311d6d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-inherited.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<title>Tests that anchor functions inherit as pixels</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+<script src="/css/css-anchor-position/support/test-common.js"></script>
+
+<style>
+.cb {
+ width: 400px;
+ height: 400px;
+ position: relative;
+ border: 1px solid black;
+}
+
+.anchor {
+ width: 100px;
+ height: 100px;
+ top: 10px;
+ left: 20px;
+ position: absolute;
+ background: red;
+ anchor-name: --a;
+}
+
+.anchored {
+ position-anchor: --a;
+ position: absolute;
+ /* Anchored directly on top */
+ top: anchor(top);
+ left: anchor(left);
+ width: anchor-size(width);
+ height: anchor-size(height);
+ background: coral;
+}
+
+/* The child should have the same size as the anchored element,
+ and inset by top:10px,left:20px vs. that element. */
+.child {
+ position-anchor: --unknown; /* Should have no effect. */
+ position: relative;
+ background: skyblue;
+ top: inherit;
+ left: inherit;
+ width: inherit;
+ height: inherit;
+}
+
+</style>
+
+<body onload="checkLayoutForAnchorPos('.child')">
+
+<div class=cb>
+ <div class=anchor></div>
+ <div class=anchored>
+ <div class=child
+ data-offset-x=20 data-offset-y=10
+ data-expected-width=100 data-expected-height=100></div>
+ </div>
+</div>
+
+</body>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-invalid-fallback.html b/testing/web-platform/tests/css/css-anchor-position/anchor-invalid-fallback.html
new file mode 100644
index 0000000000..4768beac62
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-invalid-fallback.html
@@ -0,0 +1,234 @@
+<!DOCTYPE html>
+<title>CSS Anchor Position Test: invalid at computed-value time</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-valid">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-size-valid">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ :root {
+ --top: top;
+ }
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: 1px solid black;
+ }
+
+ #anchor {
+ anchor-name: --a;
+ position: absolute;
+ width: 50px;
+ height: 40px;
+ left: 75px;
+ top: 75px;
+ background: coral;
+ }
+
+ #main > div, #ref {
+ position: absolute;
+ background: seagreen;
+ }
+
+ #ref {
+ inset: unset;
+ width: unset;
+ height: unset;
+ min-width: unset;
+ min-height: unset;
+ max-width: unset;
+ max-height: unset;
+ }
+
+</style>
+<div id=cb>
+ <div id=anchor></div>
+ <div id=main></div>
+ <div id=ref>X</div>
+</div>
+<script>
+
+// Append <div>X</div> to `container`, and remove it again once the test (`t`)
+// is finished.
+function createTarget(t, container) {
+ t.add_cleanup(() => { container.replaceChildren(); });
+ let target = document.createElement('div');
+ target.textContent = 'X';
+ container.append(target);
+ return target;
+}
+
+// First, some sanity checks to verify that the anchor etc is set up correctly,
+// and that anchor() queries can produce results if done correctly.
+
+test((t) => {
+ let target = createTarget(t, main);
+ target.style = `
+ position-anchor: --a;
+ left:anchor(right);
+ top:anchor(top);
+ width:anchor-size(width);
+ height:anchor-size(height);
+ `;
+ let cs = getComputedStyle(target);
+ assert_equals(cs.left, '125px');
+ assert_equals(cs.top, '75px');
+ assert_equals(cs.width, '50px');
+ assert_equals(cs.height, '40px');
+}, 'Element can be anchor positioned');
+
+test((t) => {
+ let target = createTarget(t, main);
+ target.style = `
+ /* No position-anchor here */
+ left:anchor(right, 17px);
+ top:anchor(top, 18px);
+ width:anchor-size(width, 42px);
+ height:anchor-size(height, 43px);
+ `;
+ let cs = getComputedStyle(target);
+ assert_equals(cs.left, '17px');
+ assert_equals(cs.top, '18px');
+ assert_equals(cs.width, '42px');
+ assert_equals(cs.height, '43px');
+}, 'Element can use <length> fallback if present');
+
+// Now test that any invalid anchor*() behaves as invalid at computed-value
+// time if there's no fallback specified.
+
+// Check that an anchored element with the specified style has the same
+// computed insets and sizing as the reference element (#ref), i.e. all
+// insets and sizing properties behave as 'unset'.
+function test_ref(style, description) {
+ test((t) => {
+ let target = createTarget(t, main);
+ target.style = style;
+ let cs = getComputedStyle(target);
+ let ref_cs = getComputedStyle(ref);
+ assert_equals(cs.top, ref_cs.top, 'top');
+ assert_equals(cs.left, ref_cs.left, 'left');
+ assert_equals(cs.right, ref_cs.right, 'right');
+ assert_equals(cs.bottom, ref_cs.bottom, 'bottom');
+ assert_equals(cs.width, ref_cs.width, 'width');
+ assert_equals(cs.height, ref_cs.height, 'height');
+ assert_equals(cs.minWidth, ref_cs.minWidth, 'minWidth');
+ assert_equals(cs.minHeight, ref_cs.minHeight, 'minHeight');
+ assert_equals(cs.maxWidth, ref_cs.maxWidth, 'maxWidth');
+ assert_equals(cs.maxHeight, ref_cs.maxHeight, 'maxHeight');
+ }, `Invalid anchor function, ${description}`);
+}
+
+// No default anchor (position-anchor):
+test_ref('left:anchor(left)', 'left');
+test_ref('right:anchor(right)', 'right');
+test_ref('bottom:anchor(bottom)', 'bottom');
+test_ref('top:anchor(top)', 'top');
+test_ref('width:anchor-size(width)', 'width');
+test_ref('height:anchor-size(height)', 'height');
+test_ref('min-width:anchor-size(width)', 'min-width');
+test_ref('min-height:anchor-size(height)', 'min-height');
+test_ref('max-width:anchor-size(width)', 'max-width');
+test_ref('max-height:anchor-size(height)', 'max-height');
+
+// Unknown anchor reference:
+test_ref('left:anchor(--unknown left)', '--unknown left');
+test_ref('width:anchor-size(--unknown width)', '--unknown width');
+
+// Wrong axis;
+test_ref('left:anchor(--a top)', 'cross-axis query (vertical)');
+test_ref('top:anchor(--a left)', ' cross-axis query (horizontal)');
+
+// Wrong query for the given property:
+test_ref('top:anchor-size(--a width)', 'anchor-size() in inset');
+test_ref('width:anchor(--a left)', 'anchor() in sizing property');
+
+// Invalid anchor*() deeper within calc():
+test_ref('left:calc(anchor(left) + 10px)', 'nested left');
+test_ref('right:calc(anchor(right) + 10px)', 'nested right');
+test_ref('bottom:calc(anchor(bottom) + 10px)', 'nested bottom');
+test_ref('top:calc(anchor(top) + 10px)', 'nested top');
+test_ref('min-width:calc(anchor-size(width) + 10px)', 'nested min-width');
+test_ref('min-height:calc(anchor-size(height) + 10px)', 'nested min-height');
+test_ref('max-width:calc(anchor-size(width) + 10px)', 'nested max-width');
+test_ref('max-height:calc(anchor-size(height) + 10px)', 'nested max-height');
+
+// Invalid anchor*() within fallback:
+test_ref('top:anchor(top, anchor(--unknown top))', 'invalid anchor() in fallback');
+test_ref('width:anchor-size(width, anchor-size(--unknown width))', 'invalid anchor-size() in fallback');
+
+// Non-calc() functions:
+test_ref('top:min(10px, anchor(top))', 'min()');
+test_ref('top:max(10px, anchor(top))', 'max()');
+test_ref('top:abs(anchor(top) - 100px)', 'abs()');
+test_ref('top:calc(sign(anchor(top) - 100px) * 20px)', 'sign()');
+
+// var():
+test_ref('top:anchor(var(--top))', 'anchor(var())');
+test_ref('top:anchor(var(--unknown, top))', 'anchor(unknown var()) (fallback)');
+test_ref('top:anchor(var(--unknown))', 'anchor(unknown var()) (no fallback)');
+
+// Reverting to an invalid anchor():
+test((t) => {
+ let target = createTarget(t, main);
+ target.setAttribute('id', 'target');
+
+ let css = document.createElement('style');
+ css.textContent = `
+ @layer base {
+ #target {
+ top: anchor(top); /* Invalid */
+ color: green;
+ }
+ }
+ #target {
+ top: revert-layer; /* Reverts to 'base'. */
+ }
+ `;
+
+ t.add_cleanup(() => { css.remove(); })
+ cb.append(css);
+
+ let cs = getComputedStyle(target);
+ let ref_cs = getComputedStyle(ref);
+ // The color check verifies that the rule is applied at all.
+ assert_equals(cs.color, 'rgb(0, 128, 0)');
+ assert_equals(cs.top, ref_cs.top);
+}, 'Revert to invalid anchor()');
+
+// Using <try-tactic> to flip to an invalid anchor():
+test((t) => {
+ let target = createTarget(t, main);
+ target.setAttribute('id', 'target');
+
+ let css = document.createElement('style');
+ css.textContent = `
+ @position-try --pt {
+ /* Undo force overflow, and also use this value to check that
+ the rule is applied at all. */
+ left: 10px;
+
+ /* Invalid. Becomes bottom:anchor(bottom) (also invalid)
+ after flip-block. */
+ top: anchor(top);
+ }
+
+ #target {
+ left: 9999px; /* Force overflow. */
+ position-try-options: --pt flip-block;
+ }
+ `;
+
+ t.add_cleanup(() => { css.remove(); })
+ cb.append(css);
+
+ let cs = getComputedStyle(target);
+ let ref_cs = getComputedStyle(ref);
+ assert_equals(cs.left, '10px', 'left');
+ // 'right' is not important in this test.
+
+ assert_equals(cs.top, ref_cs.top, 'top');
+ assert_equals(cs.bottom, ref_cs.bottom, 'bottom');
+}, 'Flip to invalid anchor()');
+
+</script>
+
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-001.tentative.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-001.html
index 1235f8fad4..3a86da5f70 100644
--- a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-001.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-001.html
@@ -2,7 +2,7 @@
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:wangxianzhu@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
-<link rel="match" href="reference/anchor-scroll-chained-001.tentative-ref.html">
+<link rel="match" href="reference/anchor-scroll-chained-001-ref.html">
<style>
body {
margin: 0;
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-002.tentative.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-002.html
index 9c60799e0b..38dadba5c8 100644
--- a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-002.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-002.html
@@ -2,7 +2,7 @@
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:wangxianzhu@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
-<link rel="match" href="reference/anchor-scroll-chained-002.tentative-ref.html">
+<link rel="match" href="reference/anchor-scroll-chained-002-ref.html">
<style>
body {
margin: 0;
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-003.tentative.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-003.html
index b441c92bf1..6352ebbfb6 100644
--- a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-003.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-003.html
@@ -2,7 +2,7 @@
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:wangxianzhu@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
-<link rel="match" href="reference/anchor-scroll-chained-002.tentative-ref.html">
+<link rel="match" href="reference/anchor-scroll-chained-002-ref.html">
<style>
body {
margin: 0;
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-004.tentative.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-004.html
index f1765a9870..b31519f580 100644
--- a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-004.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-004.html
@@ -2,7 +2,7 @@
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:wangxianzhu@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
-<link rel="match" href="reference/anchor-scroll-chained-004.tentative-ref.html">
+<link rel="match" href="reference/anchor-scroll-chained-004-ref.html">
<style>
body {
margin: 0;
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-fallback.html
index d2300da818..221df77b06 100644
--- a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-chained-fallback.html
@@ -2,7 +2,7 @@
<title>Tests scroll adjustments of element anchored to another anchored element with fallback</title>
<link rel="author" href="mailto:wangxianzhu@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
-<link rel="match" href="reference/anchor-scroll-chained-fallback.tentative-ref.html">
+<link rel="match" href="reference/anchor-scroll-chained-fallback-ref.html">
<style>
body {
margin: 0;
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden-ref.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden-ref.html
new file mode 100644
index 0000000000..b674998a5d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden-ref.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<link rel="stylesheet" href="/fonts/ahem.css">
+<style>
+body {
+ font: 20px/1 Ahem;
+ margin: 0;
+}
+
+#placefiller-above-anchor {
+ height: 200px;
+}
+
+#placefiller-before-anchor {
+ display: inline-block;
+ width: 50px;
+}
+
+#inner-anchored {
+ color: green;
+ position: fixed;
+ left: 70px;
+ top: 180px;
+}
+
+#outer-anchored {
+ color: yellow;
+ position: fixed;
+ left: 70px;
+ top: 220px;
+}
+</style>
+
+<div id="placefiller-above-anchor"></div>
+<div id="placefiller-before-anchor"></div>
+<span id="anchor">anchor</span>
+<div id="inner-anchored">inner-anchored</div>
+<div id="outer-anchored">outer-anchored</div>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden.html
new file mode 100644
index 0000000000..b57e39956b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-overflow-hidden.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<title>Basic of anchor positioned scrolling: anchored elements should be "pinned" to the anchor when anchor is scrolled in overflow:hidden</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
+<link rel="match" href="anchor-scroll-overflow-hidden-ref.html">
+<link rel="stylesheet" href="/fonts/ahem.css">
+<style>
+body {
+ font: 20px/1 Ahem;
+ margin: 0;
+}
+
+#scroll-container {
+ width: 400px;
+ height: 400px;
+ overflow: hidden;
+}
+
+#scroll-contents {
+ width: 1000px;
+ height: 1000px;
+}
+
+#placefiller-above-anchor {
+ height: 500px;
+}
+
+#placefiller-before-anchor {
+ display: inline-block;
+ width: 500px;
+}
+
+#anchor {
+ anchor-name: --anchor;
+}
+
+#inner-anchored {
+ color: green;
+ position: absolute;
+ left: anchor(--anchor left);
+ bottom: anchor(--anchor top);
+ position-anchor: --anchor;
+}
+
+#outer-anchored {
+ color: yellow;
+ position: absolute;
+ left: anchor(--anchor left);
+ top: anchor(--anchor bottom);
+ position-anchor: --anchor;
+}
+</style>
+
+<div id="scroll-container">
+ <div id="scroll-contents">
+ <div id="placefiller-above-anchor"></div>
+ <div id="placefiller-before-anchor"></div>
+ <span id="anchor">anchor</span>
+ <div id="inner-anchored">inner-anchored</div>
+ </div>
+</div>
+<div id="outer-anchored">outer-anchored</div>
+
+<script>
+const scroller = document.getElementById('scroll-container');
+scroller.scrollTop = 300;
+scroller.scrollLeft = 450;
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-013.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-013.html
new file mode 100644
index 0000000000..3f1330d744
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-013.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#scroll">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-apply">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/test-common.js"></script>
+<style>
+#cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: solid 1px;
+}
+
+#scroller {
+ width: 200px;
+ height: 200px;
+ overflow: scroll;
+}
+
+#abspos {
+ position: absolute;
+ background: hotpink;
+ width: 50px;
+ height: 50px;
+
+ inset-area: bottom;
+ position-try-options: flip-block;
+ position-anchor: --a;
+}
+
+#anchor {
+ anchor-name: --a;
+ width: 50px;
+ height: 50px;
+ margin: 150px 0 150px 50px;
+ background: dodgerblue;
+}
+
+</style>
+<div id="cb">
+ <div id="scroller">
+ <div id="anchor">
+ </div>
+ </div>
+ <div id="abspos"></div>
+</div>
+
+<script>
+promise_test(async () => {
+ await waitUntilNextAnimationFrame();
+ assert_fallback_position(abspos, anchor, 'top');
+});
+
+promise_test(async () => {
+ scroller.scrollTop = 50;
+ await waitUntilNextAnimationFrame();
+ assert_fallback_position(abspos, anchor, 'bottom');
+});
+
+promise_test(async () => {
+ scroller.scrollTop = 40;
+ await waitUntilNextAnimationFrame();
+ assert_fallback_position(abspos, anchor, 'top');
+});
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-014.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-014.html
new file mode 100644
index 0000000000..f19f41c088
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-position-try-014.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#scroll">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-apply">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/test-common.js"></script>
+<style>
+#cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: solid 1px;
+}
+
+#scroller {
+ width: 200px;
+ height: 200px;
+ overflow: scroll;
+ display: flex;
+ flex-direction: column-reverse;
+}
+
+#abspos {
+ position: absolute;
+ background: hotpink;
+ width: 50px;
+ height: 50px;
+
+ inset-area: top;
+ position-try-options: flip-block;
+ position-anchor: --a;
+}
+
+#anchor {
+ anchor-name: --a;
+ width: 50px;
+ min-height: 50px;
+ flex: 0;
+ margin: 150px 0 150px 50px;
+ background: dodgerblue;
+}
+
+</style>
+<div id="cb">
+ <div id="scroller">
+ <div id="anchor">
+ </div>
+ </div>
+ <div id="abspos"></div>
+</div>
+
+<script>
+promise_test(async () => {
+ await waitUntilNextAnimationFrame();
+ assert_fallback_position(abspos, anchor, 'bottom');
+});
+
+promise_test(async () => {
+ scroller.scrollTop = -100;
+ await waitUntilNextAnimationFrame();
+ assert_fallback_position(abspos, anchor, 'top');
+});
+
+promise_test(async () => {
+ scroller.scrollTop = -50;
+ await waitUntilNextAnimationFrame();
+ assert_fallback_position(abspos, anchor, 'bottom');
+});
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor-ref.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor-ref.html
new file mode 100644
index 0000000000..3528b565fc
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor-ref.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<style>
+#scroll-container {
+ width: 400px;
+ height: 400px;
+ overflow: scroll;
+}
+
+#scroll-contents {
+ width: 1000px;
+ height: 1000px;
+ position: relative;
+}
+
+#anchor {
+ anchor-name: --anchor;
+ height: 100px;
+ width: 100px;
+ overflow: scroll;
+}
+
+#anchored {
+ background: green;
+ width: 100px;
+ height: 100px;
+}
+</style>
+
+<div id="scroll-container">
+ <div id="scroll-contents">
+ <div style="height: 400px"></div>
+ <div id="anchored"></div>
+ <div id="anchor">
+ <div style="height: 500px"></div>
+ </div>
+ </div>
+</div>
+
+<script>
+document.getElementById('scroll-container').scrollTop = 300;
+document.getElementById('anchor').scrollTop = 300;
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor.html b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor.html
new file mode 100644
index 0000000000..c2a256877d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-scroll-scrollable-anchor.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<title>Basic of anchor positioned scrolling: scroll of a scrollable anchor should not affect anchor positioing</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
+<link rel="match" href="anchor-scroll-scrollable-anchor-ref.html">
+<style>
+#scroll-container {
+ width: 400px;
+ height: 400px;
+ overflow: scroll;
+ will-change: scroll-position;
+}
+
+#scroll-contents {
+ width: 1000px;
+ height: 1000px;
+ position: relative;
+}
+
+.placefiller {
+ height: 500px;
+}
+
+#anchor {
+ anchor-name: --anchor;
+ height: 100px;
+ width: 100px;
+ overflow: scroll;
+ will-change: scroll-position;
+}
+
+#anchored {
+ background: green;
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: anchor(left);
+ bottom: anchor(top);
+ position-anchor: --anchor;
+}
+</style>
+
+<div id="scroll-container">
+ <div id="scroll-contents">
+ <div class="placefiller"></div>
+ <div id="anchor">
+ <div class="placefiller"></div>
+ </div>
+ </div>
+</div>
+<div id="anchored"></div>
+
+<script>
+document.getElementById('scroll-container').scrollTop = 300;
+document.getElementById('anchor').scrollTop = 300;
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/at-position-try-cssom.html b/testing/web-platform/tests/css/css-anchor-position/at-position-try-cssom.html
index 91172c5185..42f82d9d4b 100644
--- a/testing/web-platform/tests/css/css-anchor-position/at-position-try-cssom.html
+++ b/testing/web-platform/tests/css/css-anchor-position/at-position-try-cssom.html
@@ -24,7 +24,7 @@ test(t => {
const positionTryRule = style.sheet.cssRules[0];
assert_true(positionTryRule instanceof CSSPositionTryRule);
assert_equals(positionTryRule.name, '--pf');
- assert_true(positionTryRule.style instanceof CSSStyleDeclaration);
+ assert_true(positionTryRule.style instanceof CSSPositionTryDescriptors);
assert_equals(positionTryRule.style.length, 1);
assert_equals(positionTryRule.style.left, 'anchor(right)');
}, 'CSSPositionTryRule attribute values');
@@ -63,4 +63,140 @@ test(t => {
}, 'CSSPositionTryRule.style.setProperty setting allowed and disallowed properties');
+test(t => {
+ const style = createStyle(t, `
+ @position-try --pf {
+ top: 10px;
+ left: 20px;
+ --x: 200px;
+ color: red;
+ }
+ `);
+ let declarations = style.sheet.cssRules[0].style;
+ assert_equals(declarations.length, 2);
+ assert_equals(declarations.item(0), 'top');
+ assert_equals(declarations.item(1), 'left');
+}, 'CSSPositionTryDescriptors.item');
+
+test(t => {
+ const style = createStyle(t, '@position-try --pf {}');
+ let declarations = style.sheet.cssRules[0].style;
+ assert_equals(declarations.length, 0);
+ declarations.cssText = `color:red;top:10px;`;
+ assert_equals(declarations.length, 1);
+}, 'CSSPositionTryDescriptors.cssText');
+
+let supported_properties = [
+ 'margin',
+ 'margin-top',
+ 'margin-right',
+ 'margin-bottom',
+ 'margin-left',
+ 'margin-block',
+ 'margin-block-start',
+ 'margin-block-end',
+ 'margin-inline',
+ 'margin-inline-start',
+ 'margin-inline-end',
+ 'inset',
+ 'top',
+ 'left',
+ 'right',
+ 'bottom',
+ 'inset-block',
+ 'inset-block-start',
+ 'inset-block-end',
+ 'inset-inline',
+ 'inset-inline-start',
+ 'inset-inline-end',
+ 'width',
+ 'height',
+ 'min-width',
+ 'max-width',
+ 'min-height',
+ 'max-height',
+ 'block-size',
+ 'min-block-size',
+ 'max-block-size',
+ 'inline-size',
+ 'min-inline-size',
+ 'max-inline-size',
+ 'place-self',
+ 'align-self',
+ 'justify-self',
+ 'position-anchor',
+ 'inset-area',
+];
+
+// A selection of unsupported properties.
+let unsupported_properties = [
+ 'color',
+ 'align-items',
+ 'align-content',
+ 'background',
+ 'display',
+ 'position',
+ 'writing-mode',
+ 'direction',
+ 'syntax', // @property
+];
+
+let upperFirst = (x) => x[0].toUpperCase() + x.slice(1);
+let lowerFirst = (x) => x[0].toLowerCase() + x.slice(1);
+let toLowerCamelCase = (x) => lowerFirst(x.split('-').map(upperFirst).join(''));
+
+// Test getting/setting the specified property on a CSSPositionTryDescriptors
+// object. The property can either be supported or not supported,
+// which determines the expected results.
+function test_property(prop, supported) {
+ test(t => {
+ let decls = supported_properties.map(x => `${x}:unset;`).join('');
+ let style = createStyle(t, `@position-try --pf { ${decls} }`);
+ let declarations = style.sheet.cssRules[0].style;
+ assert_equals(declarations.getPropertyValue(prop), supported ? 'unset' : '');
+ }, `CSSPositionTryDescriptors.getPropertyValue(${prop})`);
+
+ test(t => {
+ let style = createStyle(t, '@position-try --pf {}');
+ let declarations = style.sheet.cssRules[0].style;
+ declarations.setProperty(prop, 'unset');
+ assert_equals(declarations.getPropertyValue(prop), supported ? 'unset' : '');
+ }, `CSSPositionTryDescriptors.setProperty(${prop})`);
+
+ test(t => {
+ let decls = supported_properties.map(x => `${x}:unset;`).join('');
+ let style = createStyle(t, `@position-try --pf { ${decls} }`);
+ let declarations = style.sheet.cssRules[0].style;
+ assert_equals(declarations[prop], supported ? 'unset' : undefined);
+ }, `CSSPositionTryDescriptors[${prop}] (set)`);
+
+ test(t => {
+ let style = createStyle(t, '@position-try --pf {}');
+ let declarations = style.sheet.cssRules[0].style;
+ declarations[prop] = 'unset';
+ assert_equals(declarations.getPropertyValue(prop), supported ? 'unset' : '');
+ }, `CSSPositionTryDescriptors[${prop}] (get)`);
+
+ let camelCaseAttr = toLowerCamelCase(prop);
+ if (camelCaseAttr != prop) {
+ // Also test the camelCase version of the attribute.
+ test(t => {
+ let decls = supported_properties.map(x => `${x}:unset;`).join('');
+ let style = createStyle(t, `@position-try --pf { ${decls} }`);
+ let declarations = style.sheet.cssRules[0].style;
+ assert_equals(declarations[camelCaseAttr], supported ? 'unset' : undefined);
+ }, `CSSPositionTryDescriptors[${camelCaseAttr}] (get)`);
+
+ test(t => {
+ let style = createStyle(t, '@position-try --pf {}');
+ let declarations = style.sheet.cssRules[0].style;
+ declarations[camelCaseAttr] = 'unset';
+ assert_equals(declarations.getPropertyValue(prop), supported ? 'unset' : '');
+ }, `CSSPositionTryDescriptors[${camelCaseAttr}] (set)`);
+ }
+}
+
+supported_properties.forEach(x => { test_property(x, /* supported */ true); });
+unsupported_properties.forEach(x => { test_property(x, /* supported */ false); });
+
</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/base-style-invalidation.html b/testing/web-platform/tests/css/css-anchor-position/base-style-invalidation.html
new file mode 100644
index 0000000000..8e8e69f9b7
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/base-style-invalidation.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: Invalidation from changing the base style</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/">
+<link rel="help" href="https://issues.chromium.org/issues/333608683">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ @position-try --pt {
+ width: 50px; /* Undo force overflow */
+ }
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: 1px solid black;
+ }
+ #anchor {
+ position: absolute;
+ left: 75px;
+ top: 75px;
+ width: 50px;
+ height: 50px;
+ background: coral;
+ anchor-name: --a;
+ }
+ #anchored {
+ position: absolute;
+ position-anchor: --a;
+ position-try-options: --pt flip-start;
+ inset: 0;
+ top: anchor(top);
+ bottom: anchor(bottom);
+ right: calc(anchor(left) + 5px);
+ width: 50px;
+ height: 50px;
+ background: skyblue;
+ justify-self: end;
+ }
+ #anchored.flip {
+ background: seagreen;
+ width: 300px; /* Force overflow */
+ }
+</style>
+<div id=cb>
+ <div id=anchor></div>
+ <div id=anchored></div>
+</div>
+<script>
+ test(() => {
+ // Initially to the left.
+ assert_equals(anchored.offsetLeft, 20);
+ assert_equals(anchored.offsetTop, 75);
+
+ // Flips to the right.
+ anchored.classList.toggle('flip');
+ assert_equals(anchored.offsetLeft, 75);
+ assert_equals(anchored.offsetTop, 20);
+
+ // Flips to the original position.
+ anchored.classList.toggle('flip');
+ assert_equals(anchored.offsetLeft, 20);
+ assert_equals(anchored.offsetTop, 75);
+ }, 'The chosen position options changes when the base style differs');
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/chrome-336164421-crash.html b/testing/web-platform/tests/css/css-anchor-position/chrome-336164421-crash.html
new file mode 100644
index 0000000000..c45b69059b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/chrome-336164421-crash.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<link rel="help" href="https://crbug.com/336164421">
+<style>
+ #inner {
+ position: absolute;
+ left: anchor(left);
+ }
+ #inner::before {
+ display: none;
+ content: "";
+ }
+</style>
+<div id="inner"></div>
diff --git a/testing/web-platform/tests/css/css-anchor-position/chrome-336322507-crash.html b/testing/web-platform/tests/css/css-anchor-position/chrome-336322507-crash.html
new file mode 100644
index 0000000000..922c53b977
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/chrome-336322507-crash.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link rel="help" href="https://crbug.com/336322507">
+<style>
+ #crash {
+ --grad: linear-gradient(black, white);
+ background: var(--grad);
+ position: absolute;
+ top: anchor(center);
+ }
+</style>
+<div id="crash"></div>
+<script>
+ document.body.offsetTop;
+ crash.remove();
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/inset-area-function.html b/testing/web-platform/tests/css/css-anchor-position/inset-area-function.html
new file mode 100644
index 0000000000..9d68bf9ddf
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/inset-area-function.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: inset-area()</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-try-options">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: 1px solid black;
+ }
+ #anchor {
+ position: absolute;
+ left: 100px;
+ top: 100px;
+ width: 80px;
+ height: 80px;
+ background-color: tomato;
+ anchor-name: --a;
+ }
+ #target, #ref {
+ position: absolute;
+ width: 40px;
+ height: 40px;
+ background-color: skyblue;
+ inset-area: bottom right;
+ position-anchor: --a;
+ }
+ #ref {
+ background-color: seagreen;
+ }
+</style>
+<style id=style>
+</style>
+<div id=cb>
+ <div id=anchor></div>
+ <div id=target></div>
+ <div id=ref></div>
+</div>
+<script>
+
+// Test that a given inset-area() produces the same result as a reference
+// element that is styled with an inset-area declaration directly.
+function test_inset_area_fn(inset_area_function, inset_area_expected) {
+ test((t) => {
+ t.add_cleanup(() => {
+ style.textContent = '';
+ });
+ style.textContent = `
+ #target {
+ position-try-options: ${inset_area_function};
+ }
+ #ref {
+ inset-area: ${inset_area_expected};
+ }
+ `;
+ assert_equals(target.offsetLeft, ref.offsetLeft, 'offsetLeft');
+ assert_equals(target.offsetTop, ref.offsetTop, 'offsetTop');
+ }, `${inset_area_function}, ${inset_area_expected}`);
+}
+
+test_inset_area_fn('inset-area(top left)', 'top left');
+test_inset_area_fn('inset-area(span-top left)', 'span-top left');
+test_inset_area_fn('inset-area(top span-left)', 'top span-left');
+test_inset_area_fn('inset-area(top center)', 'top center');
+test_inset_area_fn('inset-area(left center)', 'left center');
+test_inset_area_fn('inset-area(start center)', 'start center');
+test_inset_area_fn('inset-area(center start)', 'center start');
+
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/inset-area-in-position-try.html b/testing/web-platform/tests/css/css-anchor-position/inset-area-in-position-try.html
new file mode 100644
index 0000000000..7339c4f41d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/inset-area-in-position-try.html
@@ -0,0 +1,188 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: inset-area in @position-try</title>
+<link rel="help" href='https://drafts.csswg.org/css-anchor-position-1/#position-try-options'>
+<script src='/resources/testharness.js'></script>
+<script src='/resources/testharnessreport.js'></script>
+<style>
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ border: 1px solid black;
+ }
+ #anchor {
+ position: absolute;
+ left: 100px;
+ top: 100px;
+ width: 50px;
+ height: 50px;
+ background-color: tomato;
+ anchor-name: --a;
+ }
+ #target {
+ left: 200px; /* force fallback */
+ }
+ #target, #ref {
+ position: absolute;
+ width: 40px;
+ height: 40px;
+ background-color: skyblue;
+ inset-area: bottom right;
+ position-anchor: --a;
+ }
+ #ref {
+ background-color: seagreen;
+ }
+</style>
+<style id=style>
+</style>
+<div id=cb>
+ <div id=anchor></div>
+ <div id=target></div>
+ <div id=ref></div>
+</div>
+<script>
+
+// Test that inside-area, when used inside @position-try, works the same
+// as when it's specified in the base style.
+function test_inset_area_ref(inset_area) {
+ test((t) => {
+ t.add_cleanup(() => {
+ style.textContent = '';
+ });
+ style.textContent = `
+ @position-try --pt {
+ inset: unset; /* Undo force fallback */
+ inset-area: ${inset_area};
+ }
+ #target {
+ position-try-options: --pt;
+ }
+ #ref {
+ inset-area: ${inset_area};
+ }
+ `;
+ assert_true(CSS.supports('inset-area', 'top left'));
+ assert_true(CSS.supports('position-try-options', '--x'));
+ assert_equals(target.offsetLeft, ref.offsetLeft, 'offsetLeft');
+ assert_equals(target.offsetTop, ref.offsetTop, 'offsetTop');
+ }, `${inset_area}`);
+}
+
+test_inset_area_ref('none');
+test_inset_area_ref('span-all');
+test_inset_area_ref('span-all span-all');
+test_inset_area_ref('top left');
+test_inset_area_ref('top center');
+test_inset_area_ref('top right');
+test_inset_area_ref('center left');
+test_inset_area_ref('center center');
+test_inset_area_ref('center right');
+test_inset_area_ref('bottom left');
+test_inset_area_ref('bottom center');
+test_inset_area_ref('bottom right');
+test_inset_area_ref('start start');
+test_inset_area_ref('start center');
+test_inset_area_ref('start end');
+test_inset_area_ref('center start');
+test_inset_area_ref('center end');
+test_inset_area_ref('end start');
+test_inset_area_ref('end center');
+test_inset_area_ref('end end');
+test_inset_area_ref('self-start self-start');
+test_inset_area_ref('self-start center');
+test_inset_area_ref('self-start self-end');
+test_inset_area_ref('center self-start');
+test_inset_area_ref('center self-end');
+test_inset_area_ref('self-end self-start');
+test_inset_area_ref('self-end center');
+test_inset_area_ref('self-end self-end');
+test_inset_area_ref('y-start x-start');
+test_inset_area_ref('y-start center');
+test_inset_area_ref('y-start x-end');
+test_inset_area_ref('center x-start');
+test_inset_area_ref('center x-end');
+test_inset_area_ref('y-end x-start');
+test_inset_area_ref('y-end center');
+test_inset_area_ref('y-end x-end');
+test_inset_area_ref('y-self-start x-self-start');
+test_inset_area_ref('y-self-start center');
+test_inset_area_ref('y-self-start x-self-end');
+test_inset_area_ref('center x-self-start');
+test_inset_area_ref('center x-self-end');
+test_inset_area_ref('y-self-end x-self-start');
+test_inset_area_ref('y-self-end center');
+test_inset_area_ref('y-self-end x-self-end');
+test_inset_area_ref('span-y-self-start span-x-self-end');
+test_inset_area_ref('span-bottom span-all');
+
+</script>
+
+<style>
+ @position-try --top {
+ inset: unset; /* Undo force fallback */
+ inset-area: top;
+ }
+ @position-try --right {
+ inset: unset; /* Undo force fallback */
+ inset-area: right;
+ }
+ @position-try --bottom {
+ inset: unset; /* Undo force fallback */
+ inset-area: bottom;
+ }
+ @position-try --left {
+ inset: unset; /* Undo force fallback */
+ inset-area: left;
+ }
+</style>
+<script>
+
+// Test that an element with the specified position-try-options is placed
+// at the same position as a reference element with inset-area:`expected`.
+// This test uses #target/#ref size of 60x60px, which causes overflow if
+// if we attempt the --right and --bottom positions.
+function test_inset_area_placement(position_try_options, expected) {
+ test((t) => {
+ style.textContent = `
+ #target, #ref {
+ width: 60px;
+ height: 60px;
+ }
+ #target {
+ position-try-options: ${position_try_options};
+ }
+ #ref {
+ inset-area: ${expected};
+ }
+ `;
+ assert_true(CSS.supports('inset-area', 'top left'));
+ assert_true(CSS.supports('position-try-options', '--x'));
+ assert_equals(target.offsetLeft, ref.offsetLeft, 'offsetLeft');
+ assert_equals(target.offsetTop, ref.offsetTop, 'offsetTop');
+ }, `Placement: ${position_try_options}`);
+}
+
+test_inset_area_placement('--top', 'top');
+test_inset_area_placement('--left', 'left');
+
+// No space to to the right/bottom:
+test_inset_area_placement('--right, --top', 'top');
+test_inset_area_placement('--bottom, --top', 'top');
+test_inset_area_placement('--bottom, --right, --top', 'top');
+test_inset_area_placement('--bottom, --right, --left, --top', 'left');
+test_inset_area_placement('--bottom, --left, --top, --right', 'left');
+
+// Flipping:
+test_inset_area_placement('--right flip-inline', 'left');
+test_inset_area_placement('--bottom flip-block', 'top');
+test_inset_area_placement('--left flip-start', 'top');
+
+// left + flip-inline => right (no space).
+test_inset_area_placement('--left flip-inline, --top', 'top');
+// top + flip-block => bottom (no space).
+test_inset_area_placement('--top flip-block, --left', 'left');
+// left + flip-start flip-block => bottom (no space).
+test_inset_area_placement('--left flip-start flip-block, --left', 'left');
+
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-computed.tentative.html b/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-computed.tentative.html
index ff4ceb73df..8a8ba88706 100644
--- a/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-computed.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-computed.tentative.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: Computed position-visibility</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-parsing.tentative.html b/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-parsing.tentative.html
index 18dd27eadb..942ec71754 100644
--- a/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-parsing.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/parsing/position-visibility-parsing.tentative.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: Parsing of position-visibility</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-try-backdrop.html b/testing/web-platform/tests/css/css-anchor-position/position-try-backdrop.html
new file mode 100644
index 0000000000..6bf2262c69
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-try-backdrop.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: position-try-options on ::backdrop</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-apply">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ @position-try --pt {
+ left: 300px;
+ }
+ #anchor {
+ width: 100px;
+ height: 100px;
+ margin-left: 150px;
+ margin-top: 50px;
+ background: coral;
+ }
+ dialog::backdrop {
+ background: seagreen;
+ width:100px;
+ height:100px;
+ left: 9999px; /* Force overflow */
+ position-try-options: --pt;
+ }
+</style>
+<div id=anchor>Anchor</div>
+<dialog id=dialog>Dialog</dialog>
+<script>
+ test((t) => {
+ dialog.showModal();
+ let style = getComputedStyle(dialog, '::backdrop');
+ assert_equals(style.left, '300px');
+ }, '::backdrop can use position-try-options');
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-try-order-inset-area.html b/testing/web-platform/tests/css/css-anchor-position/position-try-order-inset-area.html
new file mode 100644
index 0000000000..98e606a7d8
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-try-order-inset-area.html
@@ -0,0 +1,196 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: position-try-order behavior with inset-area</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-try-order-property">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#inset-area">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<!--
+ Note: This test is the inset-area version of position-try-order-basic.html.
+-->
+<style>
+ #cb {
+ position: absolute;
+ width: 400px;
+ height: 400px;
+ border: 1px solid black;
+ }
+ #anchor {
+ position: absolute;
+ left: 150px;
+ top: 200px;
+ width: 150px;
+ height: 150px;
+ background-color: coral;
+ anchor-name: --a;
+ }
+ #target, #ref {
+ position: absolute;
+ left: 450px; /* force fallback */
+ width: 40px;
+ height: 40px;
+ background-color: skyblue;
+ position-anchor: --a;
+ /* Note: align/justify is for cosmetic/debugging reasons only,
+ it should not have any effect on the result. */
+ align-self: start;
+ justify-self: start;
+ }
+ #ref {
+ background-color: seagreen;
+ }
+
+/*
+
+The IMCB for --right is the whole area to the right of the anchor, and similarly
+for --left, etc.
+
+ ┌──────────────┐
+ │ xxxx│
+ │ xxxx│
+ │ ┌────┐xxxx│
+ │ │ │xxxx│
+ │ └────┘xxxx│
+ │ xxxx│
+ │ xxxx│
+ └──────────────┘
+
+**/
+
+ @position-try --right {
+ inset: unset;
+ inset-area: right;
+ }
+ @position-try --left {
+ inset: unset;
+ inset-area: left;
+ }
+ @position-try --top {
+ inset: unset;
+ inset-area: top;
+ }
+ @position-try --bottom {
+ inset: unset;
+ inset-area: bottom;
+ }
+
+/*
+
+The IMCB for --right-sweep is the area that would be "swept" by the anchor if it
+moved right, and similarly for --left-sweep, etc.
+
+ ┌──────────────┐
+ │ │
+ │ │
+ │ ┌────┐xxxx│
+ │ │ │xxxx│
+ │ └────┘xxxx│
+ │ │
+ │ │
+ └──────────────┘
+
+*/
+
+ @position-try --right-sweep {
+ inset: unset;
+ inset-area: right center;
+ }
+
+ @position-try --left-sweep {
+ inset: unset;
+ inset-area: left center;
+ }
+
+ @position-try --bottom-sweep {
+ inset: unset;
+ inset-area: bottom center;
+ }
+
+ @position-try --top-sweep {
+ inset: unset;
+ inset-area: top center;
+ }
+
+</style>
+<style id=style>
+</style>
+<div id=cb>
+ <div id=anchor></div>
+ <div id=target></div>
+ <div id=ref></div>
+</div>
+<script>
+
+// Test that an element with the specified `position_try` gets the same
+// position as a reference element with `position_try_expected`.
+function test_inset_area_order(position_try, position_try_expected) {
+ test((t) => {
+ style.textContent = `
+ #target {
+ position-try: ${position_try};
+ }
+ #ref {
+ position-try: ${position_try_expected};
+ }
+ `;
+ assert_true(CSS.supports('position-try', 'normal --x'));
+ assert_equals(target.offsetLeft, ref.offsetLeft, 'offsetLeft');
+ assert_equals(target.offsetTop, ref.offsetTop, 'offsetTop');
+ }, `${position_try} | ${position_try_expected}`);
+}
+
+// Note: --right, --left, --top, and --bottom all fit, but have different
+// inset-modifed containing blocks.
+
+test_inset_area_order('--right', '--right');
+test_inset_area_order('--left', '--left');
+test_inset_area_order('--top', '--top');
+test_inset_area_order('--bottom', '--bottom');
+
+// position-try-order:normal just picks the first option.
+test_inset_area_order('--right, --left, --bottom, --top', '--right');
+test_inset_area_order('normal --right, --left, --bottom, --top', '--right');
+test_inset_area_order('normal --top, --left, --bottom, --right', '--top');
+
+// --right and --left have the same IMCB block-size.
+test_inset_area_order('most-block-size --right, --left', '--right');
+test_inset_area_order('most-height --right, --left', '--right');
+// --left has more inline-size than --right.
+test_inset_area_order('most-inline-size --right, --left', '--left');
+test_inset_area_order('most-width --right, --left', '--left');
+
+// --bottom and --top have the same IMCB inline-size.
+test_inset_area_order('most-inline-size --bottom, --top', '--bottom');
+test_inset_area_order('most-width --bottom, --top', '--bottom');
+// --top has more block-size than --bottom.
+test_inset_area_order('most-block-size --bottom, --top', '--top');
+test_inset_area_order('most-height --bottom, --top', '--top');
+
+// --bottom/--top has more IMBC inline-size than --right/--left.
+test_inset_area_order('most-inline-size --right, --left, --bottom, --top', '--bottom');
+test_inset_area_order('most-inline-size --right, --left, --top, --bottom', '--top');
+
+// --right/--left has more IMBC block-size than --bottom/--top.
+test_inset_area_order('most-block-size --bottom, --top, --right, --left', '--right');
+test_inset_area_order('most-block-size --bottom, --top, --left, --right', '--left');
+
+// --left-sweep and --bottom-sweep has the same IMBC inline-size ...
+test_inset_area_order('most-inline-size --left-sweep, --bottom-sweep', '--left-sweep');
+test_inset_area_order('most-inline-size --bottom-sweep, --left-sweep', '--bottom-sweep');
+// ... but not the same block-size.
+test_inset_area_order('most-block-size --left-sweep, --bottom-sweep', '--left-sweep');
+test_inset_area_order('most-block-size --bottom-sweep, --left-sweep', '--left-sweep');
+
+test_inset_area_order('most-inline-size --right-sweep, --left-sweep, --bottom-sweep, --top-sweep', '--left-sweep');
+test_inset_area_order('most-block-size --right-sweep, --left-sweep, --bottom-sweep, --top-sweep', '--top-sweep');
+
+test_inset_area_order(`most-inline-size
+ --right-sweep, --left-sweep, --bottom-sweep, --top-sweep,
+ --right, --left, --bottom, --top
+ `, '--left-sweep');
+
+test_inset_area_order(`most-block-size
+ --right-sweep, --left-sweep, --bottom-sweep, --top-sweep,
+ --right, --left, --bottom, --top
+ `, '--right');
+
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-add-no-overflow.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-add-no-overflow.html
index 9d87f82b9f..de0647f88b 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-add-no-overflow.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-add-no-overflow.html
@@ -2,7 +2,7 @@
<html class=reftest-wait>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: position-visibility: no-overflow</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-no-overflow-ref.html">
<style>
#scroll-container {
@@ -44,4 +44,4 @@ requestAnimationFrame(() => {
});
});
</script>
-</html> \ No newline at end of file
+</html>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-valid.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-valid.tentative.html
index bf67921639..4b069c253b 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-valid.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-valid.tentative.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: position-visibility: anchors-valid</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-valid-ref.html">
<style>
.anchor {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-in.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-in.html
index cea439c55f..f13c500915 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-in.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-in.html
@@ -3,7 +3,7 @@
<meta charset="utf-8">
<meta name="assert" content="Scrolling an anchor in to view should cause a position-visibility: anchors-visible element to appear." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-after-scroll-in-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-out.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-out.html
index b2e3643b07..4294091b89 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-out.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-after-scroll-out.html
@@ -3,7 +3,7 @@
<meta charset="utf-8">
<meta name="assert" content="Scrolling an anchor out of view should cause a position-visibility: anchors-visible element to disappear." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-after-scroll-out-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed-ref.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed-ref.html
new file mode 100644
index 0000000000..7a9d69a9e3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+
+<!-- This test passes if both the anchor and anchored elements are hidden. -->
+<div style="height: 200vh;"></div>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed.tentative.html
new file mode 100644
index 0000000000..3ea26c896e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-both-position-fixed.tentative.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="assert" content="position-visibility: anchors-visible should work with a fixed-position anchored element." />
+<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="match" href="position-visibility-anchors-visible-both-position-fixed-ref.html">
+<style>
+ #anchor {
+ anchor-name: --a1;
+ position: fixed;
+ top: -100px;
+ left: 0;
+ width: 100px;
+ height: 100px;
+ background: orange;
+ }
+
+ #target {
+ position-anchor: --a1;
+ position-visibility: anchors-visible;
+ inset-area: bottom right;
+ width: 100px;
+ height: 100px;
+ background: red;
+ position: fixed;
+ top: 0;
+ left: 0;
+ }
+
+ #spacer {
+ height: 200vh;
+ }
+</style>
+
+<!-- Test passes if #target is not visible, due to #anchor being off-screen. -->
+<div id="anchor">anchor</div>
+<div id="target">target</div>
+<div id="spacer"></div>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-001.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-001.html
new file mode 100644
index 0000000000..3f515a5686
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-001.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<meta charset="utf-8">
+<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="match" href="position-visibility-anchors-visible-after-scroll-out-ref.html">
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/rendering-utils.js"></script>
+<style>
+ #scroll-container {
+ overflow: hidden scroll;
+ width: 300px;
+ height: 100px;
+ }
+
+ #anchor1 {
+ anchor-name: --a1;
+ width: 100px;
+ height: 100px;
+ background: orange;
+ }
+
+ #anchor2 {
+ anchor-name: --a2;
+ width: 100px;
+ height: 50px;
+ background: yellow;
+ }
+
+ .spacer {
+ height: 100px;
+ }
+
+ .anchored {
+ position-visibility: anchors-visible;
+ inset-area: bottom;
+ width: 100px;
+ height: 50px;
+ background: red;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
+
+ #chained {
+ position-anchor: --a1;
+ }
+
+ #target {
+ position-anchor: --a2;
+ }
+</style>
+
+<div id="scroll-container">
+ <div id="anchor1">anchor1</div>
+ <div class="spacer"></div>
+ <div id="chained" class="anchored">
+ <div id="anchor2">chained</div>
+ </div>
+ <div id="target" class="anchored">target</div>
+</div>
+
+<script>
+ // #target should be initially visible because it is anchored to #anchor2
+ // which is chained to #anchor1 and both anchors are visible.
+ waitForAtLeastOneFrame().then(() => {
+ // Scroll #anchor1 so that it is out of view.
+ document.getElementById('scroll-container').scrollTop = 100;
+
+ // #target should now be invisible.
+ takeScreenshot();
+ });
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-002.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-002.html
new file mode 100644
index 0000000000..aa1dcd0eb9
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-002.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<meta charset="utf-8">
+<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="match" href="position-visibility-anchors-visible-after-scroll-out-ref.html">
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/rendering-utils.js"></script>
+<style>
+ #scroll-container {
+ overflow: hidden scroll;
+ width: 300px;
+ height: 100px;
+ }
+
+ #anchor1 {
+ anchor-name: --a1;
+ width: 100px;
+ height: 100px;
+ background: orange;
+ }
+
+ #chained {
+ position-anchor: --a1;
+ anchor-name: --a2;
+ background: yellow;
+ }
+
+ .spacer {
+ height: 100px;
+ }
+
+ .anchored {
+ position-visibility: anchors-visible;
+ inset-area: bottom;
+ width: 100px;
+ height: 50px;
+ background: red;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
+
+ #target {
+ position-anchor: --a2;
+ }
+</style>
+
+<div id="scroll-container">
+ <div id="anchor1">anchor1</div>
+ <div class="spacer"></div>
+ <div id="chained" class="anchored"></div>
+ <div id="target" class="anchored">target</div>
+</div>
+
+<script>
+ // #target should be initially visible because it is anchored to #anchor2
+ // which is chained to #anchor1 and both anchors are visible.
+ waitForAtLeastOneFrame().then(() => {
+ // Scroll #anchor1 so that it is out of view.
+ document.getElementById('scroll-container').scrollTop = 100;
+
+ // #target should now be invisible.
+ takeScreenshot();
+ });
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-003.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-003.html
new file mode 100644
index 0000000000..9a1e077de0
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-003.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<meta charset="utf-8">
+<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="match" href="position-visibility-anchors-visible-after-scroll-out-ref.html">
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/rendering-utils.js"></script>
+<style>
+ #scroll-container {
+ overflow: hidden scroll;
+ width: 300px;
+ height: 100px;
+ }
+
+ #anchor1 {
+ anchor-name: --a1;
+ width: 100px;
+ height: 100px;
+ background: orange;
+ }
+
+ .spacer {
+ height: 100px;
+ }
+
+ #anchor2 {
+ anchor-name: --a2;
+ position-anchor: --a1;
+ }
+
+ #anchor3 {
+ anchor-name: --a3;
+ position-anchor: --a2;
+ }
+
+ #anchor4 {
+ anchor-name: --a4;
+ position-anchor: --a3;
+ }
+
+ .anchored {
+ position-visibility: anchors-visible;
+ inset-area: bottom;
+ width: 100px;
+ height: 50px;
+ background: red;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
+
+ #target {
+ position-anchor: --a4;
+ }
+</style>
+
+<div id="scroll-container">
+ <div id="anchor1">anchor1</div>
+ <div class="spacer"></div>
+ <div id="anchor2" class="anchored">anchor2</div>
+ <div id="anchor3" class="anchored">anchor3</div>
+ <div id="anchor4" class="anchored">anchor4</div>
+ <div id="target" class="anchored">target</div>
+</div>
+
+<script>
+ // #target should be initially visible because it is anchored to #anchor2
+ // which is chained to #anchor1 and both anchors are visible.
+ waitForAtLeastOneFrame().then(() => {
+ // Scroll #anchor1 so that it is out of view.
+ document.getElementById('scroll-container').scrollTop = 100;
+
+ // #target should now be invisible.
+ takeScreenshot();
+ });
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004-ref.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004-ref.html
new file mode 100644
index 0000000000..409247a695
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<style>
+ #scroll-container {
+ overflow: hidden scroll;
+ width: 300px;
+ height: 100px;
+ }
+
+ #anchor {
+ width: 100px;
+ height: 100px;
+ background: orange;
+ margin-bottom: 100px;
+ }
+
+ #chained {
+ width: 100px;
+ height: 50px;
+ background: blue;
+ }
+
+ #target {
+ width: 100px;
+ height: 50px;
+ background: green;
+ }
+</style>
+
+<div id="scroll-container">
+ <div id="anchor">anchor1</div>
+</div>
+<div id="chained">chained</div>
+<div id="target">target</div>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004.html
new file mode 100644
index 0000000000..62ab7578a3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-chained-004.html
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<meta charset="utf-8">
+<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
+<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="match" href="position-visibility-anchors-visible-chained-004-ref.html">
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/rendering-utils.js"></script>
+<style>
+ #scroll-container {
+ overflow: hidden scroll;
+ width: 300px;
+ height: 100px;
+ }
+
+ #anchor1 {
+ anchor-name: --a1;
+ width: 100px;
+ height: 100px;
+ background: orange;
+ }
+
+ #anchor2 {
+ anchor-name: --a2;
+ width: 100px;
+ height: 50px;
+ background: blue;
+ }
+
+ .spacer {
+ height: 100px;
+ }
+
+ .anchored {
+ position-visibility: anchors-visible;
+ inset-area: bottom;
+ width: 100px;
+ height: 50px;
+ background: green;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
+
+ #chained {
+ position-anchor: --a1;
+ }
+
+ #target {
+ position-anchor: --a2;
+ }
+</style>
+
+<div id="scroll-container">
+ <div id="anchor1">anchor1</div>
+ <div class="spacer"></div>
+ <div id="chained" class="anchored">
+ <div id="anchor2">chained</div>
+ </div>
+ <div id="target" class="anchored">target</div>
+</div>
+
+<script>
+ // #target should be initially visible because it is anchored to #anchor2
+ // which is chained to #anchor1 and both anchors are visible.
+ waitForAtLeastOneFrame().then(() => {
+ // Scroll #anchor out of view.
+ const scroller = document.getElementById('scroll-container');
+ scroller.scrollTop = 100;
+ // #target1 should now be invisible.
+
+ waitForAtLeastOneFrame().then(() => {
+ // Scroll #anchor back into view.
+ scroller.scrollTop = 0;
+
+ // #target should now be visible again.
+ takeScreenshot();
+ });
+ });
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-anchor.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-anchor.html
index f8b1cc6d10..117628e7dc 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-anchor.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-anchor.html
@@ -3,7 +3,7 @@
<meta charset="utf-8">
<meta name="assert" content="Position-visibility should not be affected by the visibility of a previous anchor." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-change-anchor-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-css-visibility.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-css-visibility.html
index 22a30658c8..f9c598374c 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-css-visibility.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-change-css-visibility.html
@@ -3,7 +3,7 @@
<meta charset="utf-8">
<meta name="assert" content="Position-visibility: anchors-visible should show an element after an anchor changes from visibility: hidden to visibility: visible." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-change-css-visibility-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-css-visibility.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-css-visibility.html
index 31be797798..a699025325 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-css-visibility.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-css-visibility.html
@@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta name="assert" content="Position-visibility: anchors-visible should hide an element with an anchor that has visibility: hidden." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-css-visibility-ref.html">
<style>
#container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-non-intervening-container.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-non-intervening-container.html
index 7b84976fd3..9c4d085b7e 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-non-intervening-container.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-non-intervening-container.html
@@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta name="assert" content="position-visibility: anchors-visible should consider the visibility of the anchor relative the containing scroller, ignoring visibility in other scrollers." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-non-intervening-container-ref.html">
<style>
#non-intervening-scroll-container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-stacked-child.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-stacked-child.html
new file mode 100644
index 0000000000..e563fecfed
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-stacked-child.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<meta name="assert" content="Position-visibility: anchors-visible should hide an element and stacked children with an out-of-view anchor." />
+<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
+<link rel="match" href="position-visibility-anchors-visible-ref.html">
+<style>
+ #scroll-container {
+ overflow: hidden scroll;
+ width: 300px;
+ height: 100px;
+ }
+
+ #anchor {
+ anchor-name: --a1;
+ width: 100px;
+ height: 100px;
+ background: orange;
+ }
+
+ #spacer {
+ height: 100px;
+ }
+
+ #target {
+ position-anchor: --a1;
+ position-visibility: anchors-visible;
+ inset-area: bottom right;
+ width: 100px;
+ height: 100px;
+ background: red;
+ position: absolute;
+ top: 0;
+ left: 0;
+ }
+ #stacking-child {
+ /* stacking context */
+ z-index: 1;
+ width: 100px;
+ height: 100px;
+ background: maroon;
+ position: absolute;
+ top: 25px;
+ left: 25px;
+ }
+</style>
+
+<div id="scroll-container">
+ <div id="anchor">anchor</div>
+ <div id="spacer"></div>
+ <div id="target">target
+ <div id="stacking-child"></div>
+ </div>
+</div>
+
+<script>
+ const scroller = document.getElementById('scroll-container');
+ scroller.scrollTop = 100;
+ // #target should not be visible because #anchor is scrolled out of view.
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-with-position.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-with-position.html
index 82eed0beb9..43dd2cc782 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-with-position.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible-with-position.html
@@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta name="assert" content="Position-visibility: anchors-visible should hide an element with an out-of-view anchor and a relpos scroller." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-ref.html">
<style>
#scroll-container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible.html
index 85b8d897db..78daffb11b 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-anchors-visible.html
@@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta name="assert" content="Position-visibility: anchors-visible should hide an element with an out-of-view anchor." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-anchors-visible-ref.html">
<style>
#scroll-container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-scroll.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-scroll.html
index 4751faeb0d..f646f819cd 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-scroll.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-scroll.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html class="reftest-wait">
<title>CSS Anchor Positioning Test: position-visibility: no-overflow</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-no-overflow-scroll-ref.html">
<style>
#scroll-container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-stacked-child.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-stacked-child.html
index f748fda33e..1ea5ff9a1e 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-stacked-child.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow-stacked-child.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: position-visibility: no-overflow</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-no-overflow-ref.html">
<style>
#scroll-container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow.html
index 39fb55b120..ea3b2d0802 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-no-overflow.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: position-visibility: no-overflow</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-no-overflow-ref.html">
<style>
#scroll-container {
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-anchors-visible.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-anchors-visible.html
index c6649e5f93..95be15ca55 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-anchors-visible.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-anchors-visible.html
@@ -3,7 +3,7 @@
<meta charset="utf-8">
<meta name="assert" content="Removing position-visibility: anchors-visible from an invisible anchored element should cause it to become visible." />
<title>CSS Anchor Positioning Test: position-visibility: anchors-visible</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-remove-anchors-visible-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="/common/rendering-utils.js"></script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-no-overflow.tentative.html b/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-no-overflow.html
index a043917da6..2cd2ed9fa3 100644
--- a/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-no-overflow.tentative.html
+++ b/testing/web-platform/tests/css/css-anchor-position/position-visibility-remove-no-overflow.html
@@ -2,7 +2,7 @@
<html class=reftest-wait>
<meta charset="utf-8">
<title>CSS Anchor Positioning Test: position-visibility: no-overflow</title>
-<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/7758">
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-visibility">
<link rel="match" href="position-visibility-no-overflow-ref.html">
<style>
#scroll-container {
@@ -45,4 +45,4 @@ requestAnimationFrame(() => {
});
});
</script>
-</html> \ No newline at end of file
+</html>
diff --git a/testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor-dynamic.html b/testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor-dynamic.html
new file mode 100644
index 0000000000..9e4fa9828e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor-dynamic.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: Pseudo elements as anchors</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#position-anchor">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ .cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ }
+ #anchor1.enabled::before {
+ display: block;
+ width: 100px;
+ height: 100px;
+ content: "";
+ anchor-name: --a1;
+ background: blue;
+ }
+ #anchor2.enabled::after {
+ display: block;
+ width: 100px;
+ height: 100px;
+ content: "";
+ anchor-name: --a2;
+ background: pink;
+ }
+ .anchored {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: anchor(right);
+ top: anchor(bottom);
+ background: orange;
+ }
+ #anchored1 { position-anchor: --a1; }
+ #anchored2 { position-anchor: --a2; }
+</style>
+<div class="cb">
+ <div id="anchor1"></div>
+ <div id="anchored1" class="anchored"></div>
+</div>
+<div class="cb">
+ <div id="anchor2"></div>
+ <div id="anchored2" class="anchored"></div>
+</div>
+<script>
+ test(() => {
+ assert_equals(anchored1.offsetLeft, 0);
+ assert_equals(anchored1.offsetTop, 0);
+ anchor1.className = "enabled";
+ assert_equals(anchored1.offsetLeft, 100);
+ assert_equals(anchored1.offsetTop, 100);
+ }, "::before as anchor dynamically generated");
+ test(() => {
+ assert_equals(anchored2.offsetLeft, 0);
+ assert_equals(anchored2.offsetTop, 0);
+ anchor2.className = "enabled";
+ assert_equals(anchored2.offsetLeft, 100);
+ assert_equals(anchored2.offsetTop, 100);
+ }, "::after as anchor dynamically generated");
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor.html b/testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor.html
new file mode 100644
index 0000000000..a107a0ec17
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/pseudo-element-anchor.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: Pseudo elements as anchors</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#position-anchor">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ .cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ }
+ #anchor1::before {
+ display: block;
+ width: 100px;
+ height: 100px;
+ content: "";
+ anchor-name: --a1;
+ background: blue;
+ }
+ #anchor2::after {
+ display: block;
+ width: 100px;
+ height: 100px;
+ content: "";
+ anchor-name: --a2;
+ background: pink;
+ }
+ .anchored {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ left: anchor(right);
+ top: anchor(bottom);
+ background: orange;
+ }
+ #anchored1 { position-anchor: --a1; }
+ #anchored2 { position-anchor: --a2; }
+</style>
+<div class="cb">
+ <div id="anchor1"></div>
+ <div id="anchored1" class="anchored"></div>
+</div>
+<div class="cb">
+ <div id="anchor2"></div>
+ <div id="anchored2" class="anchored"></div>
+</div>
+<script>
+ test(() => {
+ assert_equals(anchored1.offsetLeft, 100);
+ assert_equals(anchored1.offsetTop, 100);
+ }, "::before as anchor");
+ test(() => {
+ assert_equals(anchored2.offsetLeft, 100);
+ assert_equals(anchored2.offsetTop, 100);
+ }, "::after as anchor");
+</script>
diff --git a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-001.tentative-ref.html b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-001-ref.html
index fb858cc105..fb858cc105 100644
--- a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-001.tentative-ref.html
+++ b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-001-ref.html
diff --git a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-002.tentative-ref.html b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-002-ref.html
index 9dde5d00f0..9dde5d00f0 100644
--- a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-002.tentative-ref.html
+++ b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-002-ref.html
diff --git a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-004.tentative-ref.html b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-004-ref.html
index 22c2270dde..22c2270dde 100644
--- a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-004.tentative-ref.html
+++ b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-004-ref.html
diff --git a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-fallback.tentative-ref.html b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-fallback-ref.html
index 0933430fc3..0933430fc3 100644
--- a/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-fallback.tentative-ref.html
+++ b/testing/web-platform/tests/css/css-anchor-position/reference/anchor-scroll-chained-fallback-ref.html