blob: 0c6763c485ddbd5aa076142cf07109cf8ebb4616 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
.scrollable_region {
width: 680px;
}
.scrolled-content {
height: 1036px;
width: 100%;
background-image: repeating-linear-gradient(silver, white 120px);
}
</style>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script>
window.jsTestIsAsync = true;
var divTarget;
var pageScrollPositionBefore;
var divScrollPositionBefore;
var continueCount = 5;
function checkForScroll()
{
// The div should not have scrolled at all.
var pageScrollPositionAfter = document.scrollingElement.scrollTop;
var divScrollPositionAfter = divTarget.scrollTop;
if (pageScrollPositionBefore != pageScrollPositionAfter)
testFailed("Page received wheel events.");
else
testPassed("Page did not receive wheel events.");
if (window.internals) {
document.getElementById('layers').innerText = internals.layerTreeAsText(document,
internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
}
finishJSTest();
}
async function scrollTest()
{
pageScrollPositionBefore = document.scrollingElement.scrollTop;
divTarget = document.getElementById('target');
divTarget.scrollTop = divTarget.scrollHeight - divTarget.clientHeight - 100;
divScrollPositionBefore = divTarget.scrollTop;
// Scroll the #source until we reach the #target.
const startPosX = Math.round(divTarget.offsetLeft) + 20;
const startPosY = Math.round(divTarget.offsetTop) + 100; // One wheel turn before end.
const events = [
{
type : "wheel",
viewX : startPosX,
viewY : startPosY,
deltaY : -10,
phase : "began"
},
{
type : "wheel",
deltaY : -10,
phase : "changed"
},
{
type : "wheel",
deltaY : -10,
phase : "changed"
},
{
type : "wheel",
phase : "ended"
},
{
type : "wheel",
deltaY : -10,
momentumPhase : "began"
},
{
type : "wheel",
deltaY : -10,
momentumPhase : "changed"
},
{
type : "wheel",
momentumPhase : "ended"
}
];
await UIHelper.mouseWheelSequence({ events: events });
checkForScroll();
}
function setupTopLevel()
{
if (window.eventSender) {
setTimeout(scrollTest, 0);
} else {
var messageLocation = document.getElementById('parent');
var message = document.createElement('div');
message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
+ "near the bottom of the scrollable region and scroll up.<br/><br/>"
+ "The page should not scroll.</p>";
messageLocation.appendChild(message);
}
}
window.addEventListener('load', setupTopLevel, false);
</script>
</head>
<body>
<div id="parent" style="height: 2000px; width: 2000px;">
<div id="source" style="height: 100px; width: 500px;">
Put mouse here and flick downwards
</div>
<div class="scrollable_region">
<h3>Scrollable Region</h3>
<div id="target" style='overflow-y: auto; overflow-x: hidden; max-height: 350px;'>
<div class="scrolled-content">Scrolled content</div>
</div>
</div>
</div>
<div id="console"></div>
<script>
description("Tests that a scrollable div doesn't pass wheel events to main frame when scrolling at bottom");
</script>
<pre id="layers">Layer tree goes here</p>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>