| Olga Gerchikov | 342939c | 2020-05-01 17:51:13 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <meta charset="utf-8"> |
| 3 | <title>ScrollTimeline snapshotting</title> |
| 4 | <link rel="help" href="https://wicg.github.io/scroll-animations/#avoiding-cycles"> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <script src="/resources/testdriver.js"></script> |
| 8 | <script src="/resources/testdriver-vendor.js"></script> |
| 9 | <script src="/resources/testdriver-actions.js"></script> |
| 10 | <script src="/web-animations/testcommon.js"></script> |
| 11 | |
| 12 | <style> |
| 13 | body { |
| 14 | height: 800px; |
| 15 | width: 800px; |
| 16 | } |
| 17 | </style> |
| 18 | <div id="log"></div> |
| 19 | |
| 20 | <script> |
| 21 | 'use strict'; |
| 22 | |
| 23 | promise_test(async t => { |
| 24 | const scroller = document.scrollingElement; |
| 25 | const maxScroll = scroller.scrollHeight - scroller.clientHeight; |
| 26 | const timeline = new ScrollTimeline( |
| 27 | {scrollSource: scroller, timeRange: maxScroll}); |
| 28 | scroller.scrollTo(0, 0); |
| 29 | assert_equals(scroller.scrollTop, 0, "verify test pre-condition"); |
| 30 | |
| 31 | scroller.scrollBy({top:100, behavior:'smooth'}) |
| 32 | // Wait for the scroll to change. |
| 33 | const startScroll = scroller.scrollTop; |
| 34 | do { |
| 35 | await waitForNextFrame(); |
| 36 | } while(scroller.scrollTop == startScroll); |
| 37 | assert_times_equal(timeline.currentTime, scroller.scrollTop, |
| 38 | 'Scroll timeline current time corresponds to the scroll position.'); |
| 39 | }, 'ScrollTimeline current time is updated after programmatic animated scroll.'); |
| 40 | |
| 41 | </script> |