summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/position-try-cascade.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/css/css-anchor-position/position-try-cascade.html')
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/position-try-cascade.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-anchor-position/position-try-cascade.html b/testing/web-platform/tests/css/css-anchor-position/position-try-cascade.html
new file mode 100644
index 0000000000..d73ddd586a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/position-try-cascade.html
@@ -0,0 +1,141 @@
+<!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-options: --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.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-options: --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 class=abs>
+ <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>