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#targetDiv { 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="targetDiv"> 24 <div id="innerDiv"> 25 </div> 26</div> 27</body> 28 29<script> 30var target_div = document.getElementById('targetDiv'); 31var horizontal_scrollend_arrived = false; 32var vertical_scrollend_arrived = false; 33function onHorizontalScrollEnd(event) { 34 assert_false(event.cancelable); 35 // scrollend events are bubbled when the target node is document. 36 assert_true(event.bubbles); 37 horizontal_scrollend_arrived = true; 38} 39function onVerticalScrollEnd(event) { 40 assert_false(event.cancelable); 41 // scrollend events are bubbled when the target node is document. 42 assert_true(event.bubbles); 43 vertical_scrollend_arrived = true; 44} 45 46function runTest() { 47 promise_test (async (t) => { 48 // Make sure that no scrollend event is sent to target_div. 49 target_div.addEventListener("scrollend", 50 t.unreached_func("target_div got unexpected scrollend event.")); 51 await waitForCompositorCommit(); 52 53 // Scroll left on target div and wait for the doc to get scrollend event. 54 document.addEventListener("scrollend", onHorizontalScrollEnd); 55 await touchScrollInTarget(300, target_div, 'left'); 56 await waitFor(() => { return horizontal_scrollend_arrived; }, 57 'Document did not receive scrollend event after scroll left on target.'); 58 assert_equals(target_div.scrollLeft, 0); 59 document.removeEventListener("scrollend", onHorizontalScrollEnd); 60 61 // Scroll up on target div and wait for the doc to get scrollend event. 62 document.addEventListener("scrollend", onVerticalScrollEnd); 63 await touchScrollInTarget(300, target_div, 'up'); 64 await waitFor(() => { return vertical_scrollend_arrived; }, 65 'Document did not receive scrollend event after scroll up on target.'); 66 assert_equals(target_div.scrollTop, 0); 67 }, 'Tests that the document gets scrollend event when no element scrolls by ' + 68 'touch.'); 69} 70</script> 71