blob: 2dd1ab5668a65762e6b067e5869c5e091e5da829 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<style>
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
#bluebox {
width: 100px;
height: 100px;
background: blue;
padding: 0px;
margin: 0px;
}
#redbox {
width: 100px;
height: 100px;
background: red;
padding: 0px;
margin: 0px;
}
</style>
<script>
var floatPrecision = 0.1;
var scrollDistance = 10;
var expectedScrollDistance;
var scrollBox;
var integerScrollOffset = true;
function scroll(scaleFactor) {
if (integerScrollOffset)
expectedScrollDistance = Math.floor(scrollDistance/scaleFactor);
else
expectedScrollDistance = scrollDistance/scaleFactor;
scrollBox.scrollTop = 0;
eventSender.gestureScrollBegin(10, 100);
for(var i = 0; i < scrollDistance; ++i) {
eventSender.gestureScrollUpdate(0, -1);
}
eventSender.gestureScrollEnd(0, 0);
shouldBeCloseTo('scrollBox.scrollTop', expectedScrollDistance, floatPrecision);
scrollBox.scrollTop = 20;
eventSender.gestureScrollBegin(10, 300);
for(var i = 0; i < scrollDistance; ++i) {
eventSender.gestureScrollUpdate(0, 1);
}
eventSender.gestureScrollEnd(0, 0);
if (integerScrollOffset)
expectedScrollDistance = Math.floor(20 - scrollDistance/scaleFactor);
else
expectedScrollDistance = 20 - scrollDistance/scaleFactor;
shouldBeCloseTo('scrollBox.scrollTop', expectedScrollDistance, floatPrecision);
}
function scaleWithEventSender(scaleFactor) {
if (window.internals) {
internals.setPageScaleFactor(scaleFactor);
}
}
function test() {
scrollBox = document.getElementById("scrollbox");
debug('Scrolling unscaled div');
scaleWithEventSender(1.0);
scroll(1.0);
debug('Scrolling 1.5 scaled div');
scaleWithEventSender(1.5);
scroll(1.5);
debug('Scrolling 1.63 scaled div');
scaleWithEventSender(1.63);
scroll(1.63);
debug('Scrolling 2.0 scaled div');
scaleWithEventSender(2.0);
scroll(2.0);
}
function run_test() {
if (window.eventSender && window.internals) {
description('This tests that a div scrolled by gesture touch while the page is scaled still scrolls at the rate of the touch');
if (internals.runtimeFlags.fractionalScrollOffsetsEnabled) {
internals.settings.setPreferCompositingToLCDTextEnabled(true);
integerScrollOffset = false;
}
test();
} else {
debug('eventSender not detected. Not running test.');
}
}
</script>
<script src="../../resources/js-test.js"></script>
</head>
<body onload="run_test();">
<div id="scrollbox" style="left:0; top:0; width:500px; height:500px; position:absolute; overflow-y: scroll; overflow-x: scroll;">
<div id="bluebox"></div>
<div id="redbox"></div>
<div id="bluebox"></div>
<div id="redbox"></div>
<div id="bluebox"></div>
<div id="redbox"></div>
<div id="bluebox"></div>
<div id="redbox"></div>
<div id="bluebox"></div>
<div id="redbox"></div>
<div id="bluebox"></div>
<div id="redbox"></div>
</div>
<div id="console"></div>
</body>
</html>