blob: 473adeea51e521d127c94aa287e71b71d55818f1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
<script src="resources/gesture-helpers.js"></script>
<style type="text/css">
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
#greenbox {
width: 100px;
height: 100px;
background: green;
padding: 0px;
margin: 0px;
}
#redbox {
width: 100px;
height: 100px;
background: red;
padding: 0px;
margin: 0px;
}
td {
padding: 0px;
}
</style>
</head>
<body style="margin:0" onload="runTest();">
<table id="table_to_fill">
<tr><td><div id="greenbox"></div></td></tr>
<tr><td><div id="redbox"></div></td></tr>
</table>
<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">
var expectedGesturesTotal = 2;
var gesturesOccurred = 0;
var scrollAmountX = ['0', '0'];
var scrollAmountY = ['70', '130'];
var wheelEventsOccurred = 0;
var expectedWheelEventsOccurred = ['0', '0'];
var scrollEventsOccurred = 0;
var scrolledElement = 'document.body'
var scrollEventsOccurred = 0;
var expectedScrollEventsOccurred = '1';
function recordScroll(event) {
debug('scroll event ' + scrollEventsOccurred + '+> ' + event.target);
scrollEventsOccurred++;
if (window.eventSender) {
// Because scroll events arrive asynchronously, only one will arrive.
if (gesturesOccurred == expectedGesturesTotal) {
shouldBe('scrollEventsOccurred', expectedScrollEventsOccurred);
// If we've got here, we've passed.
successfullyParsed = true;
isSuccessfullyParsed();
if (window.testRunner)
testRunner.notifyDone();
}
}
}
// Always construct a page larger than the vertical height of the window.
function buildPage()
{
var table = document.getElementById('table_to_fill');
var targetHeight = document.body.offsetHeight;
var cellPairHeight = table.offsetHeight;
var numberOfReps = targetHeight / cellPairHeight * 2;
var i;
for (i = 0; i < numberOfReps; i++) {
var p = document.createElement('tr');
p.innerHTML = '<td><div id="greenbox"></div></td>';
table.appendChild(p);
var p = document.createElement('tr');
p.innerHTML = '<td><div id="redbox"></div></td>';
table.appendChild(p);
}
window.addEventListener("scroll", recordScroll);
window.addEventListener("mousewheel", recordWheel);
}
function firstGestureScroll()
{
debug("first gesture");
eventSender.gestureScrollBegin(10, 72);
eventSender.gestureScrollUpdate(0, -30);
eventSender.gestureScrollUpdate(0, -40);
eventSender.gestureScrollEnd(0, 0);
// Wait for layout.
checkScrollOffset();
}
function secondGestureScroll()
{
debug("second gesture");
eventSender.gestureScrollBegin(800, 40);
eventSender.gestureScrollUpdate(0, -30);
eventSender.gestureScrollUpdate(0, -30);
eventSender.gestureScrollEnd(0, 0);
// Wait for layout.
checkScrollOffset();
}
if (window.testRunner)
testRunner.waitUntilDone();
function runTest()
{
buildPage();
if (window.eventSender) {
description('This tests scroll gesture event scrolling on a whole page.');
if (checkTestDependencies())
firstGestureScroll();
else
exitIfNecessary();
} else {
debug("This test requires DumpRenderTree. Gesture-scroll the page to validate the implementation.");
}
}
</script>
</body>
</html>