blob: 36d43c301523610efb03964f098dc69c1150315e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../../resources/ui-helper.js"></script>
<style>
#parent {
background-color: #eee;
}
#target {
background-color: silver;
}
</style>
<script>
window.jsTestIsAsync = true;
var pageScrollPositionBefore;
var pageScrollHeightBefore;
var continueCount = 5;
function checkForScrollOffset()
{
var pageScrollPositionAfter = document.scrollingElement.scrollTop;
var pageScrollHeightAfter = document.scrollingElement.scrollHeight;
if (pageScrollPositionAfter + 100 >= pageScrollPositionBefore)
testFailed("Page did not properly handle rubber banding state.");
else
testPassed("Page properly handled rubber banding state.");
finishJSTest();
}
var zoomOutCount = 0;
function zoomPageOut()
{
if (!zoomOutCount) {
pageScrollPositionBefore = document.scrollingElement.scrollTop;
pageScrollHeightBefore = document.scrollingElement.scrollHeight;
}
eventSender.zoomPageOut();
zoomOutCount = zoomOutCount + 1;
if (zoomOutCount >= 2)
setTimeout(checkForScrollOffset, 100);
else
setTimeout(zoomPageOut, 100);
}
async function scrollDown()
{
// Scroll the #source until we reach the #target.
const selectTarget = document.getElementById('target');
const startPosX = Math.round(selectTarget.offsetLeft) + 20;
const startPosY = Math.round(selectTarget.offsetTop) - 42; // Slightly more than one wheel scroll away from the target div
let events = [
{
type : "wheel",
viewX : startPosX,
viewY : startPosY,
deltaY : -10,
phase : "began"
}
];
const changedEvent = {
type : "wheel",
deltaY : -100,
phase : "changed"
};
const changedEventCount = 40;
const changedEvents = Array(changedEventCount).fill(changedEvent);
events.push(...changedEvents);
events.push({
type : "wheel",
phase : "ended"
});
await UIHelper.mouseWheelSequence({ events: events });
setTimeout(zoomPageOut, 700);
}
var zoomInCount = 0;
function zoomPageIn()
{
eventSender.zoomPageIn();
zoomInCount = zoomInCount + 1;
if (zoomInCount >= 2)
setTimeout(scrollDown, 100);
else
setTimeout(zoomPageIn, 100);
}
function startTest()
{
if (window.eventSender) {
setTimeout(zoomPageIn, 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, perform two text zooms, scroll to the bottom of the page, then zoom back out.<br/>"
+ "The bottom of the test page should not be offset from the bottom of the web view.<\/p>";
messageLocation.appendChild(message);
}
}
window.addEventListener('load', startTest, false);
</script>
</head>
<body>
<div id="parent" style="height: 2000px;">
<div id="source" style="height: 100px">
Put mouse here and do the following:
<ol>
<li>Perform two text zooms (in). (Command+ in Safari)</li>
<li>Scroll down to the bottom. Be sure to scroll far enough that a rubberband animation is triggered.</li>
<li>Perform two text zooms (out). (Commmand- in Safari)</li>
</ol>
</div>
<div id="target" style="height: 1000px; position: relative">
</div>
</div>
<div id="console"></div><script type="text/javascript">
description("Tests that scroll dimensions return to correct size after rubber banding while zoomed.");
</script>
<div id="bottom">This should be at the very bottom of the page.</div>
<script src="../../resources/js-test-post.js" type="text/javascript"></script>
</body>
</html>