3 <title>Scroll timeline with paused animations
</title>
4 <link rel=
"help" href=
"https://drafts.csswg.org/scroll-animations-1/#scroll-notation">
5 <link rel=
"help" href=
"https://drafts.csswg.org/css-animations/#animation-play-state">
6 <script src=
"/resources/testharness.js"></script>
7 <script src=
"/resources/testharnessreport.js"></script>
8 <script src=
"/scroll-animations/scroll-timelines/testcommon.js"></script>
9 <script src=
"/css/css-animations/support/testcommon.js"></script>
12 from { width:
100px; }
26 async
function resetScrollPosition() {
27 // Reset to 0 so we don't affect following tests.
28 document
.scrollingElement
.scrollTop
= 0;
29 return waitForNextFrame();
32 promise_test(async t
=> {
33 const div
= addDiv(t
, { style
: 'width: 50px; height: 100px;' });
34 const filling
= addDiv(t
, { class: 'fill-vh' });
35 const scroller
= document
.scrollingElement
;
36 t
.add_cleanup(resetScrollPosition
);
38 div
.style
.animation
= 'anim 100s linear paused scroll(root)';
39 const anim
= div
.getAnimations()[0];
41 assert_percents_equal(anim
.currentTime
, 0, 'timeline time reset');
42 assert_equals(getComputedStyle(div
).width
, '100px');
44 const maxScroll
= scroller
.scrollHeight
- scroller
.clientHeight
;
45 scroller
.scrollTop
= maxScroll
;
46 await
waitForNextFrame();
47 assert_equals(getComputedStyle(div
).width
, '100px');
49 }, 'Test that the scroll animation is paused');
51 promise_test(async t
=> {
52 const div
= addDiv(t
, { style
: 'width: 50px; height: 100px;' });
53 const filling
= addDiv(t
, { class: 'fill-vh' });
54 const scroller
= document
.scrollingElement
;
55 await
waitForNextFrame();
57 div
.style
.animation
= 'anim 100s linear forwards scroll(root)';
58 const anim
= div
.getAnimations()[0];
60 assert_percents_equal(anim
.currentTime
, 0, 'timeline time reset');
61 assert_equals(getComputedStyle(div
).width
, '100px');
63 await
waitForNextFrame();
64 const maxScroll
= scroller
.scrollHeight
- scroller
.clientHeight
;
65 scroller
.scrollTop
= maxScroll
;
66 await
waitForNextFrame();
67 assert_equals(getComputedStyle(div
).width
, '200px');
69 div
.style
.animationPlayState
= 'paused';
70 assert_equals(anim
.playState
, 'paused');
71 assert_equals(getComputedStyle(div
).width
, '200px',
72 'Current time preserved when pause-pending.');
73 assert_true(anim
.pending
,
74 'Pending state after changing animationPlayState');
76 assert_equals(getComputedStyle(div
).width
, '200px',
77 'Current time preserved when paused.');
78 assert_percents_equal(anim
.timeline
.currentTime
, 100);
79 document
.scrollingElement
.scrollTop
= 0;
80 await
waitForNextFrame();
81 assert_percents_equal(anim
.timeline
.currentTime
, 0);
82 assert_equals(getComputedStyle(div
).width
, '200px');
83 }, 'Test that the scroll animation is paused by updating animation-play-state');