Skip to content

Commit 1669f8a

Browse files
lilleschromium-wpt-export-bot
authored andcommitted
Make some scroll-timelines tests not rely on dirty-tree snapshot
An HTML PR[1] is attempting to move snapshotting of post-layout state to where the layout tree is actually clean. The test changes here make them valid both when timelines are updated before the rendering update, and when they are only updated post-layout. [1] whatwg/html#11613 Bug: 384523570 Change-Id: I9435a897fa9fd758ed96bb3c5af373f5b274a463 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6950416 Reviewed-by: Kevin Ellis <kevers@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1516451}
1 parent 660152e commit 1669f8a

File tree

6 files changed

+49
-39
lines changed

6 files changed

+49
-39
lines changed

scroll-animations/scroll-timelines/current-time-writing-modes.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@
3838
assert_percents_equal(verticalScrollTimeline.currentTime, 0,
3939
'Unscrolled vertical timeline');
4040

41-
// The offset in the inline/horizontal direction should be inverted. The
42-
// block/vertical direction should be unaffected.
43-
scroller.scrollTop = 0.1 * verticalScrollRange;
44-
scroller.scrollLeft = -0.8 * horizontalScrollRange;
4541
// Wait for new animation frame which allows the timeline to compute new
4642
// current time.
47-
await waitForNextFrame();
43+
await runAndWaitForFrameUpdate(() => {
44+
// The offset in the inline/horizontal direction should be inverted. The
45+
// block/vertical direction should be unaffected.
46+
scroller.scrollTop = 0.1 * verticalScrollRange;
47+
scroller.scrollLeft = -0.8 * horizontalScrollRange;
48+
});
4849

4950
assert_percents_equal(blockScrollTimeline.currentTime, 10,
5051
'Scrolled block timeline');

scroll-animations/scroll-timelines/effect-updateTiming.html

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,9 @@
460460
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
461461
anim.play();
462462
await anim.ready;
463-
scroller.scrollTop = maxScroll * 0.07
464-
await waitForNextFrame();
463+
await runAndWaitForFrameUpdate(() => {
464+
scroller.scrollTop = maxScroll * 0.07;
465+
});
465466

466467
assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.07,
467468
'progress before updating direction');
@@ -514,8 +515,9 @@
514515
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
515516
anim.play();
516517
await anim.ready;
517-
scroller.scrollTop = maxScroll * 0.17 // 34% through first iteration
518-
await waitForNextFrame();
518+
await runAndWaitForFrameUpdate(() => {
519+
scroller.scrollTop = maxScroll * 0.17; // 34% through first iteration
520+
});
519521

