smooth-scroll-in-load-event.html (1803B)
1 <!DOCTYPE html> 2 <title>A smooth scroll operation in load event handler isn't omitted</title> 3 <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> 4 <link rel="help" href="https://drafts.csswg.org/cssom-view/#concept-smooth-scroll"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/dom/events/scrolling/scroll_support.js"></script> 8 <style> 9 body { 10 margin: 0; 11 } 12 html { 13 overflow: auto; 14 } 15 </style> 16 <div id="pageContent" style="position: absolute; left: 0; top: 0;"></div> 17 <script> 18 window.addEventListener("load", () => { 19 // Expand the page content to make the root scroll container overflowed. 20 pageContent.style.width = (window.innerWidth) * 5 + "px"; 21 pageContent.style.height = (window.innerHeight) * 6 + "px"; 22 23 promise_test(async () => { 24 document.scrollingElement.scrollTo({ 25 left: window.innerWidth, 26 top: window.innerHeight, 27 behavior: "smooth" 28 }); 29 30 assert_equals(document.scrollingElement.scrollLeft, 0, "Should not set scrollLeft immediately"); 31 assert_equals(document.scrollingElement.scrollTop, 0, "Should not set scrollTop immediately"); 32 33 // In the next frame, change something to trigger a paint which might 34 // clobber the smooth scroll operation. 35 await new Promise(resolve => requestAnimationFrame(resolve)); 36 pageContent.style.color = "green"; 37 38 await waitForScrollEndFallbackToDelayWithoutScrollEvent(document); 39 40 assert_equals(document.scrollingElement.scrollLeft, window.innerWidth, "Final value of scrollLeft"); 41 assert_equals(document.scrollingElement.scrollTop, window.innerHeight, "Final value of scrollTop"); 42 }, `Smooth scroll in load event handler`); 43 }); 44 </script>