fune/testing/web-platform/tests/css/css-anchor-position/position-try-transition-basic.html
Anders Hartvoll Ruud 7c4001dab2 Bug 1889593 [wpt PR 45537] - [anchor] Add WPTs for transitions triggered by position-try-options, a=testonly
Automatic update from web-platform-tests
[anchor] Add WPTs for transitions triggered by position-try-options

Bug: 40943051
Change-Id: I6d486b676d3aaa621727e111f59373c51419c482
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5419305
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1283074}

--

wpt-commits: 9d46525e573e34f4d78d9336e5f089469e60399c
wpt-pr: 45537
2024-04-10 09:26:53 +00:00

58 lines
1.4 KiB
HTML

<!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;
position-try-options: --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 = '';
}
test((t) => {
t.add_cleanup(cleanup);
assert_equals(target.offsetLeft, 300);
cb.classList.add('shrink');
target.classList.add('anim');
// Now we take the --200 option:
assert_equals(target.offsetLeft, 250);
}, 'Transition when @position-try is applied');
test((t) => {
t.add_cleanup(cleanup);
cb.classList.add('shrink');
assert_equals(target.offsetLeft, 200);
cb.classList.remove('shrink');
target.classList.add('anim');
assert_equals(target.offsetLeft, 250);
}, 'Transition when @position-try is unapplied');
</script>