11cb0ef41Sopenharmony_ci<!DOCTYPE HTML> 21cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script> 31cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script> 41cb0ef41Sopenharmony_ci<script src="/resources/testdriver.js"></script> 51cb0ef41Sopenharmony_ci<script src="/resources/testdriver-actions.js"></script> 61cb0ef41Sopenharmony_ci<script src="/resources/testdriver-vendor.js"></script> 71cb0ef41Sopenharmony_ci<script src="scroll_support.js"></script> 81cb0ef41Sopenharmony_ci<style> 91cb0ef41Sopenharmony_ci#scrollableDiv { 101cb0ef41Sopenharmony_ci width: 200px; 111cb0ef41Sopenharmony_ci height: 200px; 121cb0ef41Sopenharmony_ci overflow: scroll; 131cb0ef41Sopenharmony_ci} 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci#innerDiv { 161cb0ef41Sopenharmony_ci width: 400px; 171cb0ef41Sopenharmony_ci height: 400px; 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci</style> 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci<body style="margin:0" onload=runTest()> 221cb0ef41Sopenharmony_ci<div id="scrollableDiv"> 231cb0ef41Sopenharmony_ci <div id="innerDiv"> 241cb0ef41Sopenharmony_ci </div> 251cb0ef41Sopenharmony_ci</div> 261cb0ef41Sopenharmony_ci</body> 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci<script> 291cb0ef41Sopenharmony_civar scrolling_div = document.getElementById('scrollableDiv'); 301cb0ef41Sopenharmony_civar overscrolled_x_delta = 0; 311cb0ef41Sopenharmony_civar overscrolled_y_delta = 0; 321cb0ef41Sopenharmony_cifunction onOverscroll(event) { 331cb0ef41Sopenharmony_ci assert_false(event.cancelable); 341cb0ef41Sopenharmony_ci assert_false(event.bubbles); 351cb0ef41Sopenharmony_ci overscrolled_x_delta = event.deltaX; 361cb0ef41Sopenharmony_ci overscrolled_y_delta = event.deltaY; 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ciscrolling_div.addEventListener("overscroll", onOverscroll); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_cifunction runTest() { 411cb0ef41Sopenharmony_ci promise_test (async (t) => { 421cb0ef41Sopenharmony_ci // Make sure that no overscroll event is sent to document. 431cb0ef41Sopenharmony_ci document.addEventListener("overscroll", 441cb0ef41Sopenharmony_ci t.unreached_func("Document got unexpected overscroll event.")); 451cb0ef41Sopenharmony_ci await waitForCompositorCommit(); 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci // Do a horizontal scroll and wait for overscroll event. 481cb0ef41Sopenharmony_ci await touchScrollInTarget(300, scrolling_div , 'right'); 491cb0ef41Sopenharmony_ci await waitFor(() => { return overscrolled_x_delta > 0; }, 501cb0ef41Sopenharmony_ci 'Scroller did not receive overscroll event after horizontal scroll.'); 511cb0ef41Sopenharmony_ci assert_equals(scrolling_div.scrollWidth - scrolling_div.scrollLeft, 521cb0ef41Sopenharmony_ci scrolling_div.clientWidth); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci overscrolled_x_delta = 0; 551cb0ef41Sopenharmony_ci overscrolled_y_delta = 0; 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci // Do a vertical scroll and wait for overscroll event. 581cb0ef41Sopenharmony_ci await touchScrollInTarget(300, scrolling_div, 'down'); 591cb0ef41Sopenharmony_ci await waitFor(() => { return overscrolled_y_delta > 0; }, 601cb0ef41Sopenharmony_ci 'Scroller did not receive overscroll event after vertical scroll.'); 611cb0ef41Sopenharmony_ci assert_equals(scrolling_div.scrollHeight - scrolling_div.scrollTop, 621cb0ef41Sopenharmony_ci scrolling_div.clientHeight); 631cb0ef41Sopenharmony_ci }, 'Tests that the scrolled element gets overscroll event after fully scrolling by touch.'); 641cb0ef41Sopenharmony_ci} 651cb0ef41Sopenharmony_ci</script> 66