Truly independent web browser
Tests/LibWeb: Import CSS anchor positioning fallback WPT tests
Andreas Klingd42433654ada
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/at-position-try-invalidation-shadow-dom.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/at-position-try-invalidation-shadow-dom.txtnew file mode 100644index 00000000000..d3c1347221e--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/at-position-try-invalidation-shadow-dom.txt@@ -0,0 +1,10 @@+Harness status: OK++Found 4 tests++2 Pass+2 Fail+Pass #host is initially left: 999999px+Pass #slotted is initially left: 999999px+Fail #host with inserted @position-try applied+Fail #slotted with inserted @position-try applied\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/at-position-try-invalidation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/at-position-try-invalidation.txtnew file mode 100644index 00000000000..76da455095e--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/at-position-try-invalidation.txt@@ -0,0 +1,10 @@+Harness status: OK++Found 4 tests++2 Pass+2 Fail+Pass position-try-fallbacks initially not matching any rules+Fail Enable @position-try rule stylesheet+Fail Insert overriding @position-try rule+Pass Disable the @position-try rules\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-animation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-animation.txtnew file mode 100644index 00000000000..11c867cb1cf--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-animation.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-block+Fail No successful position, keep flip-block+Fail Base position without fallback now successful\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-basic.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-basic.txtnew file mode 100644index 00000000000..11c867cb1cf--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-basic.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-block+Fail No successful position, keep flip-block+Fail Base position without fallback now successful\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-fallbacks-position-area.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-fallbacks-position-area.txtnew file mode 100644index 00000000000..d39f88cd094--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-fallbacks-position-area.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with fallback+Fail Both base and fallback works, position-try-fallbacks is set to the same value, keeps fallback+Fail position-try-fallbacks is set to a different value, both base and fallback works, uses base because last successful position option is invalidated\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-fallbacks.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-fallbacks.txtnew file mode 100644index 00000000000..90b1b214139--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-fallbacks.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-block+Fail No successful position, keep flip-block+Fail No successful position, last successful invalidated by position-try-fallbacks change\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-try-rule.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-try-rule.txtnew file mode 100644index 00000000000..918e04f7763--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-change-try-rule.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with --try+Fail No successful position, keep --try+Fail No successful position, last successful invalidated by @position-try change\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-fallback-to-base-style.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-fallback-to-base-style.txtnew file mode 100644index 00000000000..5abc0f4e8ca--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-fallback-to-base-style.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-inline fallback+Fail Base position without fallback now successful+Fail Both base position and flip-inline works, keep base position since it's the last successful option\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-iframe.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-iframe.txtnew file mode 100644index 00000000000..11c867cb1cf--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-iframe.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-block+Fail No successful position, keep flip-block+Fail Base position without fallback now successful\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-intermediate-ignored.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-intermediate-ignored.txtnew file mode 100644index 00000000000..24076f4f27b--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-intermediate-ignored.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail Starts rendering with flip-block+Fail No successful position (with intermediate successful), keep flip-block\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-pseudo-element-basic.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-pseudo-element-basic.txtnew file mode 100644index 00000000000..11c867cb1cf--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-pseudo-element-basic.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-block+Fail No successful position, keep flip-block+Fail Base position without fallback now successful\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-pseudo-element-fallbacks.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-pseudo-element-fallbacks.txtnew file mode 100644index 00000000000..90b1b214139--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/last-successful-pseudo-element-fallbacks.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail Starts rendering with flip-block+Fail No successful position, keep flip-block+Fail No successful position, last successful invalidated by position-try-fallbacks change\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-001.txtnew file mode 100644index 00000000000..5669aa327b7--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-001.txt@@ -0,0 +1,12 @@+Harness status: OK++Found 6 tests++2 Pass+4 Fail+Pass .target 1+Fail .target 2+Fail .target 3+Fail .target 4+Fail .target 5+Pass .target 6\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-002.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-002.txtnew file mode 100644index 00000000000..f6d36d8c196--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-002.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail .target 1\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-003.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-003.txtnew file mode 100644index 00000000000..b437bec8ade--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-003.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Fail+Fail .anchored 1+Fail .anchored 2+Fail .anchored 3\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-004.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-004.txtnew file mode 100644index 00000000000..2f88762991f--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-004.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Pass .target 1+Fail .target 2\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-backdrop.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-backdrop.txtnew file mode 100644index 00000000000..b3a5860e8f9--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-backdrop.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail ::backdrop can use position-try-fallbacks\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-cascade-layer-reorder.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-cascade-layer-reorder.txtnew file mode 100644index 00000000000..1084ed09361--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-cascade-layer-reorder.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail When in the same layer, the last rule of each name wins+Fail When in different layers, the rule of each name in the highest layer wins\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-cascade.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-cascade.txtnew file mode 100644index 00000000000..7f3958f2869--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-cascade.txt@@ -0,0 +1,11 @@+Harness status: OK++Found 6 tests++6 Fail+Fail @position-try rule applies+Fail @position-try rule wins over inline style+Fail @position-try rule does not win over !important+Fail @position-try rule does not win over animations+Fail @position-try rule does not win over transitions+Fail @position-try revert / revert-layer reverts to user / author origin\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-container-query.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-container-query.txtnew file mode 100644index 00000000000..2e689e215d7--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-container-query.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail Size container query responds to fallback width+Fail Size container query responds to fallback width and applies height to not fit the first fallback\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-custom-property.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-custom-property.txtnew file mode 100644index 00000000000..97d2549b9e7--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-custom-property.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail .target 1+Fail .target 2\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-dynamic.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-dynamic.txtnew file mode 100644index 00000000000..bb0b15282ac--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-dynamic.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 2 tests++1 Pass+1 Fail+Pass Initial static left position is 0+Fail Left position set to right edge of anchor with @position-try\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-003.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-003.txtnew file mode 100644index 00000000000..ab299d6fa0f--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-003.txt@@ -0,0 +1,13 @@+Harness status: OK++Found 8 tests++8 Fail+Fail initial position+Fail scroll to 100+Fail scroll to 101+Fail scroll back to 100+Fail redisplay at 100+Fail scroll to 200+Fail scroll to 300+Fail scroll back to 0\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-limit.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-limit.txtnew file mode 100644index 00000000000..ec7a3f84ccb--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-limit.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail Try fallbacks which are not found are not part of the limit+Fail Must support At least five try fallbacks\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-no-fit-after-fit.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-no-fit-after-fit.txtnew file mode 100644index 00000000000..ad8c9b1338e--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-fallbacks-no-fit-after-fit.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Nothing fits after a fallback fit in a previous layout without rendering\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-grid-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-grid-001.txtnew file mode 100644index 00000000000..f6d36d8c196--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-grid-001.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail .target 1\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-initial-transition.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-initial-transition.txtnew file mode 100644index 00000000000..45129b80450--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-initial-transition.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail No transition for initial style with @position-try\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-order-inset-modified-containing-block.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-order-inset-modified-containing-block.txtnew file mode 100644index 00000000000..995f2ff7d39--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-order-inset-modified-containing-block.txt@@ -0,0 +1,9 @@+Harness status: OK++Found 4 tests++4 Pass+Pass most-width --margin, --no-margin | --margin+Pass most-width --no-margin, --margin | --no-margin+Pass most-height --margin, --no-margin | --margin+Pass most-height --no-margin, --margin | --no-margin\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-position-anchor.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-position-anchor.txtnew file mode 100644index 00000000000..c5664894c53--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-position-anchor.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail #anchored 1\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-pseudo-element.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-pseudo-element.txtnew file mode 100644index 00000000000..bad3397cd38--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-pseudo-element.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail ::before using second fallback+Fail ::after using first fallback\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-rule-caching-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-rule-caching-001.txtnew file mode 100644index 00000000000..6bb7642b406--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-rule-caching-001.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Modifying one sheet containing @position-try rule doesn't affect another sheet\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-rule-caching-002.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-rule-caching-002.txtnew file mode 100644index 00000000000..6bb7642b406--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-rule-caching-002.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Modifying one sheet containing @position-try rule doesn't affect another sheet\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-transition-basic.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-transition-basic.txtnew file mode 100644index 00000000000..f331dbbcdd5--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-transition-basic.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail Transition when @position-try is applied+Fail Transition when @position-try is unapplied\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-transition-flip.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-transition-flip.txtnew file mode 100644index 00000000000..350c8f9de78--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-transition-flip.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail Transition to a flipped state+Fail Transition to an unflipped state\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-typed-om.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-typed-om.txtnew file mode 100644index 00000000000..0ebe54ffc5d--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/position-try-typed-om.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Effects of position-try-fallbacks are visible in the computed values\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/try-tactic-back-to-base.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/try-tactic-back-to-base.txtnew file mode 100644index 00000000000..6b6ae96370a--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-anchor-position/try-tactic-back-to-base.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Pass+Pass Should use base values when nothing fits\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/at-position-try-invalidation-shadow-dom.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/at-position-try-invalidation-shadow-dom.htmlnew file mode 100644index 00000000000..b69c4c19784--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/at-position-try-invalidation-shadow-dom.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: Dynamically change @position-try rules in Shadow DOM</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-rule">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ body { margin: 0; }+ #host { width: 200px }+</style>++<div id="host">+ <template shadowrootmode="open">+ <style>+ ::slotted(#slotted), :host {+ position-try-fallbacks: --pf;+ position: absolute;+ left: 999999px; /* force fallback */+ }+ </style>+ <slot></slot>+ </template>+ <div id="slotted"></div>+</div>++<script>+ test(() => {+ assert_equals(host.offsetLeft, 999999);+ }, "#host is initially left: 999999px");++ test(() => {+ assert_equals(slotted.offsetLeft, 999999);+ }, "#slotted is initially left: 999999px");++ host.shadowRoot.styleSheets[0].insertRule(`+ @position-try --pf { left: 100px; }+ `);++ test(() => {+ assert_equals(host.offsetLeft, 100);+ }, "#host with inserted @position-try applied");++ test(() => {+ assert_equals(slotted.offsetLeft, 100);+ }, "#slotted with inserted @position-try applied");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/at-position-try-invalidation.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/at-position-try-invalidation.htmlnew file mode 100644index 00000000000..67bc5910d75--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/at-position-try-invalidation.html@@ -0,0 +1,62 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: Dynamically change @position-try rules</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-rule">+<meta name="viewport" content="width=device-width, initial-scale=1">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ body { margin: 0; }++ #anchor {+ anchor-name: --a;+ margin-left: 100px;+ width: 100px;+ height: 100px;+ }++ #anchored {+ position: absolute;+ width: 100px;+ height: 100px;+ position-try-fallbacks: --pf;+ left: 999999px; /* force fallback */+ }+</style>++<style id="to-enable" media="print">+ @position-try --pf {+ left: anchor(--a left);+ }+</style>++<div>+ <div id="anchor">anchor</div>+ <div id="anchored">anchored</div>+</div>++<script>+ test(() => {+ assert_equals(anchored.offsetLeft, 999999);+ }, "position-try-fallbacks initially not matching any rules");++ test(() => {+ document.getElementById("to-enable").media = "";+ assert_equals(anchored.offsetLeft, 100);+ }, "Enable @position-try rule stylesheet");++ const sheet = document.getElementById("to-enable").sheet;++ test(() => {+ sheet.insertRule(+ `@position-try --pf {+ left: anchor(--a right);+ }`, 1);+ assert_equals(anchored.offsetLeft, 200);+ }, "Insert overriding @position-try rule");++ test(() => {+ sheet.disabled = "true";+ assert_equals(anchored.offsetLeft, 999999);+ }, "Disable the @position-try rules");++</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-animation.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-animation.htmlnew file mode 100644index 00000000000..ea7283c0efe--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-animation.html@@ -0,0 +1,68 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: last successful position fallback with animation</title>+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">+<meta name="description" content="Tests a bug in WebKit where the last-successful position fallback isn't remembered when the anchor-positioned element is animated">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }++ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }++ /* Dummy animation keyframe */+ @keyframes anime {+ from { background: #000000; }+ to { background: #ffffff; }+ }++ #anchored {+ position-anchor: --a;+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ position-area: top center;+ background: lime;+ animation: anime 1s linear;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "No successful position, keep flip-block");++ promise_test(async () => {+ anchor.style.top = "200px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 0);+ }, "Base position without fallback now successful");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-basic.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-basic.htmlnew file mode 100644index 00000000000..1c8499e8d54--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-basic.html@@ -0,0 +1,57 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: basic last successful position fallback</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ position-area: top center;+ background: lime;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "No successful position, keep flip-block");++ promise_test(async () => {+ anchor.style.top = "200px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 0);+ }, "Base position without fallback now successful");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-fallbacks-position-area.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-fallbacks-position-area.htmlnew file mode 100644index 00000000000..5f0d9ec4710--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-fallbacks-position-area.html@@ -0,0 +1,59 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: changing position-try-fallbacks to the same position-area value does not invalidate last successful position fallback</title>+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #container {+ position: relative;+ width: 600px;+ height: 300px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: right center;+ position: absolute;+ width: 200px;+ height: 100px;+ position-area: left center;+ background: lime;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetLeft, 200);+ }, "Starts rendering with fallback");++ promise_test(async () => {+ anchor.style.left = "300px";+ anchored.style.positionTryFallbacks = "right center";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetLeft, 400);+ }, "Both base and fallback works, position-try-fallbacks is set to the same value, keeps fallback");++ promise_test(async () => {+ anchored.style.positionTryFallbacks = "right top";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetLeft, 100);+ }, "position-try-fallbacks is set to a different value, both base and fallback works, uses base because last successful position option is invalidated");+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-fallbacks.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-fallbacks.htmlnew file mode 100644index 00000000000..f093a8e4fbd--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-fallbacks.html@@ -0,0 +1,57 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: changing position-try-fallbacks invalidates last successful position fallback</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ position-area: top center;+ background: lime;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "No successful position, keep flip-block");++ promise_test(async () => {+ anchored.style.positionTryFallbacks = "flip-block, --foo";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 0);+ }, "No successful position, last successful invalidated by position-try-fallbacks change");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-try-rule.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-try-rule.htmlnew file mode 100644index 00000000000..ac060ebe3e7--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-change-try-rule.html@@ -0,0 +1,61 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: changing @position-try rules invalidates last successful position fallback</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style id="anchor_sheet">+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: --try;+ position: absolute;+ width: 100px;+ height: 200px;+ position-area: top center;+ background: lime;+ }+ @position-try --try {+ position-area: bottom center;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "Starts rendering with --try");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "No successful position, keep --try");++ promise_test(async () => {+ // Changing @position-try --try {}+ anchor_sheet.sheet.cssRules[3].style.positionArea = "bottom";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 0);+ }, "No successful position, last successful invalidated by @position-try change");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-fallback-to-base-style.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-fallback-to-base-style.htmlnew file mode 100644index 00000000000..91d10edd76a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-fallback-to-base-style.html@@ -0,0 +1,59 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: switch from using fallback style to base style</title>+<meta name="description" content="Tests a bug in WebKit where if a fallback is initially used, then the base style is used, WebKit will remember the fallback to be the last successful position fallback instead of the base style.">+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #container {+ position: relative;+ width: 600px;+ height: 300px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: flip-inline;+ position: absolute;+ width: 200px;+ height: 100px;+ position-area: left center;+ background: lime;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetLeft, 200);+ }, "Starts rendering with flip-inline fallback");++ promise_test(async () => {+ anchor.style.left = "350px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetLeft, 150);+ }, "Base position without fallback now successful");++ promise_test(async () => {+ anchor.style.left = "300px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetLeft, 100);+ }, "Both base position and flip-inline works, keep base position since it's the last successful option");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-iframe.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-iframe.htmlnew file mode 100644index 00000000000..f162643bc19--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-iframe.html@@ -0,0 +1,68 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: basic last successful position fallback</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>++<iframe id="iframe" srcdoc='+<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ position-area: top center;+ background: lime;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+'></iframe>+<script>+ // Wait for the iframe to load:+ onload = function() {+ const doc = iframe.contentWindow.document;+ const container = doc.getElementById('container');+ const anchor = doc.getElementById('anchor');+ const anchored = doc.getElementById('anchored');++ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "No successful position, keep flip-block");++ promise_test(async () => {+ anchor.style.top = "200px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 0);+ }, "Base position without fallback now successful");+ }+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-intermediate-ignored.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-intermediate-ignored.htmlnew file mode 100644index 00000000000..97ee366e820--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-intermediate-ignored.html@@ -0,0 +1,54 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: last successful updated on resizeObserver timing</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored {+ position-anchor: --a;+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ position-area: top center;+ background: lime;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "200px";+ // Temporarily successful position for base style, but last successful is+ // updated resize observer time.+ assert_equals(anchored.offsetTop, 0);+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 200);+ }, "No successful position (with intermediate successful), keep flip-block");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-pseudo-element-basic.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-pseudo-element-basic.htmlnew file mode 100644index 00000000000..df380c50279--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-pseudo-element-basic.html@@ -0,0 +1,75 @@+<!DOCTYPE html>++<title>CSS Anchor Positioning: basic last successful position fallback on pseudo-elements</title>+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">++<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>++<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored::before {+ position-anchor: --a;+ /*+ We can't use position-area, since there's no way to access offsetTop of+ pseudo-elements to check for position. Instead, we have to use anchor()+ and check the computed inset values.+ */+ bottom: anchor(top);+ left: anchor(left);+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ background: lime;+ content: "";+ }+</style>++<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>++<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ const anchoredStyle = getComputedStyle(anchored, "::before");+ assert_equals(anchoredStyle.top, "200px");+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ const anchoredStyle = getComputedStyle(anchored, "::before");+ assert_equals(anchoredStyle.top, "250px");+ }, "No successful position, keep flip-block");++ promise_test(async () => {+ anchor.style.top = "200px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ const anchoredStyle = getComputedStyle(anchored, "::before");+ assert_equals(anchoredStyle.top, "0px");+ }, "Base position without fallback now successful");+</script>+diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-pseudo-element-fallbacks.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-pseudo-element-fallbacks.htmlnew file mode 100644index 00000000000..10497d71ef2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/last-successful-pseudo-element-fallbacks.html@@ -0,0 +1,76 @@+<!DOCTYPE html>++<title>CSS Anchor Positioning: changing position-try-fallbacks invalidates last successful position fallback on pseudo-elements</title>+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">++<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>++<style>+ #container {+ position: relative;+ width: 400px;+ height: 400px;+ background: teal;+ }+ #anchor {+ position: relative;+ top: 100px;+ left: 100px;+ width: 100px;+ height: 100px;+ background: red;+ anchor-name: --a;+ }+ #anchored::before {+ position-anchor: --a;+ bottom: anchor(top);+ left: anchor(left);+ position-try-fallbacks: flip-block;+ position: absolute;+ width: 100px;+ height: 200px;+ background: lime;+ content: "";+ }+ /*+ Hack to change position-try-fallbacks of the pseudo-element,+ since there's no easy way to change it in JavaScript.+ */+ #anchored.new-fallback::before {+ position-try-fallbacks: flip-block, --foo;+ }+</style>++<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ const anchoredStyle = getComputedStyle(anchored, "::before");+ assert_equals(anchoredStyle.top, "200px");+ }, "Starts rendering with flip-block");++ promise_test(async () => {+ anchor.style.top = "150px";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ const anchoredStyle = getComputedStyle(anchored, "::before");+ assert_equals(anchoredStyle.top, "250px");+ }, "No successful position, keep flip-block");++ promise_test(async () => {+ anchored.classList.add("new-fallback");+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ const anchoredStyle = getComputedStyle(anchored, "::before");+ assert_equals(anchoredStyle.top, "-50px");+ }, "No successful position, last successful invalidated by position-try-fallbacks change");+</script>+diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-001.htmlnew file mode 100644index 00000000000..0cf101f2bef--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-001.html@@ -0,0 +1,114 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<link rel="author" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>+<style>+.cb {+ position: relative;+ width: 190px;+ height: 70px;+ background: yellow;+ border-bottom: 1px solid black;+}+.spacer {+ width: 1px;+ height: 20px;+}+.anchor1 {+ anchor-name: --a1;+ margin-left: 45px;+ width: 100px;+ height: 30px;+ background: blue;+}+.target {+ position: absolute;+ position-try-fallbacks: --f1, --f2, --f3, --f4;+ width: 40px;+ height: 15px;+ margin: 5px;+ background: orange;+ /* Position to the right of the anchor. */+ left: anchor(--a1 right);+ top: anchor(--a1 top);+}+@position-try --f1 {+ inset: auto;+ /* Position to the left of the anchor. */+ right: anchor(--a1 left);+ top: anchor(--a1 top);+}+@position-try --f2 {+ inset: auto;+ /* Position to the bottom of the anchor. */+ left: anchor(--a1 left);+ top: anchor(--a1 bottom);+}+@position-try --f3 {+ inset: auto;+ /* Position to the top of the anchor. */+ left: anchor(--a1 left);+ bottom: anchor(--a1 top);+}+@position-try --f4 {+ inset: auto;+ /* Position to the left with the narrower width. */+ left: anchor(--a1 right);+ top: anchor(--a1 top);+ width: 35px;+ height: 40px;+}+</style>+<body onload="checkLayoutForAnchorPos('.target')">+ <!-- If the `cb` is wider, the base style fits. -->+ <div class="cb" style="width: 195px">+ <div class="spacer"></div>+ <div class="anchor1"></div>+ <div class="target"+ data-offset-x=150 data-offset-y=25+ data-expected-width=40 data-expected-height=15></div>+ </div>+ <!-- If the `margin-left` is wider, the first `@position-try` fits. -->+ <div class="cb">+ <div class="spacer"></div>+ <div class="anchor1" style="margin-left: 50px"></div>+ <div class="target"+ data-offset-x=5 data-offset-y=25+ data-expected-width=40 data-expected-height=15></div>+ </div>+ <!-- Without a spacer, the 2nd `@position-try` fits. -->+ <div class="cb">+ <div class="anchor1"></div>+ <div class="target"+ data-offset-x=50 data-offset-y=35+ data-expected-width=40 data-expected-height=15></div>+ </div>+ <!-- With two spacers, the 3rd `@position-try` fits. -->+ <div class="cb">+ <div class="spacer"></div>+ <div class="spacer"></div>+ <div class="anchor1"></div>+ <div class="target"+ data-offset-x=50 data-offset-y=20+ data-expected-width=40 data-expected-height=15></div>+ </div>+ <!-- With a spacer, the last `@position-try` fits. -->+ <div class="cb">+ <div class="spacer"></div>+ <div class="anchor1"></div>+ <div class="target"+ data-offset-x=150 data-offset-y=25+ data-expected-width=35 data-expected-height=40></div>+ </div>+ <!-- If the `cb` is narrower, no rules fit. The base style is used. -->+ <div class="cb" style="width: 185px">+ <div class="spacer"></div>+ <div class="anchor1"></div>+ <div class="target"+ data-offset-x=150 data-offset-y=25+ data-expected-width=40 data-expected-height=15></div>+ </div>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-002.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-002.htmlnew file mode 100644index 00000000000..ac724f90633--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-002.html@@ -0,0 +1,61 @@+<!DOCTYPE html>+<title>Tests that overflowing the inset-modified containing block triggers position fallback</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<link rel="author" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>+<style>+.cb {+ width: 400px;+ height: 400px;+ transform: scale(1);+ background: yellow;+}+.anchor1 {+ anchor-name: --a;+ margin-left: 100px;+ width: 100px;+ height: 100px;+ background: blue;+}+.target {+ position: absolute;+ position-try-fallbacks: --f1, --f2;+ width: min-content;+ height: 100px;+ background: orange;+ /* 1: Position to the left of the anchor. */+ left: 0;+ right: anchor(--a left);+ top: anchor(--a top);+}+.inline-spacer {+ display: inline-block;+ width: 200px;+ height: 100px;+}+@position-try --f1 {+ /* 2: Position to the right of the anchor. */+ left: anchor(--a right);+ right: 0;+ top: anchor(--a top);+}+@position-try --f2 {+ /* 3: Placeholder fallback that shouldn't be selected when the previous+ ones do not overflow the available space. */+ inset: 0;+}+</style>+<body onload="checkLayoutForAnchorPos('.target')">+ <!-- The first base style overflows the inset-modifed containing block -->+ <div class="cb">+ <div class="anchor1"></div>+ <div class="target"+ data-offset-x=200 data-offset-y=0+ data-expected-width=200 data-expected-height=100>+ <span class="inline-spacer"></span>+ </div>+ </div>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-003.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-003.htmlnew file mode 100644index 00000000000..557d5f319a4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-003.html@@ -0,0 +1,138 @@+<!DOCTYPE html>+<title>Tests fallback positions that overflow the inset-modified containing block regardless of scrolling</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<link rel="author" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>+<style>+body { margin: 0; }+.ltr { direction: ltr; }+.rtl { direction: rtl; }+.vrl { writing-mode: vertical-rl; }+.vlr { writing-mode: vertical-lr; }++.cb {+ width: 200px;+ height: 200px;+ transform: scale(1);+}++.spacer {+ block-size: 50px;+}++.anchor {+ width: 100px;+ height: 100px;+ margin-inline-start: 50px;+ background: orange;+ anchor-name: --a;+}++.anchored {+ position: absolute;+ width: 50px;+ height: 50px;+ background: lime;+}++/* Used on a element whose block and inline axes are the same with its+ containing block, so that the first two positions will exceed the end edges+ of the IMCB, and the last position will be used. */+.exceeds-end {+ position-try-fallbacks: --exceeds-end-1, --exceeds-end-2;+ left: 0;+ right: anchor(--a left);+ width: 100px;+}++@position-try --exceeds-end-1 {+ inset: auto;+ top: 0;+ bottom: anchor(--a top);+ width: auto;+ height: 100px;+}++@position-try --exceeds-end-2 {+ inset: auto;+ top: 11px;+ left: 22px;+ width: auto;+ height: auto;+}++/* Used on a element whose block and inline axes are in the opposite directions+ of its containing block, so that the first two positions will exceed the+ start edges of the IMCB, and the last position will be used. */+.exceeds-start {+ position-try-fallbacks: --exceeds-start-1, --exceeds-start-2;+ bottom: 0;+ top: anchor(--a bottom);+ height: 100px;+}++@position-try --exceeds-start-1 {+ inset: auto;+ right: 0;+ left: anchor(--a right);+ width: 100px;+ height: auto;+}++@position-try --exceeds-start-2 {+ inset: auto;+ top: 11px;+ left: 22px;+ height: auto;+}++/* Both inset sides are `auto`, but the size is too big to fit in the containing+ block. */+.exceeds-size {+ position-try-fallbacks: --exceeds-size-1, --exceeds-size-2;+ top: anchor(--a bottom);+ left: auto;+ right: auto;+ width: 300px;+}++@position-try --exceeds-size-1 {+ inset: auto;+ left: anchor(--a right);+ width: auto;+ height: 300px;+}++@position-try --exceeds-size-2 {+ inset: auto;+ width: auto;+ top: 11px;+ left: 22px;+}+</style>++<body onload="checkLayoutForAnchorPos('.anchored')">+ <div class=cb>+ <div class=spacer></div>+ <div class=anchor></div>+ <div class="anchored exceeds-end"+ data-offset-x=22 data-offset-y=11></div>+ </div>++ <div class="cb rtl vrl">+ <div class=spacer></div>+ <div class=anchor></div>+ <div class="anchored ltr vlr exceeds-start"+ data-offset-x=22 data-offset-y=11></div>+ </div>++ <div class="cb">+ <div class=spacer></div>+ <div class=anchor></div>+ <div class="anchored exceeds-size"+ data-offset-x=22 data-offset-y=11></div>+ </div>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-004.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-004.htmlnew file mode 100644index 00000000000..9e72a2a390a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-004.html@@ -0,0 +1,71 @@+<!DOCTYPE html>+<title>Tests margin properties in position fallback</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#accepted-try-properties">+<link rel="author" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>++<style>+body {+ margin: 0;+}++.cb {+ width: 300px;+ height: 150px;+ position: relative;+ background: lightgray;+}++.anchor {+ position: absolute;+ width: 100px;+ height: 100px;+ top: 25px;+ background: orange;+ anchor-name: --a;+}++.target {+ position: absolute;+ width: 100px;+ height: 100px;+ background: lime;+ position-try-fallbacks: --fallback;+ top: anchor(--a top);+ right: anchor(--a left);+ margin-top: 10px;+ margin-right: 10px;+}++@position-try --fallback {+ inset: auto;+ bottom: anchor(--a bottom);+ left: anchor(--a right);+ margin: 0;+ margin-bottom: 10px;+ margin-left: 10px;+}+</style>++<body onload="checkLayoutForAnchorPos('.target')">++<div class=cb>+ <div class=anchor style="left: 110px"></div>+ <!-- Chooses base style. -->+ <div class=target data-offset-x=0+ data-expected-margin-left=0 data-expected-margin-right=10+ data-expected-margin-top=10 data-expected-margin-bottom=0></div>+</div>++<div class=cb>+ <div class=anchor style="right: 110px"></div>+ <!-- Chooses @position-try block. -->+ <div class=target data-offset-x=200+ data-expected-margin-left=10 data-expected-margin-right=0+ data-expected-margin-top=0 data-expected-margin-bottom=10></div>+</div>++</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-backdrop.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-backdrop.htmlnew file mode 100644index 00000000000..e3a562925a6--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-backdrop.html@@ -0,0 +1,33 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: position-try-fallbacks 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-fallbacks: --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-fallbacks');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-cascade-layer-reorder.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-cascade-layer-reorder.htmlnew file mode 100644index 00000000000..2381a2de916--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-cascade-layer-reorder.html@@ -0,0 +1,76 @@+<!DOCTYPE html>+<title>Tests that @position-try rules are reordered by cascade layers</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-rule">+<link rel="help" href="https://www.w3.org/TR/css-cascade-5/#layering">+<link rel="author" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+body { margin: 0; }+#anchor {+ width: 100px;+ height: 100px;+ margin-left: 200px;+ margin-top: 200px;+ color: orange;+ anchor-name: --a;+}++.target {+ position: absolute;+ width: 100px;+ height: 100px;+ color: lime;+ position-try-fallbacks: --fallback;+ left: 999999px; /* force fallback */+}+</style>++<div id="anchor"></div>++<script>+function createTargetWithStyle(test, style) {+ let styleElement = document.createElement('style');+ styleElement.textContent = style;+ let target = document.createElement('div');+ target.classList.add('target');++ test.add_cleanup(() => {+ styleElement.remove();+ target.remove();+ });++ document.head.appendChild(styleElement);+ document.body.appendChild(target);+ return target;+}++test(t => {+ const target = createTargetWithStyle(t, `+ @position-try --fallback {+ left: auto;+ right: anchor(--a left);+ }+ @position-try --fallback {+ left: anchor(--a right);+ }+ `);+ assert_equals(target.offsetLeft, 300);+}, 'When in the same layer, the last rule of each name wins');++test(t => {+ const target = createTargetWithStyle(t, `+ @position-try --fallback {+ left: auto;+ bottom: anchor(--a top);+ }+ @layer {+ @position-try --fallback {+ left: auto;+ top: anchor(--a bottom);+ }+ }+ `);+ assert_equals(target.offsetTop, 100);+}, 'When in different layers, the rule of each name in the highest layer wins');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-cascade.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-cascade.htmlnew file mode 100644index 00000000000..befd9c558f0--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-cascade.html@@ -0,0 +1,146 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: @position-try and cascade interaction</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>+ .cb {+ position: relative;+ width: 100px;+ height: 100px;+ background: lightpink;+ display: inline-block;+ }+ .abs {+ position: absolute;+ background: darkcyan;+ left: 0px;+ top: 0px;+ width: 150px; /* force fallback */+ height: 25px;+ position-try-fallbacks: --pf;+ }+ @position-try --pf {+ width: 50px;+ left: 50px;+ top: 50px;+ }+</style>++<!-- Basic @position-try rule -->+<div class=cb>+ <div id=abs_try class=abs></div>+</div>+<script>+ test(() => {+ assert_equals(abs_try.offsetLeft, 50);+ assert_equals(abs_try.offsetTop, 50);+ }, '@position-try rule applies');+</script>++<!-- Inline style -->+<div class=cb>+ <div id=abs_inline class=abs style="left:20px"></div>+</div>+<script>+ test(() => {+ assert_equals(abs_inline.offsetLeft, 50);+ assert_equals(abs_inline.offsetTop, 50);+ }, '@position-try rule wins over inline style');+</script>++<!-- !important -->+<style>+ #abs_important {+ left: 10px !important;+ }+</style>+<div class=cb>+ <div id=abs_important class=abs></div>+</div>+<script>+ test(() => {+ assert_equals(abs_important.offsetLeft, 10);+ assert_equals(abs_important.offsetTop, 50);+ }, '@position-try rule does not win over !important');+</script>++<!-- Animations -->+<style>+ @keyframes anim {+ from { top: 20px; }+ to { top: 20px; }+ }+ #abs_animation {+ animation: anim 1000s steps(2, start) paused;+ }+</style>+<div class=cb>+ <div id=abs_animation class=abs></div>+</div>+<script>+ test(() => {+ assert_equals(abs_animation.offsetLeft, 50);+ assert_equals(abs_animation.offsetTop, 20);+ }, '@position-try rule does not win over animations');+</script>++<!-- Transitions -->+<style>+ #abs_transition {+ top: 50px;++ &.move {+ top: 10px !important;+ transition: top 1000s steps(2, start);+ }+ }+</style>+<div class=cb>+ <div id=abs_transition class=abs></div>+</div>+<script>+ test(() => {+ abs_transition.offsetTop;+ abs_transition.classList.add('move');+ assert_equals(abs_transition.offsetLeft, 50);+ assert_equals(abs_transition.offsetTop, 30);+ }, '@position-try rule does not win over transitions');+</script>++<!-- revert / revert-layer -->+<style>+ #abs_revert {+ position-try-fallbacks: --pf-revert;+ }+ @layer author-layer {+ #abs_revert {+ top: 30px;+ left: 30px;+ }+ }+ #abs_revert {+ top: 20px;+ left: 20px;+ /* overflowing .cb to force --pf-revert to be applied */+ width: 200px;+ height: 200px;+ }+ @position-try --pf-revert {+ left: revert;+ top: revert-layer;+ width: 30px;+ height: 30px;+ }+</style>+<div class=cb>+ <div id=abs_revert class=abs></div>+</div>+<script>+ test(() => {+ assert_equals(abs_revert.offsetLeft, 0, "left reverted back to user origin");+ assert_equals(abs_revert.offsetTop, 20, "top reverted back to author");+ assert_equals(abs_revert.offsetWidth, 30, "width from --pf-revert");+ assert_equals(abs_revert.offsetHeight, 30, "height from --pf-revert");+ }, '@position-try revert / revert-layer reverts to user / author origin');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-container-query.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-container-query.htmlnew file mode 100644index 00000000000..b30f50bbff8--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-container-query.html@@ -0,0 +1,91 @@+<!DOCTYPE html>+<title>@position-try with container query responding to fallback widths</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ #relative {+ background: maroon;+ position: relative;+ width: 195px;+ height: 200px;+ }+ #target1 {+ container-type: inline-size;+ container-name: target1;+ position-try-fallbacks: --fallback1;+ background: green;+ position: absolute;+ top: 0px;+ left: 999999px; /* force fallback */+ width: 100px;+ height: 100px;+ }+ @position-try --fallback1 {+ top: 100px;+ left: 0px;+ width: 150px;+ }+ @container (width > 100px) {+ #inner1 {+ background-color: lime;+ width: 100px;+ height: 100px;+ }+ }++ #target2 {+ container-type: inline-size;+ container-name: target2;+ position-try-fallbacks: --fallback2, --fallback3;+ background: orange;+ position: absolute;+ top: 0px;+ left: 999999px; /* force fallback */+ width: 100px;+ }+ @position-try --fallback2 {+ top: 100px;+ left: 0px;+ width: 150px;+ }+ @position-try --fallback3 {+ top: 0px;+ left: 0px;+ width: 150px;+ }+ @container target2 (width = 150px) {+ #inner2 {+ background-color: yellow;+ width: 100px;+ height: 150px;+ }+ }+</style>+<div id="relative">+ <div id="target1">+ <div id="inner1"></div>+ </div>+ <div id="target2">+ <div id="inner2"></div>+ </div>+</div>+<script>+ test(() => {+ assert_equals(getComputedStyle(inner1).backgroundColor, "rgb(0, 255, 0)");+ assert_equals(getComputedStyle(inner1).width, "100px");+ assert_equals(getComputedStyle(inner1).height, "100px");+ assert_equals(getComputedStyle(target1).top, "100px");+ assert_equals(getComputedStyle(target1).left, "0px");+ assert_equals(getComputedStyle(target1).width, "150px");+ }, "Size container query responds to fallback width");++ test(() => {+ assert_equals(getComputedStyle(inner2).backgroundColor, "rgb(255, 255, 0)");+ assert_equals(getComputedStyle(inner2).width, "100px");+ assert_equals(getComputedStyle(inner2).height, "150px");+ assert_equals(getComputedStyle(target2).top, "0px");+ assert_equals(getComputedStyle(target2).left, "0px");+ assert_equals(getComputedStyle(target2).width, "150px");+ }, "Size container query responds to fallback width and applies height to not fit the first fallback");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-custom-property.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-custom-property.htmlnew file mode 100644index 00000000000..adcd6136008--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-custom-property.html@@ -0,0 +1,66 @@+<!DOCTYPE html>+<title>Variable substitution in @position-try rules</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>+<style>+.cb {+ position: relative;+ width: 195px;+ height: 70px;+ background: yellow;+ border-bottom: 1px solid black;+}+.spacer {+ width: 1px;+ height: 20px;+}+.anchor1 {+ anchor-name: --a1;+ margin-left: 45px;+ width: 100px;+ height: 30px;+ background: blue;+}+.target {+ position: absolute;+ position-try-fallbacks: --fallback1;+ width: 40px;+ height: 15px;+ margin: 5px;+ background: orange;+ --left: anchor(--a1 right);+ --top: anchor(--a1 top);+}+.fallback1 {+ position-try-fallbacks: --fallback1;+}+.fallback2 {+ position-try-fallbacks: --fallback2;+}+@position-try --fallback1 {+ /* Position to the right of the anchor. */+ left: var(--left);+ top: var(--top);+}+/* Same as above, but using a shorthand. */+@position-try --fallback2 {+ inset: var(--top) 0px 0px var(--left);+}+</style>+<body onload="checkLayoutForAnchorPos('.target')">+ <div class="cb">+ <div class="spacer"></div>+ <div class="anchor1"></div>+ <div class="target fallback1"+ data-offset-x=150 data-offset-y=25></div>+ </div>+ <div class="cb">+ <div class="spacer"></div>+ <div class="anchor1"></div>+ <div class="target fallback2"+ data-offset-x=150 data-offset-y=25></div>+ </div>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-dynamic.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-dynamic.htmlnew file mode 100644index 00000000000..1cb6ccd9fdc--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-dynamic.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: Dynamically change position via position-try-fallbacks property</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ body { margin: 0; }++ @position-try --fallback1 {+ left: anchor(--a1 right);+ }+ #anchor {+ anchor-name: --a1;+ width: 100px;+ height: 100px;+ }+ #anchored {+ position: absolute;+ left: 999999px; /* Force fallback */+ width: 100px;+ height: 100px;+ }+</style>+<div id="anchor"></div>+<div id="anchored"></div>+<script>+ test(() => {+ assert_equals(anchored.offsetLeft, 999999);+ }, "Initial static left position is 0");++ test(() => {+ anchored.style.positionTryFallbacks = "--fallback1";+ assert_equals(anchored.offsetLeft, 100);+ }, "Left position set to right edge of anchor with @position-try");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-003.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-003.htmlnew file mode 100644index 00000000000..25acdb01e15--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-003.html@@ -0,0 +1,139 @@+<!DOCTYPE html>+<title>position-try-fallbacks:flip-block, only switch fallback if the current option doesn't fit</title>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#position-try-fallbacks">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ #anchor {+ anchor-name: --a;+ margin-top: 200px;+ margin-left: 100px;+ width: 150px;+ height: 50px;+ background: blue;+ }+ #anchored1 {+ position: absolute;+ position-anchor: --a;+ position-area: top left;+ position-try-fallbacks: flip-block;+ position-visibility: always;+ width: 100px;+ height: 100px;+ background: hotpink;+ }+ #anchored2 {+ position: absolute;+ position-anchor: --a;+ position-area: top right;+ position-try-fallbacks: flip-block;+ position-visibility: always;+ width: 100px;+ height: 300px;+ background: yellow;+ }+</style>++<div style="position:relative; width:400px; height:400px;">+<div id="scroller" style="overflow-y:scroll; scrollbar-width: none; width:400px; height:400px;">+ <div id="anchor"></div>+ <div style="height:1000px;"></div>+ <div id="anchored1"></div>+ <div id="anchored2"></div>+</div>++<script>+ async function redisplay() {+ anchored1.style.display = "none";+ anchored2.style.display = "none";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ anchored1.style.display = "block";+ anchored2.style.display = "block";+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ }++ promise_test(async () => {+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ // Both options fits. Pick the first one.+ assert_equals(anchored1.offsetTop, 100);+ // None of the options for #anchor2 fits. Use the first one.+ assert_equals(anchored2.offsetTop, 0);+ }, 'initial position');++ promise_test(async () => {+ scroller.scrollTop = 100;+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored1.offsetTop, 0);+ assert_equals(anchored2.offsetTop, 0);+ }, 'scroll to 100');++ promise_test(async () => {+ scroller.scrollTop = 101;+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ // The first option for #anchored1 no longer fits. Move to the second one,+ // which fits.+ assert_equals(anchored1.offsetTop, 149);+ // None of the options for #anchor2 fits. Keep using the first one.+ assert_equals(anchored2.offsetTop, 0);+ }, 'scroll to 101');++ promise_test(async () => {+ scroller.scrollTop = 100;+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ // The first option fits again, but stay at the second option, since that+ // one too still fits.+ assert_equals(anchored1.offsetTop, 150);++ assert_equals(anchored2.offsetTop, 0);+ }, 'scroll back to 100');++ promise_test(async () => {+ await redisplay();+ // Redisplaying the anchored element should go through the options over+ // again, which means that the first options will be chosen.+ assert_equals(anchored1.offsetTop, 0);+ assert_equals(anchored2.offsetTop, 0);+ }, 'redisplay at 100');++ promise_test(async () => {+ scroller.scrollTop = 200;+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ // The first option no longer fits. Move to the second one, which fits.+ assert_equals(anchored1.offsetTop, 50);++ assert_equals(anchored2.offsetTop, 50);+ }, 'scroll to 200');+++ promise_test(async () => {+ scroller.scrollTop = 300;+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored1.offsetTop, -50);++ // The second option now fits.+ assert_equals(anchored2.offsetTop, -50);+ }, 'scroll to 300');++ promise_test(async () => {+ scroller.scrollTop = 0;+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();++ // The second option still fits.+ assert_equals(anchored1.offsetTop, 250);++ // The second option no longer fits, but neither does the first one. Stay at+ // the second one.+ assert_equals(anchored2.offsetTop, 100);+ }, 'scroll back to 0');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-limit.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-limit.htmlnew file mode 100644index 00000000000..cd928bf664d--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-limit.html@@ -0,0 +1,53 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: position fallbacks list limit</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>+ #container {+ position: relative;+ width: 200px;+ height: 200px;+ }+ .positioned {+ width: 200px;+ height: 200px;+ position: absolute;+ top: 0;+ left: 10px; /* overflowing #container */+ }++ @position-try --bar {+ left: 0; /* not overflowing #container */+ }+ #t1 {+ /* If --foo is not found, we should still try --bar even if we limit the+ number of applied position fallbacks to five because the --foo's are not+ added to the `position fallbacks list` per spec. */+ position-try-fallbacks: --foo, --foo, --foo, --foo, --foo, --foo, --foo, --bar;+ }++ /* --f1 .. --f4 all overflowing #container */+ @position-try --f1 { left: 10px; }+ @position-try --f2 { left: 10px; }+ @position-try --f3 { left: 10px; }+ @position-try --f4 { left: 10px; }+ @position-try --f5 { left: 20px; width: 20px; /* not overflowing #container */ }+ #t2 {+ position-try-fallbacks: --f1, --f2, --f3, --f4, --f5;+ }++</style>+<div id="container">+ <div id="t1" class="positioned"></div>+ <div id="t2" class="positioned"></div>+</div>+<script>+ test(() => {+ assert_equals(t1.offsetLeft, 0, "The --bar try fallback should be applied");+ }, "Try fallbacks which are not found are not part of the limit");++ test(() => {+ assert_equals(t2.offsetLeft, 20, "The --f5 try fallback should be applied");+ }, "Must support At least five try fallbacks");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-no-fit-after-fit.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-no-fit-after-fit.htmlnew file mode 100644index 00000000000..10341bccc94--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-fallbacks-no-fit-after-fit.html@@ -0,0 +1,52 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: no fallback fits after one fit in a previous layout</title>+<meta name="description" content="Tests that a layout where no position option fits, following a layout (without an intervening rendering update) where a fallback did fit, settles on the base position rather than retrying forever.">+<link rel="author" title="Mozilla" href="https://mozilla.org">+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:[email protected]">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#fallback-apply">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#last-successful-position-fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="support/test-common.js"></script>+<style>+ html, body { margin: 0; }+ #container {+ position: relative;+ width: 400px;+ height: 300px;+ }+ #anchor {+ anchor-name: --a;+ position: absolute;+ bottom: 0;+ left: 0;+ width: 20px;+ height: 20px;+ }+ #anchored {+ position: absolute;+ position-anchor: --a;+ top: anchor(outside);+ left: 0;+ position-try-fallbacks: flip-block;+ width: 390px;+ height: 100px;+ }+</style>+<div id="container">+ <div id="anchor"></div>+ <div id="anchored"></div>+</div>+<script>+ promise_test(async () => {+ // Base position (below the anchor) never fits; flip-block fits here.+ assert_equals(anchored.offsetTop, 180, "flip-block fits initially");+ // Now make flip-block not fit either, before the last successful position+ // option has been recorded.+ container.style.width = "380px";+ assert_equals(anchored.offsetTop, 300, "base position when nothing fits");+ await waitUntilNextAnimationFrame();+ await waitUntilNextAnimationFrame();+ assert_equals(anchored.offsetTop, 300, "base position after rendering");+ }, "Nothing fits after a fallback fit in a previous layout without rendering");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-grid-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-grid-001.htmlnew file mode 100644index 00000000000..5a370920314--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-grid-001.html@@ -0,0 +1,96 @@+<!DOCTYPE html>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-pos">+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<link rel="help" href="https://drafts.csswg.org/css-grid/#abspos-items">+<link rel="author" href="mailto:[email protected]">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>+<style>+.cb {+ position: relative;+}+.grid {+ display: grid;+ grid-template-columns: repeat(4, 100px);+ grid-template-rows: 50px 100px 50px 50px;+}+.item {+ background: lightgray;+}+.spacer {+ background: yellow;+}+.anchor1 {+ anchor-name: --a1;+ background: orange;+ margin-left: 15px;+ width: 20px;+ height: 30px;+}+.target {+ grid-column: 2 / 4;+ grid-row: 2 / 4;+ position: absolute;+ position-try-fallbacks: --f1, --f2, --f3;+ width: 100px;+ height: 100px;+ background: lime;+ opacity: .2;+ /* Position to the left of the anchor. */+ position-anchor: --a1;+ right: anchor(left);+ top: anchor(top);+}+@position-try --f1 {+ inset: auto;+ left: anchor(right);+ top: anchor(top);+ width: 250px;+}+@position-try --f2 {+ /* Position to the right of the anchor. This entry should succeed. */+ inset: auto;+ left: anchor(right);+ top: anchor(top);+}+@position-try --f3 {+ /* Zero-sized, the last entry wins if none succeeded. */+ inset: auto;+ left: 0;+ top: 0;+ width: 0;+ height: 0;+}+</style>+<body onload="checkLayoutForAnchorPos('.target')">+ <div>+ <div class="spacer" style="height: 10px"></div>+ <div class="grid cb">+ <div class="item">1</div>+ <div class="item">2</div>+ <div class="item">3</div>+ <div class="item">4</div>+ <div class="item">5</div>+ <div class="item">+ <div class="spacer" style="height: 20px"></div>+ <div class="anchor1"></div>+ </div>+ <div class="item">7</div>+ <div class="item">8</div>+ <div class="item">9</div>+ <div class="item">10</div>+ <div class="item">11</div>+ <div class="item">12</div>+ <div class="item">13</div>+ <div class="item">14</div>+ <div class="item">15</div>+ <div class="item">16</div>++ <div class="target"+ data-offset-x=135 data-offset-y=70+ data-expected-height=100></div>+ </div>+ </div>+</body>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-initial-transition.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-initial-transition.htmlnew file mode 100644index 00000000000..d983c074d2e--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-initial-transition.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: Initial @position-try does not trigger a transition</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>+<div id=cb>+ <div id=abs></div>+</div>+<style>+ #cb {+ position: relative;+ width: 100px;+ height: 100px;+ background: lightpink;+ }+ #abs {+ position: absolute;+ background: darkcyan;+ top: 10px;+ left: 10px;+ width: 150px; /* force fallback */+ height: 25px;+ position-try-fallbacks: --pf;+ transition-property: top, left;+ transition-duration: 10s;+ transition-timing-function: steps(2, start);+ }+ @position-try --pf {+ width: 50px;+ top: 50px;+ left: 50px;+ }+</style>+<script>+ test(() => {+ assert_equals(getComputedStyle(abs).top, '50px');+ assert_equals(getComputedStyle(abs).left, '50px');+ }, 'No transition for initial style with @position-try');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-order-inset-modified-containing-block.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-order-inset-modified-containing-block.htmlnew file mode 100644index 00000000000..67a1548da15--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-order-inset-modified-containing-block.html@@ -0,0 +1,66 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: position-try-order behavior with margins</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#position-try-order-property">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ #cb {+ position: absolute;+ width: 400px;+ height: 400px;+ border: 1px solid black;+ }+ #target, #ref {+ position: absolute;+ left: 450px; /* force fallback */+ height: 40px;+ background-color: skyblue;+ }+ #ref {+ background-color: seagreen;+ }++ @position-try --margin {+ left:0px;+ right:0px;+ margin: 100px;+ }+ @position-try --no-margin {+ left:0px;+ right:0px;+ }++</style>+<style id=style>+</style>+<div id=cb>+ <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_position_try_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(getComputedStyle(target).marginLeft, getComputedStyle(ref).marginLeft, 'marginLeft');+ }, `${position_try} | ${position_try_expected}`);+}++// Margin does not affect the inset-modified containing block size so the first option should get picked.+test_position_try_order('most-width --margin, --no-margin', '--margin');+test_position_try_order('most-width --no-margin, --margin', '--no-margin');+test_position_try_order('most-height --margin, --no-margin', '--margin');+test_position_try_order('most-height --no-margin, --margin', '--no-margin');++</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-position-anchor.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-position-anchor.htmlnew file mode 100644index 00000000000..723573c43e4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-position-anchor.html@@ -0,0 +1,43 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: @position-try can set position-anchor</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/check-layout-th.js"></script>+<script src="support/test-common.js"></script>+<style>+ #cb {+ position: relative;+ width: 400px;+ height: 400px;+ }+ .anchor {+ width: 100px;+ height: 100px;+ }+ #anchor-a {+ anchor-name: --a;+ /* Makes #anchored overflow when aligned with right edge */+ margin-left: 100px;+ }+ #anchor-b {+ anchor-name: --b;+ }+ #anchored {+ position: absolute;+ left: anchor(right);+ width: 300px;+ height: 100px;+ position-anchor: --a;+ position-try-fallbacks: --pf;+ }+ @position-try --pf {+ position-anchor: --b;+ }+</style>+<body onload="checkLayoutForAnchorPos('#anchored')">+<div id="cb">+ <div id="anchor-a" class="anchor"></div>+ <div id="anchor-b" class="anchor"></div>+ <div id="anchored" data-offset-x="100"></div>+</div>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-pseudo-element.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-pseudo-element.htmlnew file mode 100644index 00000000000..f28603c4431--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-pseudo-element.html@@ -0,0 +1,55 @@+<!DOCTYPE html>+<title>@position-try for ::before and ::after pseudo elements</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ #container {+ background: maroon;+ position: relative;+ width: 195px;+ height: 200px;+ }+ #target::before {+ position-try-fallbacks: --f1, --f2;+ background: lime;+ position: absolute;+ left: 200px;+ top: 200px;+ width: 100px;+ height: 200px;+ content: "";+ }+ #target::after {+ position-try-fallbacks: --f1, --f2;+ background: green;+ position: absolute;+ left: 100px;+ width: 100px;+ height: 100px;+ content: "";+ }+ @position-try --f1 {+ top: 100px;+ left: 50px;+ }+ @position-try --f2 {+ top: 0px;+ left: 0px;+ }+</style>+<div id="container">+ <div id="target"></div>+</div>+<script>+ test(() => {+ const before_style = getComputedStyle(target, "::before");+ assert_equals(before_style.top, "0px");+ assert_equals(before_style.left, "0px");+ }, "::before using second fallback");+ test(() => {+ const after_style = getComputedStyle(target, "::after");+ assert_equals(after_style.top, "100px");+ assert_equals(after_style.left, "50px");+ }, "::after using first fallback");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-rule-caching-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-rule-caching-001.htmlnew file mode 100644index 00000000000..dfb06b719a5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-rule-caching-001.html@@ -0,0 +1,24 @@+<!DOCTYPE html>++<title>Tests that given two sheets containing the same @position-try, modifying one sheet doesn't affect the other sheet</title>++<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-rule">+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>++<script>+ test(() => {+ const style1 = new CSSStyleSheet();+ const style2 = new CSSStyleSheet();++ const cssText = "@position-try --try { position-area: center }";+ style1.replaceSync(cssText);+ style2.replaceSync(cssText);++ style1.cssRules[0].style.positionArea = "bottom right";++ assert_equals(style2.cssRules[0].style.positionArea, "center");+ }, "Modifying one sheet containing @position-try rule doesn't affect another sheet");+</script>\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-rule-caching-002.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-rule-caching-002.htmlnew file mode 100644index 00000000000..93af92774f2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-rule-caching-002.html@@ -0,0 +1,28 @@+<!DOCTYPE html>++<title>Tests that given two sheets containing the same @position-try, modifying one sheet doesn't affect the other sheet</title>++<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-rule">+<link rel="author" title="Kiet Ho" href="mailto:[email protected]">++<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>++<style id="style1">+ @position-try --try {+ position-area: right top;+ }+</style>++<style id="style2">+ @position-try --try {+ position-area: right top;+ }+</style>++<script>+ test(() => {+ style1.sheet.cssRules[0].style.positionArea = "right bottom";+ assert_equals(style2.sheet.cssRules[0].style.positionArea, "right top");+ }, "Modifying one sheet containing @position-try rule doesn't affect another sheet");+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-transition-basic.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-transition-basic.htmlnew file mode 100644index 00000000000..e245e6f12e2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-transition-basic.html@@ -0,0 +1,64 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: Transition when @position-try is applied</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>+ #cb {+ display: inline-block;+ position: relative;+ width: 400px;+ height: 250px;+ border: 1px solid black;+ }+ #cb.shrink {+ width: 300px;+ }+ #target {+ position: absolute;+ left: 300px;+ width: 50px;+ height: 50px;+ background: skyblue;+ }+ #target.fallback {+ position-try-fallbacks: --200;+ }+ #target.anim {+ transition: left 1000s steps(2, start);+ }+ @position-try --200 {+ left: 200px;+ }+</style>+<div id=cb>+ <div id=target></div>+</div>+<script>+ function cleanup() {+ target.className = '';+ cb.className = '';+ // Clean up running transition+ target.getAnimations().forEach(a => a.cancel());+ }++ test((t) => {+ t.add_cleanup(cleanup);+ assert_equals(target.offsetLeft, 300);+ cb.classList.add('shrink');+ target.classList.add('fallback', 'anim');+ // Now we take the --200 fallback:+ assert_equals(target.offsetLeft, 250);+ }, 'Transition when @position-try is applied');++ test((t) => {+ t.add_cleanup(cleanup);+ cb.classList.add('shrink');+ target.classList.add('fallback');+ assert_equals(target.offsetLeft, 200);+ cb.classList.remove('shrink');+ target.classList.remove('fallback');+ target.classList.add('anim');+ assert_equals(target.offsetLeft, 250);+ }, 'Transition when @position-try is unapplied');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-transition-flip.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-transition-flip.htmlnew file mode 100644index 00000000000..9f33f0664ed--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-transition-flip.html@@ -0,0 +1,74 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: Transition to a flipped state</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-apply">+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ #cb {+ display: inline-block;+ position: relative;+ width: 400px;+ height: 250px;+ border: 1px solid black;+ }+ #cb.shrink {+ width: 325px;+ }+ #anchor {+ position: absolute;+ width: 50px;+ height: 50px;+ background: coral;+ left: 250px;+ top: 50px;+ anchor-name: --a;+ }+ #target {+ position-anchor: --a;+ position: absolute;+ left: anchor(right);+ top: anchor(top);+ width: 50px;+ height: 50px;+ background: skyblue;+ }+ #target.fallback {+ position-try-fallbacks: flip-start;+ }+ #target.anim {+ transition: left 1000s steps(2, start);+ }+</style>+<div id=cb>+ <div id=anchor></div>+ <div id=target></div>+</div>+<script>+ function cleanup() {+ target.className = '';+ cb.className = '';+ // Clean up running transition+ target.getAnimations().forEach(a => a.cancel());+ }++ test((t) => {+ t.add_cleanup(cleanup);+ assert_equals(target.offsetLeft, 300);+ cb.classList.add('shrink');+ target.classList.add('fallback', 'anim');+ assert_equals(target.offsetLeft, 275);+ }, 'Transition to a flipped state');++ test((t) => {+ t.add_cleanup(cleanup);+ cb.classList.add('shrink');+ target.classList.add('fallback');+ assert_equals(target.offsetLeft, 250);+ cb.classList.remove('shrink');+ target.classList.remove('fallback');+ target.classList.add('anim');+ assert_equals(target.offsetLeft, 275);+ }, 'Transition to an unflipped state');++</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-typed-om.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-typed-om.htmlnew file mode 100644index 00000000000..cc6dbb18ee4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/position-try-typed-om.html@@ -0,0 +1,55 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning Test: Effects from @position-try in CSS Typed OM</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: anchor(right);+ top: 50px;+ width: anchor-size(width);+ height: 40px;+ }+ #cb {+ position: relative;+ width: 100px;+ height: 100px;+ border: 1px solid black;+ }+ #anchor {+ position: absolute;+ left: 10px;+ top: 10px;+ width: 20px;+ height: 20px;+ background: coral;+ anchor-name: --a;+ }+ #target {+ position: absolute;+ background: skyblue;+ position-anchor: --a;+ left: 9999px; /* force overflow */+ position-try-fallbacks: --pt;+ }+</style>++<div id=cb>+ <div id=anchor></div>+ <div id=target></div>+</div>+<script>+ function assert_unit_value(actual, expected) {+ assert_true(actual instanceof CSSUnitValue);+ assert_true(expected instanceof CSSUnitValue);+ assert_equals(actual.value, expected.value);+ assert_equals(actual.unit, expected.unit);+ }++ test(() => {+ assert_unit_value(target.computedStyleMap().get('left'), CSS.px(30));+ assert_unit_value(target.computedStyleMap().get('top'), CSS.px(50));+ assert_unit_value(target.computedStyleMap().get('width'), CSS.px(20));+ assert_unit_value(target.computedStyleMap().get('height'), CSS.px(40));+ }, 'Effects of position-try-fallbacks are visible in the computed values');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/try-tactic-back-to-base.html b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/try-tactic-back-to-base.htmlnew file mode 100644index 00000000000..6e8bf5a53a5--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-anchor-position/try-tactic-back-to-base.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<title>CSS Anchor Positioning: try-tactic, back to base values</title>+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic">+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<style>+ #cb {+ position: absolute;+ width: 400px;+ height: 200px;+ border: 1px solid black;+ }+ #target {+ position: absolute;+ width: 50px;+ height: 50px;+ /* Does not fit ... */+ left: 180px;+ top: 190px;+ /* ... and neither does this. */+ position-try-fallbacks: flip-block;+ background-color: coral;++ }+</style>+<div id=cb>+ <div id=target></div>+</div>+<script>+ test(() => {+ let cs = getComputedStyle(target);+ assert_equals(cs.left, '180px');+ assert_equals(cs.top, '190px');+ }, 'Should use base values when nothing fits');+</script>