blob: cbcedc328aa409bff45f38faa5330c7c2cec5ad9 [file] [log] [blame]
<!DOCTYPE HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../resources/gesture-util.js"></script>
<script src="resources/scroll-util.js"></script>
<style>
#targetDiv {
width: 200px;
height: 200px;
overflow: scroll;
}
#innerDiv {
width: 400px;
height: 400px;
}
</style>
<body style="margin:0">
<div id="targetDiv">
<div id="innerDiv">
</div>
</div>
</body>
<script>
if (window.internals)
internals.runtimeFlags.overscrollCustomizationEnabled = true;
var target_div = document.getElementById('targetDiv');
var rect = target_div.getBoundingClientRect();
var x = rect.left + rect.width / 2;
var y = rect.top + rect.height / 2;
var horizontal_scrollend_arrived = false;
var vertical_scrollend_arrived = false;
function onHorizontalScrollEnd(event) {
assert_false(event.cancelable);
// scrollend events are bubbled when the target node is document.
assert_true(event.bubbles);
horizontal_scrollend_arrived = true;
}
function onVerticalScrollEnd(event) {
assert_false(event.cancelable);
// scrollend events are bubbled when the target node is document.
assert_true(event.bubbles);
vertical_scrollend_arrived = true;
}
document.addEventListener("scrollend", onHorizontalScrollEnd);
document.addEventListener("scrollend", onVerticalScrollEnd);
async function test_scrollend_event_fire(source_device,
precise_scrolling_delta) {
horizontal_scrollend_arrived = false;
vertical_scrollend_arrived = false;
await waitForCompositorCommit();
// Scroll left on target div and wait for the doc to get scrollend event.
await scrollLeft(source_device, precise_scrolling_delta);
await waitFor(() => { return horizontal_scrollend_arrived; },
'Document did not receive scrollend event after scroll left on target.');
assert_equals(target_div.scrollLeft, 0);
// Scroll up on target div and wait for the doc to get scrollend event.
await scrollUp(source_device, precise_scrolling_delta);
await waitFor(() => { return vertical_scrollend_arrived; },
'Document did not receive scrollend event after scroll up on target.');
assert_equals(target_div.scrollTop, 0);
}
promise_test (async (t) => {
// Make sure that no scrollend event is sent to target_div.
target_div.addEventListener("scrollend",
t.unreached_func("target_div got unexpected scrollend event."));
return test_scrollend_event_fire(GestureSourceType.TOUCH_INPUT);
}, 'Tests that the document gets scrollend event when no element scrolls by ' +
'touch.');
promise_test (async (t) => {
// Make sure that no scrollend event is sent to target_div.
target_div.addEventListener("scrollend",
t.unreached_func("target_div got unexpected scrollend event."));
return test_scrollend_event_fire(GestureSourceType.MOUSE_INPUT,
true /* precise_scrolling_delta */);
}, 'Tests that the document gets scrollend event when no element scrolls by '+
' wheel in non-animated scrolling path.');
promise_test (async (t) => {
// Make sure that no scrollend event is sent to target_div.
target_div.addEventListener("scrollend",
t.unreached_func("target_div got unexpected scrollend event."));
return test_scrollend_event_fire(GestureSourceType.MOUSE_INPUT,
false /* precise_scrolling_delta */);
}, 'Tests that the document gets scrollend event when no element scrolls by '+
' wheel in smooth scrolling path.');
</script>