Files
sousa-gecko/testing/web-platform/tests/scroll-animations/css/scroll-timeline-inactive.html
T
Blink WPT Bot 6d72a59090 Bug 2036323 [wpt PR 59048] - Fix scroll-timeline-inactive.html, a=testonly
Automatic update from web-platform-tests
Fix scroll-timeline-inactive.html (#59048)

Problems:
* missing timeline-scope
* animation paused

As a result, the animation in the second sub-test was forced to have a
hold time of 0s despite supposedly having a scroll-timeline. Without
timeline-scope, the scroll-timeline was not resolved. The test
likely predated the introduction of timeline-scope rules.

Removed time-based values and animation-play-state from the animations
since these were masking the real problem in the second sub-test.
Added validation to ensure the timeline is properly resolved.

Interop 2026

Change-Id: I345f2134bea64aa1b4ef3f4d0c500ecb336bde2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7736342
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1611480}

Co-authored-by: Kevin Ellis <kevers@google.com>
--

wpt-commits: 1d9c8817db562a9ca0972f4ae49e0dc5986ed347
wpt-pr: 59048
2026-05-08 08:38:23 +00:00

120 lines
3.5 KiB
HTML

<!DOCTYPE html>
<link rel="help" src="https://drafts.csswg.org/scroll-animations-1/#scroll-timelines">
<link rel="help" src="https://drafts.csswg.org/scroll-animations-1/#avoiding-cycles">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<style>
@keyframes expand {
from { width: 100px; }
to { width: 200px; }
}
.scroller {
overflow: scroll;
width: 100px;
height: 100px;
}
#main {
timeline-scope: --timeline;
}
</style>
<main id=main></main>
<script>
function inflate(t, template) {
t.add_cleanup(() => main.replaceChildren());
main.append(template.content.cloneNode(true));
main.offsetTop;
}
</script>
<template id=basic>
<style>
#timeline {
scroll-timeline: --timeline;
}
#element {
width: 0px;
animation: expand;
animation-timeline: --timeline;
}
</style>
<div id="container">
<div id=timeline class=scroller><div>
<div id=element></div>
</div>
</template>
<script>
promise_test(async (t) => {
await runAndWaitForFrameUpdate(() => {
inflate(t, basic);
});
const animation = document.getAnimations()[0];
assert_true(animation.timeline instanceof ScrollTimeline,
'Timeline successfully set');
assert_equals(getComputedStyle(element).width, '0px');
}, 'Animation does not apply when the timeline is inactive because there is ' +
'no scroll range');
</script>
<template id=dynamically_change_range>
<style>
#timeline {
scroll-timeline: --timeline;
}
#contents {
height: 200px;
}
#contents.shrink {
height: 0px;
}
#element {
width: 0px;
animation: expand;
animation-timeline: --timeline;
}
</style>
<div id="container">
<div id=timeline class=scroller>
<div id="contents"></div>
</div>
<div id=element></div>
</div>
</template>
<script>
promise_test(async (t) => {
let scroller;
let initial_width;
await runAndWaitForFrameUpdate(() => {
inflate(t, dynamically_change_range);
scroller = document.querySelector('.scroller');
scroller.scrollTop = 0;
initial_width = getComputedStyle(element).width;
});
assert_equals(initial_width, '0px',
'Animation not in effect until after next animation frame');
const animation = document.getAnimations()[0];
assert_true(animation.timeline instanceof ScrollTimeline,
'Timeline successfully set');
assert_equals(getComputedStyle(element).width, '100px',
'Style after frame update');
let updated_width;
let updated_scroll_range;
await runAndWaitForFrameUpdate(() => {
// Style change after the first update-cycle for the frame.
// timeline time remains fixed until the next frame.
contents.classList.add('shrink');
updated_width = getComputedStyle(element).width;
udpated_scroll_range = scroller.scrollHeight - scroller.clientHeight;
});
assert_equals(updated_width, '100px',
'Animation progress fixed until next animation frame');
assert_equals(udpated_scroll_range, 0,
'Scroll range after content collapses');
// Timeline is once again inactive.
assert_equals(getComputedStyle(element).width, '0px',
'Timeline time after frame update with zero scroll range');
}, 'Animation does not apply when timeline becomes inactive');
</script>