blob: d750d9486c481240d06955e6dacb5aa189e7aec9 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/ui-helper.js"></script>
</head>
<body onload="setupTopLevel();">
<script>
var pageScrollPositionBefore;
var iframeTarget;
var iFrameScrollPositionBefore;
var selectTarget;
var selectTargetScrollPositionBefore;
function checkForScroll()
{
// The IFrame should not have scrolled at all.
var pageScrollPositionAfter = document.scrollingElement.scrollTop;
if (pageScrollPositionAfter != pageScrollPositionAfter)
testFailed("Page consumed wheel events.");
else
testPassed("Page did not receive wheel events.");
var iFrameScrollPositionAfter = window.frames['target'].document.scrollingElement.scrollTop;
if (iFrameScrollPositionBefore != iFrameScrollPositionAfter)
testFailed("IFrame consumed wheel events.");
else
testPassed("IFrame did not receive wheel events.");
var selectTargetScrollPositionAfter = selectTarget.scrollTop;
if (selectTargetScrollPositionBefore != selectTargetScrollPositionAfter)
testPassed("Select consumed wheel events.");
else
testFailed("Select did not receive wheel events.");
finishJSTest();
testRunner.notifyDone();
}
async function scrollTest()
{
pageScrollPositionBefore = document.scrollingElement.scrollTop;
iFrameScrollPositionBefore = window.frames['target'].document.scrollingElement.scrollTop;
iframeTarget = document.getElementById('target');
selectTarget = window.frames['target'].document.getElementById('selectTarget');
selectTargetScrollPositionBefore = selectTarget.scrollTop;
// Scroll the #source until we reach the #target.
const startPosX = Math.round(selectTarget.offsetLeft) + 10;
const startPosY = Math.round(selectTarget.offsetTop) + 10; // Slightly more than one wheel scroll away from the IFrame
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();
// 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();
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 iframe.<br/><br/>"
+ "The iframe should not scroll.</p>";
messageLocation.appendChild(message);
}
}
</script>
<div id="parent" style="height: 2000px;">
<iframe id="target" name="target" height="500" width="600" src="resources/select_iframe.html"></iframe>
</iframe>
</div>
<div id="console"></div>
<script>
description("Tests that iframe doesn't consume wheel events when scrolling a select in an iframe.");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>