|
27 | 27 | <script src="/resources/testdriver.js"></script>
|
28 | 28 | <script src="/resources/testdriver-vendor.js"></script>
|
29 | 29 | <script src="/resources/testdriver-actions.js"></script>
|
| 30 | +<script src="/dom/events/scrolling/scroll_support.js"></script> |
30 | 31 | <script src="../support/common.js"></script>
|
| 32 | + |
31 | 33 | <div id="scroller">
|
32 | 34 | <div class="box"></div>
|
33 |
| - <div class="box"></div> |
| 35 | + <div id="target" class="box"></div> |
34 | 36 | <div id="space"></div>
|
35 | 37 | </div>
|
36 | 38 | <script>
|
37 | 39 | promise_test(async t => {
|
| 40 | + await waitForCompositorReady(); |
38 | 41 | const scroller = document.getElementById("scroller");
|
39 | 42 | scroller.scrollTo(0, 0);
|
40 | 43 | assert_equals(scroller.scrollTop, 0, "verify test pre-condition");
|
|
43 | 46 | };
|
44 | 47 | const scrollPromise = waitForScrollEvent(scroller);
|
45 | 48 | const wheelPromise = waitForWheelEvent(scroller);
|
| 49 | + const targetBounds = |
| 50 | + document.getElementById('target').getBoundingClientRect(); |
| 51 | + const dy = targetBounds.top / 2 + 1; |
46 | 52 | const actions = new test_driver.Actions()
|
47 |
| - .scroll(50, 50, 0, 50, {origin: scroller, duration: 100}); |
| 53 | + .scroll(50, 50, 0, dy, {origin: scroller, duration: 100}); |
48 | 54 | await actions.send();
|
49 | 55 | await wheelPromise;
|
50 | 56 | await scrollPromise;
|
51 |
| - let scrollEndTime; |
52 |
| - let snapEndTime; |
53 |
| - // Detect first pause in scrolling. |
54 |
| - const scrollStabilizedPromise = |
55 |
| - waitForAnimationEnd(scrollTop).then((timestamp) => { |
56 |
| - scrollEndTime = timestamp; |
57 |
| - }); |
58 |
| - const snapEndPromise = |
59 |
| - waitForScrollTo(scroller, () => { |
60 |
| - return scroller.scrollTop; |
61 |
| - }, 110).then((evt) => { |
62 |
| - snapEndTime = evt.timestamp; |
63 |
| - }); |
64 |
| - await Promise.all([scrollStabilizedPromise, snapEndPromise]); |
65 |
| - assert_equals(scroller.scrollTop, 110, |
| 57 | + // Detect first pause in scrolling. As expected to snap right at the end of |
| 58 | + // the scroll, there should be no appreciable pause before the snap takes |
| 59 | + // place. Once the scrolling settles, we are expected to be at the snap |
| 60 | + // position. |
| 61 | + const scrollStabilizedPromise = waitForAnimationEnd(scrollTop); |
| 62 | + await scrollStabilizedPromise; |
| 63 | + assert_approx_equals(scroller.scrollTop, 110, 0.5, |
66 | 64 | 'Failed to advance to next snap target');
|
67 |
| - assert_true(snapEndTime < scrollEndTime, |
68 |
| - 'Detected pause in scrolling before reaching snap target'); |
69 |
| -}, "Wheel-scroll triggers snap to target position immediately."); |
| 65 | +}, "Wheel-scroll triggers snap to target position without intermediate pause."); |
70 | 66 | </script>
|
0 commit comments