summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scroll-animations/css/view-timeline-with-delay-and-range.tentative.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/css/view-timeline-with-delay-and-range.tentative.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/css/view-timeline-with-delay-and-range.tentative.html')
-rw-r--r--testing/web-platform/tests/scroll-animations/css/view-timeline-with-delay-and-range.tentative.html93
1 files changed, 93 insertions, 0 deletions
diff --git a/testing/web-platform/tests/scroll-animations/css/view-timeline-with-delay-and-range.tentative.html b/testing/web-platform/tests/scroll-animations/css/view-timeline-with-delay-and-range.tentative.html
new file mode 100644
index 0000000000..db260f15f0
--- /dev/null
+++ b/testing/web-platform/tests/scroll-animations/css/view-timeline-with-delay-and-range.tentative.html
@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="help" src="https://drafts.csswg.org/scroll-animations-1/#named-timeline-range">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/web-animations/testcommon.js"></script>
+<script src="support/testcommon.js"></script>
+<title>Animation range and delay</title>
+</head>
+<style type="text/css">
+ @keyframes anim {
+ from { opacity: 0 }
+ to { opacity: 1 }
+ }
+ #scroller {
+ border: 10px solid lightgray;
+ overflow-y: scroll;
+ width: 300px;
+ height: 200px;
+ }
+ #target {
+ margin: 800px 0px;
+ width: 100px;
+ height: 100px;
+ z-index: -1;
+ background-color: green;
+ animation: anim auto linear;
+ animation-timeline: --t1;
+ view-timeline: --t1 block;
+ animation-range-start: entry 0%;
+ animation-range-end: entry 100%;
+ /* Sentinel value when in before or after phase of the animation. */
+ opacity: 0.96875;
+ }
+</style>
+<body>
+ <div id=scroller>
+ <div id=target></div>
+ </div>
+</body>
+<script type="text/javascript">
+ async function runTest() {
+
+ function assert_opacity_equals(expected, errorMessage) {
+ assert_approx_equals(
+ parseFloat(getComputedStyle(target).opacity), expected, 1e-6,
+ errorMessage);
+ }
+
+ promise_test(async t => {
+ await waitForNextFrame();
+ const anim = document.getAnimations()[0];
+ await anim.ready;
+
+ await waitForNextFrame();
+ scroller.scrollTop = 650;
+ await waitForNextFrame();
+
+ const baseOpacity = 0.96875;
+ // Delays are percentages.
+ const testData = [
+ { delay: 0, endDelay: 0, opacity: 0.5 },
+ { delay: 20, endDelay: 0, opacity: 0.375 },
+ { delay: 0, endDelay: 20, opacity: 0.625 },
+ { delay: 20, endDelay: 20, opacity: 0.5 },
+ // Negative delays.
+ { delay: -25, endDelay: 0, opacity: 0.6 },
+ { delay: 0, endDelay: -25, opacity: 0.4 },
+ { delay: -25, endDelay: -25, opacity: 0.5 },
+ // Stress tests with >= 100% total delay. Verify effect is inactive.
+ { delay: 100, endDelay: 0, opacity: baseOpacity },
+ { delay: 0, endDelay: 100, opacity: baseOpacity },
+ { delay: 100, endDelay: 100, opacity: baseOpacity }
+ ];
+
+ testData.forEach(test => {
+ anim.effect.updateTiming({
+ delay: CSS.percent(test.delay),
+ endDelay: CSS.percent(test.endDelay)
+ });
+ assert_opacity_equals(
+ test.opacity,
+ `Opacity when delay=${test.delay} and endDelay=${test.endDelay}`);
+ });
+ }, 'ViewTimeline with animation delays and range');
+ }
+
+ window.onload = runTest;
+
+</script>
+</html>