summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html')
-rw-r--r--testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html b/testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html
new file mode 100644
index 0000000000..8b61a9ab81
--- /dev/null
+++ b/testing/web-platform/tests/scroll-animations/view-timelines/contain-alignment.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<link rel="help" src="https://drafts.csswg.org/scroll-animations-1/">
+<style>
+
+@keyframes bg {
+ from { background-color: rgb(254, 0, 0); }
+ to { background-color: rgb(0 254, 0); }
+}
+.item {
+ flex-grow: 1;
+ width: 2em;
+ height: 2em;
+ background: #888;
+ animation: bg linear;
+ animation-timeline: view();
+ animation-range: contain;
+}
+
+.inline .item {
+ animation-timeline: view(inline);
+}
+
+.scroller {
+ width: 10em;
+ height: 10em;
+ outline: 1px solid;
+ margin: 1em;
+ overflow: auto;
+ display: inline-flex;
+ vertical-align: top;
+ flex-direction: column;
+ gap: 1em;
+ resize: vertical;
+}
+
+.inline {
+ resize: horizontal;
+ flex-direction: row;
+}
+
+.block .spacer {
+ height: 20em;
+ width: 1em;
+}
+
+.inline .spacer {
+ width: 20em;
+ height: 1em;
+}
+</style>
+<body>
+<div class="scroller block">
+ <div class="item" id="a"></div>
+ <div class="item" id="b"></div>
+ <div class="item" id="c"></div>
+</div>
+
+<div class="scroller inline">
+ <div class="item" id="d"></div>
+ <div class="item" id="e"></div>
+ <div class="item" id="f"></div>
+</div>
+
+<br>
+
+<div class="scroller block">
+ <div class="item" id="g"></div>
+ <div class="item" id="h"></div>
+</div>
+
+<div class="scroller inline">
+ <div class="item" id="i"></div>
+ <div class="item" id="j"></div>
+</div>
+</body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/web-animations/testcommon.js"></script>
+<script type="text/javascript">
+ promise_test(async t => {
+ let anims = document.getAnimations();
+ await Promise.all(anims.map(anim => anim.ready));
+ await waitForNextFrame();
+
+ const expected_results = [
+ { id: "a", progress: 1.0, bg: 'rgb(0, 254, 0)' },
+ { id: "b", progress: 0.5, bg: 'rgb(127, 127, 0)' },
+ { id: "c", progress: 0.0, bg: 'rgb(254, 0, 0)' },
+ { id: "d", progress: 1.0, bg: 'rgb(0, 254, 0)' },
+ { id: "e", progress: 0.5, bg: 'rgb(127, 127, 0)' },
+ { id: "f", progress: 0.0, bg: 'rgb(254, 0, 0)' },
+ { id: "g", progress: 1.0, bg: 'rgb(0, 254, 0)' },
+ { id: "h", progress: 0.0, bg: 'rgb(254, 0, 0)' },
+ { id: "i", progress: 1.0, bg: 'rgb(0, 254, 0)' },
+ { id: "j", progress: 0.0, bg: 'rgb(254, 0, 0)' }
+ ];
+
+ expected_results.forEach(result => {
+ const element = document.getElementById(result.id);
+ const anim = element.getAnimations()[0];
+ assert_approx_equals(anim.effect.getComputedTiming().progress,
+ result.progress, 1e-3,
+ `${result.id}: Unexpected progress`);
+ assert_equals(getComputedStyle(element).backgroundColor,
+ result.bg, `${result.id}: Mismatched background color`);
+ });
+
+ }, 'Stability of animated elements aligned to the bounds of a contain region');
+</script>
+</html>