blob: bb45ec598ac09d3c49242207e1a86bb6cf2a5970 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
.scrollable_region {
width: 680px;
}
.table td, .table th {
padding: 2px;
}
.table th {
height: 20px;
text-align: left;
font-weight: strong;
}
.table tr:nth-child(odd) {
background: #f3f3f3;
}
.scrollable_select option:nth-child(odd) {
background: #f3f3f3;
}
</style>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script>
function onLoad() {
setupTopLevel();
}
</script>
</head>
<body onload="onLoad();">
<script>
var selectTarget;
var pageScrollPositionBefore;
var selectScrollPositionBefore;
var continueCount = 5;
function checkForScroll()
{
// The page should not have scrolled at all.
var pageScrollPositionAfter = document.scrollingElement.scrollTop;
var selectScrollPositionAfter = selectTarget.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);
}
testRunner.notifyDone();
}
async function scrollTest()
{
pageScrollPositionBefore = document.scrollingElement.scrollTop;
selectTarget = document.getElementById('target');
selectTarget.scrollTop = selectTarget.scrollHeight - selectTarget.clientHeight - 100;
selectScrollPositionBefore = selectTarget.scrollTop;
// Scroll the #source until we reach the #target.
const startPosX = Math.round(selectTarget.offsetLeft) + 20;
const startPosY = Math.round(selectTarget.offsetTop) + Math.round(selectTarget.clientHeight) - 42;
debug("div display height = " + Math.round(selectTarget.clientHeight));
debug("Mouse moved to (" + startPosX + ", " + startPosY + ")");
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) {
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/>"
+ "inside the select box, and scroll near (but not AT) the bottom of the range. Use the mouse wheel or a two-finger<br/>"
+ "swipe to scroll through the rest of the select options.<br/><br/>"
+ "You should not see the page position change if this test is successful.</p>";
messageLocation.appendChild(message);
}
}
</script>
<div id="parent" style="height: 2000px; width: 2000px;">
<div id="source" style="height: 100px; width: 500px;">
Put mouse near the bottom of the select and scroll downwards.
</div>
<div class="scrollable_region">
<h3>Scrollable Select</h3>
<select id="target" class="scrollable_select" size="8">
<option>content1</option>
<option>content2</option>
<option>content3</option>
<option>content4</option>
<option>content5</option>
<option>content6</option>
<option>content7</option>
<option>content8</option>
<option>content9</option>
<option>content10</option>
<option>content11</option>
<option>content12</option>
<option>content13</option>
<option>content14</option>
<option>content15</option>
<option>content16</option>
<option>content17</option>
<option>content18</option>
<option>content19</option>
<option>content20</option>
<option>content21</option>
</select>
</div>
</div>
</div>
<div id="console"></div>
<script>
description("Tests that a select 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>