11cb0ef41Sopenharmony_ci<!DOCTYPE HTML> 21cb0ef41Sopenharmony_ci<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1"> 31cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 41cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 51cb0ef41Sopenharmony_ci<script src="/resources/testdriver.js"></script> 61cb0ef41Sopenharmony_ci<script src="/resources/testdriver-actions.js"></script> 71cb0ef41Sopenharmony_ci<script src="/resources/testdriver-vendor.js"></script> 81cb0ef41Sopenharmony_ci<script src="scroll_support.js"></script> 91cb0ef41Sopenharmony_ci<style> 101cb0ef41Sopenharmony_ci#targetDiv { 111cb0ef41Sopenharmony_ci width: 200px; 121cb0ef41Sopenharmony_ci height: 200px; 131cb0ef41Sopenharmony_ci overflow: scroll; 141cb0ef41Sopenharmony_ci} 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci#innerDiv { 171cb0ef41Sopenharmony_ci width: 500px; 181cb0ef41Sopenharmony_ci height: 4000px; 191cb0ef41Sopenharmony_ci} 201cb0ef41Sopenharmony_ci</style> 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci<body style="margin:0" onload=runTest()> 231cb0ef41Sopenharmony_ci<div id="targetDiv"> 241cb0ef41Sopenharmony_ci <div id="innerDiv"> 251cb0ef41Sopenharmony_ci </div> 261cb0ef41Sopenharmony_ci</div> 271cb0ef41Sopenharmony_ci</body> 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci<script> 301cb0ef41Sopenharmony_ciconst target_div = document.getElementById('targetDiv'); 311cb0ef41Sopenharmony_cilet scrollend_arrived = false; 321cb0ef41Sopenharmony_cilet scrollend_event_count = 0; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_cifunction onScrollEnd(event) { 351cb0ef41Sopenharmony_ci assert_false(event.cancelable); 361cb0ef41Sopenharmony_ci assert_false(event.bubbles); 371cb0ef41Sopenharmony_ci scrollend_arrived = true; 381cb0ef41Sopenharmony_ci scrollend_event_count += 1; 391cb0ef41Sopenharmony_ci} 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_cifunction runTest() { 421cb0ef41Sopenharmony_ci promise_test (async (t) => { 431cb0ef41Sopenharmony_ci // Make sure that no scrollend event is sent to document. 441cb0ef41Sopenharmony_ci document.addEventListener("scrollend", 451cb0ef41Sopenharmony_ci t.unreached_func("document got unexpected scrollend event.")); 461cb0ef41Sopenharmony_ci await waitForCompositorCommit(); 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci // Scroll down & up & down on target div and wait for the target_div to get scrollend event. 491cb0ef41Sopenharmony_ci target_div.addEventListener("scrollend", onScrollEnd); 501cb0ef41Sopenharmony_ci const move_path = [ 511cb0ef41Sopenharmony_ci { x: 0, y: -300}, // down 521cb0ef41Sopenharmony_ci { x: 0, y: -100}, // up 531cb0ef41Sopenharmony_ci { x: 0, y: -400}, // down 541cb0ef41Sopenharmony_ci { x: 0, y: -200}, // up 551cb0ef41Sopenharmony_ci ]; 561cb0ef41Sopenharmony_ci await touchScrollInTargetSequentiallyWithPause(target_div, move_path, 150); 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci await waitFor(() => {return scrollend_arrived;}, 591cb0ef41Sopenharmony_ci 'target_div did not receive scrollend event after sequence of scrolls on target.'); 601cb0ef41Sopenharmony_ci assert_equals(scrollend_event_count, 1); 611cb0ef41Sopenharmony_ci }, "Move down, up and down again, receive scrollend event only once"); 621cb0ef41Sopenharmony_ci} 631cb0ef41Sopenharmony_ci</script> 64