blob: 15afb0bd6e13af2f67fd0214dc03962c3902d335 [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>
window.jsTestIsAsync = true;
var divTarget;
var pageScrollPositionBefore;
var divScrollPositionBefore;
var continueCount = 5;
function onPageScroll()
{
if (document.scrollingElement.scrollTop >= 70)
checkForScroll();
}
let didCheck = false;
function checkForScroll()
{
if (didCheck)
return;
didCheck = true;
// The div should not have scrolled at all.
var pageScrollPositionAfter = document.scrollingElement.scrollTop;
var divScrollPositionAfter = divTarget.scrollTop;
if (divScrollPositionBefore != divScrollPositionAfter)
testFailed("Scrollable div consumed wheel events.");
else
testPassed("Scrollable div did not receive wheel events.");
finishJSTest();
}
function scrollTest()
{
pageScrollPositionBefore = document.scrollingElement.scrollTop;
divTarget = document.getElementById('target');
divScrollPositionBefore = divTarget.scrollTop;
// Scroll the #source until we reach the #target.
var startPosX = Math.round(divTarget.offsetLeft) + 20;
var startPosY = Math.round(divTarget.offsetTop) - 42;
eventSender.mouseMoveTo(startPosX, startPosY);
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -4, 'none', 'continue');
eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
eventSender.callAfterScrollingCompletes(checkForScroll);
// We should finish via the scroll event; this will fire in the case of failure when the page doesn't scroll.
}
function setupTopLevel()
{
if (window.eventSender) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
eventSender.monitorWheelEvents();
requestIdleCallback(() => {
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/>"
+ "at the top of the page, and then use the mouse wheel or a two-finger swipe to scroll the<br/>"
+ "down past the div.<br/><br/>"
+ "The scrollable region should not scroll.</p>";
messageLocation.appendChild(message);
}
}
window.addEventListener('load', () => {
setupTopLevel();
window.addEventListener("scroll", onPageScroll);
}, 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; 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 consume wheel events when scroll is latched to main frame.");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>