520522
assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.34,
521523
'progress before updating direction');
@@ -535,8 +537,9 @@
535537
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
536538
anim.play();
537539
await anim.ready;
538-
scroller.scrollTop = maxScroll * 0.17
539-
await waitForNextFrame();
540+
await runAndWaitForFrameUpdate(() => {
541+
scroller.scrollTop = maxScroll * 0.17;
542+
});
540543
// anim.currentTime = 17000; // 34% through first iteration
541544
assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.34,
542545
'progress before updating direction');
@@ -556,8 +559,9 @@
556559
async function assert_progress(animation, scrollPercent, easingFunction) {
557560
const scroller = animation.timeline.source;
558561
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
559-
scroller.scrollTop = maxScroll * scrollPercent
560-
await waitForNextFrame();
562+
await runAndWaitForFrameUpdate(() => {
563+
scroller.scrollTop = maxScroll * scrollPercent;
564+
});
561565
assert_approx_equals(animation.effect.getComputedTiming().progress,
562566
easingFunction(scrollPercent),
563567
0.01,
@@ -610,8 +614,9 @@
610614
assert_equals(anim.effect.getComputedTiming().progress, 0,
611615
'easing replace to steps(2, end) at before phase');
612616

613-
scroller.scrollTop = maxScroll * 0.875
614-
await waitForNextFrame();
617+
await runAndWaitForFrameUpdate(() => {
618+
scroller.scrollTop = maxScroll * 0.875;
619+
});
615620

616621
assert_equals(anim.effect.getComputedTiming().progress, 0.5,
617622
'change currentTime to active phase');
@@ -620,8 +625,9 @@
620625
assert_equals(anim.effect.getComputedTiming().progress, 1,
621626
'easing replace to steps(2, start) at active phase');
622627

623-
scroller.scrollTop = maxScroll * 1.25
624-
await waitForNextFrame();
628+
await runAndWaitForFrameUpdate(() => {
629+
scroller.scrollTop = maxScroll * 1.25;
630+
});
625631

626632
anim.effect.updateTiming({ easing: 'steps(2, end)' });
627633
assert_equals(anim.effect.getComputedTiming().progress, 1,

scroll-animations/scroll-timelines/finish-animation.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@
213213
const animation = createScrollLinkedAnimation(t);
214214
const scroller = animation.timeline.source;
215215
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
216-
scroller.scrollTop = 0.25 * maxScroll;
217216
// Wait for new animation frame which allows the timeline to compute new
218217
// current time.
219-
await waitForNextFrame();
218+
await runAndWaitForFrameUpdate(() => {
219+
scroller.scrollTop = 0.25 * maxScroll;
220+
});
220221

221222
const eventWatcher = new EventWatcher(t, animation, 'finish');
222223
animation.finish();
@@ -277,10 +278,10 @@
277278
animation.play();
278279
await animation.ready;
279280

280-
// Make the scroll timeline inactive.
281-
scroller.style.overflow = 'visible';
282-
scroller.scrollTop;
283-
await waitForNextFrame();
281+
await runAndWaitForFrameUpdate(() => {
282+
// Make the scroll timeline inactive.
283+
scroller.style.overflow = 'visible';
284+
});
284285
assert_equals(animation.timeline.currentTime, null,
285286
'Sanity check the timeline is inactive.');
286287
assert_equals(animation.playState, 'running',

scroll-animations/scroll-timelines/pause-animation.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@
8989

9090
const currentTimeAfterPausing = animation.currentTime;
9191

92-
scroller.scrollTop = 0.2 * maxScroll;
93-
await waitForNextFrame();
92+
await runAndWaitForFrameUpdate(() => {
93+
scroller.scrollTop = 0.2 * maxScroll;
94+
});
9495
assert_percents_equal(animation.timeline.currentTime, 20,
9596
'Sanity check timeline time changed');
9697

@@ -126,12 +127,12 @@
126127
promise_test(async t => {
127128
const animation = createScrollLinkedAnimation(t);
128129
const scroller = animation.timeline.source;
129-
// Make the scroll timeline inactive.
130-
scroller.style.overflow = 'visible';
131-
scroller.scrollTop;
132130
// Wait for new animation frame which allows the timeline to compute new
133131
// current time.
134-
await waitForNextFrame();
132+
await runAndWaitForFrameUpdate(() => {
133+
// Make the scroll timeline inactive.
134+
scroller.style.overflow = 'visible';
135+
});
135136
assert_equals(animation.timeline.currentTime, null,
136137
'Sanity check the timeline is inactive.');
137138
// Pause the animation when the timeline is inactive.
@@ -152,12 +153,12 @@
152153
const scroller = animation.timeline.source;
153154
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
154155
scroller.scrollTop = 0.2 * maxScroll;
155-
// Make the scroll timeline inactive.
156-
scroller.style.overflow = 'visible';
157-
scroller.scrollTop;
158156
// Wait for new animation frame which allows the timeline to compute new
159157
// current time.
160-
await waitForNextFrame();
158+
await runAndWaitForFrameUpdate(() => {
159+
// Make the scroll timeline inactive.
160+
scroller.style.overflow = 'visible';
161+
});
161162
assert_equals(animation.timeline.currentTime, null,
162163
'Sanity check the timeline is inactive.');
163164
// Play the animation when the timeline is inactive.

scroll-animations/scroll-timelines/reverse-animation.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@
128128
promise_test(async t => {
129129
const animation = createScrollLinkedAnimation(t);
130130
const scroller = animation.timeline.source;
131-
// Make the scroll timeline inactive.
132-
scroller.style.overflow = 'visible';
133-
scroller.scrollTop;
134-
await waitForNextFrame();
131+
await runAndWaitForFrameUpdate(() => {
132+
// Make the scroll timeline inactive.
133+
scroller.style.overflow = 'visible';
134+
});
135135

136136
assert_throws_dom('InvalidStateError', () => { animation.reverse(); });
137137
}, 'Reversing an animation without an active timeline throws an ' +

scroll-animations/scroll-timelines/scroll-timeline-range.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@
7171
anim.cancel();
7272
});
7373
await anim.ready;
74-
scroller.scrollTop = 600;
75-
await waitForNextFrame();
74+
await runAndWaitForFrameUpdate(() => {
75+
scroller.scrollTop = 600;
76+
});
7677

7778
const expectedProgress =
7879
(600 - options.startOffset) / (options.endOffset - options.startOffset);

0 commit comments

Comments
 (0)