blob: 36c94caacc9b8ccdbb669ffe95fa0221811d65e9 [file] [log] [blame]
<!DOCTYPE html> <!-- webkit-test-runner [ AsyncOverflowScrollingEnabled=true ] -->
<html>
<head>
<style>
body {
height: 1000px;
}
.scroller {
position: absolute;
top: 10px;
left: 10px;
height: 300px;
width: 300px;
border: 20px solid gray;
padding: 5px;
overflow: scroll;
}
.content {
width: 200%;
height: 300%;
}
.overlapper {
position: absolute;
width: 300px;
height: 300px;
top: 200px;
left: 200px;
border-radius: 50%;
box-shadow: 0 0 20px black; /* Inflate layer size for testing */
background-color: rgba(0, 0, 128, 0.5);
}
</style>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../../resources/ui-helper.js"></script>
<script>
var jsTestIsAsync = true;
var scroller;
var overflowScrollEventCount = 0;
var windowScrollEventCount = 0;
async function resetScrollPositions()
{
window.scrollTo(0, 0);
scroller.scrollTop = 0;
// Wait for scroll events to fire.
await UIHelper.renderingUpdate();
overflowScrollEventCount = 0;
windowScrollEventCount = 0;
}
async function testScrollOverContent()
{
debug('');
debug('Test scroll over content');
await resetScrollPositions();
await UIHelper.mouseWheelScrollAt(50, 50);
shouldBe('overflowScrollEventCount > 0', 'true');
shouldBe('windowScrollEventCount == 0', 'true');
}
async function testScrollOverOverlapper()
{
debug('');
debug('Test scroll over overlapping element');
await resetScrollPositions();
await UIHelper.mouseWheelScrollAt(300, 300);
shouldBe('overflowScrollEventCount == 0', 'true');
shouldBe('windowScrollEventCount > 0', 'true');
}
async function testScrollOverOverlapperOutsideRadius()
{
debug('');
debug('Test scroll over overlapping element outside border');
await resetScrollPositions();
await UIHelper.mouseWheelScrollAt(230, 230);
shouldBe('overflowScrollEventCount > 0', 'true');
shouldBe('windowScrollEventCount == 0', 'true');
}
async function scrollTest()
{
await testScrollOverContent();
await testScrollOverOverlapper();
await testScrollOverOverlapperOutsideRadius();
finishJSTest();
}
window.addEventListener('load', () => {
scroller = document.querySelector('.scroller');
scroller.addEventListener('scroll', () => {
++overflowScrollEventCount;
}, false);
window.addEventListener('scroll', () => {
++windowScrollEventCount;
}, false);
setTimeout(scrollTest, 0);
}, false);
</script>
</head>
<body>
<div class="scroller">
<div class="content"></div>
</div>
<div class="overlapper"></div>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>