helper_main_thread_smooth_scroll_scrollend.html (1098B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <script src="apz_test_utils.js"></script> 6 <script src="apz_test_native_event_utils.js"></script> 7 <script src="/tests/SimpleTest/EventUtils.js"></script> 8 <script src="/tests/SimpleTest/paint_listener.js"></script> 9 <style> 10 html { 11 overflow: hidden; 12 } 13 #spacer { 14 height: 200vh; 15 width: 200vw; 16 position: absolute; 17 background: linear-gradient(green, blue); 18 } 19 </style> 20 </head> 21 <body> 22 <div id="spacer"></div> 23 </body> 24 <script> 25 async function test() { 26 let scrollendCount = 0; 27 28 window.addEventListener("scrollend", () => { 29 scrollendCount += 1; 30 }); 31 32 window.scrollTo({ top: window.scrollY, behavior: 'smooth' }); 33 34 await promiseFrame(); 35 36 is(scrollendCount, 0, "Scrollend is not fired for a main thread no-op smooth scroll"); 37 38 window.scrollTo({ top: window.scrollY + 200, behavior: 'smooth' }); 39 40 await promiseOneEvent(window, "scrollend"); 41 42 is(scrollendCount, 1, "Scrollend is fired for a main thread smooth scroll"); 43 } 44 waitUntilApzStable() 45 .then(test) 46 .then(subtestDone, subtestFailed); 47 </script>