1<!DOCTYPE HTML> 2<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1"> 3<script src="/resources/testharness.js"></script> 4<script src="/resources/testharnessreport.js"></script> 5<script src="/resources/testdriver.js"></script> 6<script src="/resources/testdriver-actions.js"></script> 7<script src="/resources/testdriver-vendor.js"></script> 8<script src="scroll_support.js"></script> 9<style> 10#scrollableDiv { 11 width: 200px; 12 height: 200px; 13 overflow: scroll; 14} 15 16#innerDiv { 17 width: 400px; 18 height: 400px; 19} 20</style> 21 22<body style="margin:0" onload=runTest()> 23<div id="scrollableDiv"> 24 <div id="innerDiv"> 25 </div> 26</div> 27</body> 28 29<script> 30var scrolling_div = document.getElementById('scrollableDiv'); 31var horizontal_scrollend_arrived = false; 32var vertical_scrollend_arrived = false; 33function onHorizontalScrollEnd(event) { 34 assert_false(event.cancelable); 35 assert_false(event.bubbles); 36 horizontal_scrollend_arrived = true; 37} 38function onVerticalScrollEnd(event) { 39 assert_false(event.cancelable); 40 assert_false(event.bubbles); 41 vertical_scrollend_arrived = true; 42} 43scrolling_div.addEventListener("scrollend", onHorizontalScrollEnd); 44scrolling_div.addEventListener("scrollend", onVerticalScrollEnd); 45 46function runTest() { 47 promise_test (async (t) => { 48 // Make sure that no scrollend event is sent to document. 49 document.addEventListener("scrollend", 50 t.unreached_func("Document got unexpected scrollend event.")); 51 await waitForCompositorCommit(); 52 53 // Do a horizontal scroll and wait for scrollend event. 54 await touchScrollInTarget(300, scrolling_div, 'right'); 55 await waitFor(() => { return horizontal_scrollend_arrived; }, 56 'Scroller did not receive scrollend event after horizontal scroll.'); 57 assert_equals(scrolling_div.scrollWidth - scrolling_div.scrollLeft, 58 scrolling_div.clientWidth); 59 60 // Do a vertical scroll and wait for scrollend event. 61 await touchScrollInTarget(300, scrolling_div, 'down'); 62 await waitFor(() => { return vertical_scrollend_arrived; }, 63 'Scroller did not receive scrollend event after vertical scroll.'); 64 assert_equals(scrolling_div.scrollHeight - scrolling_div.scrollTop, 65 scrolling_div.clientHeight); 66 }, 'Tests that the scrolled element gets scrollend event at the end of touch scrolling.'); 67} 68</script> 69