Skip to content

Commit 0069f44

Browse files
lillesChromium LUCI CQ
authored andcommitted
Make scroll-timeline snapshotting tests align with spec and proposal
According to the current spec, scroll-timelines are update after scroll events are dispatched, but before style and layout is updated for the frame update. With the proposed change[1] in the HTML specification, the scroll-timelines are updated after a first style/layout update in the resizeObserver loop. We modify the scroll-timeline-snapshotting tests to allow them to pass for both timings. This reveals an issue with the current Blink implementation not matching the current spec, as we snapshot the timelines before the scroll events are dispatched. WebKit implements the current spec and still pass the tests after modification. [1] whatwg/html#11613 Bug: 384523570 Change-Id: I03b29b1f85527f9e54d597586d0764fc53f7776b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7141779 Reviewed-by: Kevin Ellis <[email protected]> Commit-Queue: Rune Lillesveen <[email protected]> Cr-Commit-Position: refs/heads/main@{#1543753}
1 parent 2932fff commit 0069f44

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

third_party/blink/web_tests/TestExpectations

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,9 +1551,13 @@ crbug.com/435625756 external/wpt/css/css-values/urls/referrer-policy/unsafe-url/
15511551
crbug.com/384523570 virtual/run-snapshot-post-layout/external/wpt/scroll-animations/scroll-timelines/effect-updateTiming.html [ Failure ]
15521552
crbug.com/384523570 virtual/run-snapshot-post-layout/external/wpt/scroll-animations/scroll-timelines/scroll-animation-effect-phases.tentative.html [ Failure ]
15531553
crbug.com/384523570 virtual/run-snapshot-post-layout/external/wpt/scroll-animations/scroll-timelines/scroll-animation-inactive-timeline.html [ Failure ]
1554-
crbug.com/384523570 virtual/run-snapshot-post-layout/external/wpt/scroll-animations/scroll-timelines/scroll-timeline-snapshotting.html [ Failure ]
15551554
crbug.com/384523570 virtual/run-snapshot-post-layout/external/wpt/scroll-animations/scroll-timelines/updating-the-finished-state.html [ Pass Timeout ]
1556-
crbug.com/384523570 virtual/run-snapshot-post-layout/fast/animation/scroll-animations/scroll-timeline-snapshotting.html [ Failure ]
1555+
1556+
# Tests only passing with RunSnapshotPostLayoutStateSteps enabled
1557+
crbug.com/384523570 virtual/run-snapshot-post-layout/external/wpt/scroll-animations/scroll-timelines/scroll-timeline-snapshotting.html [ Pass ]
1558+
crbug.com/384523570 virtual/run-snapshot-post-layout/fast/animation/scroll-animations/scroll-timeline-snapshotting.html [ Pass ]
1559+
crbug.com/384523570 external/wpt/scroll-animations/scroll-timelines/scroll-timeline-snapshotting.html [ Failure ]
1560+
crbug.com/384523570 fast/animation/scroll-animations/scroll-timeline-snapshotting.html [ Failure ]
15571561

15581562
# Failing WPT html/semantics/* tests. Not all have been investigated.
15591563
crbug.com/1234202 external/wpt/html/semantics/embedded-content/the-video-element/video_initially_paused.html [ Failure ]

third_party/blink/web_tests/external/wpt/scroll-animations/scroll-timelines/scroll-timeline-snapshotting.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<!DOCTYPE html>
22
<meta charset="utf-8">
33
<title>ScrollTimeline snapshotting</title>
4-
<link rel="help" href="https://wicg.github.io/scroll-animations/#avoiding-cycles">
4+
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#event-loop">
5+
<link rel="help" href="https://github.com/whatwg/html/pull/11613">
56
<script src="/resources/testharness.js"></script>
67
<script src="/resources/testharnessreport.js"></script>
78
<script src="/resources/testdriver.js"></script>
89
<script src="/resources/testdriver-vendor.js"></script>
910
<script src="/resources/testdriver-actions.js"></script>
1011
<script src="/web-animations/testcommon.js"></script>
1112
<script src="./testcommon.js"></script>
13+
<script src="/css/css-scroll-snap/support/common.js"></script>
1214

1315
<style>
1416
body {
@@ -30,13 +32,17 @@
3032

3133
scroller.scrollBy({top: 100, behavior: 'smooth'});
3234
// Wait for the scroll to change.
33-
const startScroll = scroller.scrollTop;
34-
do {
35-
await waitForNextFrame();
36-
} while(scroller.scrollTop == startScroll);
35+
await waitForScrollEvent(document);
36+
// The next frame the scroll changes, the scroll-timelines should not be
37+
// updated before the scroll events are dispatched. Store the scroll position
38+
// from the previous frame to compare the timeline to.
39+
let scroll_percentage = (scroller.scrollTop / maxScroll) * 100;
40+
41+
await waitForScrollEvent(document);
42+
3743
assert_percents_equal(
3844
timeline.currentTime,
39-
(scroller.scrollTop / maxScroll) * 100,
45+
scroll_percentage,
4046
'Scroll timeline current time corresponds to the scroll position.');
4147
}, 'ScrollTimeline current time is updated after programmatic animated ' +
4248
'scroll.');

third_party/blink/web_tests/fast/animation/scroll-animations/resources/testcommon.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ function waitForNextFrame() {
1414
});
1515
}
1616

17+
// Wait for event handler to be dispatched on a given target
18+
function waitForEvent(eventTarget, type) {
19+
return new Promise(resolve => {
20+
eventTarget.addEventListener(type, resolve, { once: true });
21+
});
22+
}
23+
1724
// creates div element, appends it to the document body and
1825
// removes the created element during test cleanup
1926
function createDiv(test, doc) {

third_party/blink/web_tests/fast/animation/scroll-animations/scroll-timeline-snapshotting.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!DOCTYPE html>
22
<meta charset="utf-8">
33
<title>ScrollTimeline snapshotting</title>
4-
<link rel="help" href="https://wicg.github.io/scroll-animations/#avoiding-cycles">
4+
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#event-loop">
5+
<link rel="help" href="https://github.com/whatwg/html/pull/11613">
56
<script src='../../../resources/testharness.js'></script>
67
<script src='../../../resources/testharnessreport.js'></script>
78
<script src='resources/testcommon.js'></script>
@@ -30,14 +31,17 @@
3031

3132
eventSender.keyDown("ArrowDown");
3233
// Wait for the scroll to change.
33-
const startScroll = scroller.scrollTop;
34-
do {
35-
await waitForNextFrame();
36-
} while(scroller.scrollTop == startScroll);
34+
await waitForEvent(document, "scroll");
35+
// The next frame the scroll changes, the scroll-timelines should not be
36+
// updated before the scroll events are dispatched. Store the scroll position
37+
// from the previous frame to compare the timeline to.
38+
let scroll_percentage = (scroller.scrollTop / maxScroll) * 100;
39+
40+
await waitForEvent(document, "scroll");
3741

3842
assert_percents_approx_equal(
3943
timeline.currentTime,
40-
(scroller.scrollTop / maxScroll) * 100,
44+
scroll_percentage,
4145
maxScroll,
4246
'Scroll timeline current time corresponds to the scroll position.');
4347
}, 'Scroll timeline current time is updated after handling user-driven scroll.');

0 commit comments

Comments
 (0)