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 scrollend_arrived = false; 32function onScrollEnd(event) { 33 assert_false(event.cancelable); 34 // scrollend events targetting document are bubbled to the window. 35 assert_true(event.bubbles); 36 scrollend_arrived = true; 37} 38window.addEventListener("scrollend", onScrollEnd); 39 40function runTest() { 41 promise_test (async (t) => { 42 // Make sure that no scrollend event is sent to target_div. 43 target_div.addEventListener("scrollend", 44 t.unreached_func("target_div got unexpected scrollend event.")); 45 await waitForCompositorCommit(); 46 47 // Scroll up on target div and wait for the doc to get scrollend event. 48 await touchScrollInTarget(300, target_div, 'up'); 49 await waitFor(() => { return scrollend_arrived; }, 50 'Window did not receive scrollend event after scroll up on target.'); 51 assert_equals(target_div.scrollTop, 0); 52 }, 'Tests that the window gets scrollend event when no element scrolls ' + 53 'after touch scrolling.'); 54} 55</script> 56