blob: bb8433b07c7374007baa55eec587c30c55f9b77f [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
body { position: relative; height: 4000px; }
</style>
<script src="../../resources/js-test.js"></script>
<script>
description('This tests that window.scrollBy respects the page\'s zoom and scale factor when scrolling.');
function zoomBy(zoomFactor)
{
while (zoomFactor > 0) {
eventSender.zoomPageIn();
zoomFactor--;
}
while (zoomFactor < 0) {
eventSender.zoomPageOut();
zoomFactor++;
}
}
function testScroll(zoomFactor, scaleFactor) {
debug('Testing at zoom ' + zoomFactor + ' and scale ' + scaleFactor);
if (window.testRunner && window.eventSender && window.internals) {
var y = 221;
internals.setPageScaleFactor(scaleFactor);
zoomBy(zoomFactor);
window.scrollTo(10, 10);
window.scrollBy(0, y);
shouldBeCloseTo('window.pageYOffset', y+10, 4, false);
zoomBy(-zoomFactor);
}
else
testFailed('This test only operates in DumpRenderTree.');
}
function runTests() {
if (window.internals)
internals.setPageScaleFactorLimits(0.5, 4);
testScroll(-1,1.2);
var zoomLevels = [-3, -2, -1, 0, 1, 3, 5];
var scaleLevels = [0.75, 1, 1.2, 1.6];
for (zoom in zoomLevels)
for (scale in scaleLevels)
testScroll(zoomLevels[zoom], scaleLevels[scale]);
wasPostTestScriptParsed = true;
finishJSTest();
}
</script>
</head>
<body onload="runTests()">
<div id="target"></div>
</body>
</html>