blob: 37ba26f9f1955043f033cc7c3aae8c8c69358aa3 [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">
#touchtarget {
width: 100px;
height: 100px;
background: white;
overflow:scroll;
}
::-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; overflow-y:hidden;" onload="runTest();">
<div id="touchtarget">
<table border="0" cellspacing="0px" id="tablefoo">
<tr>
<td><div id="redbox"></div></td>
<td><div id="greenbox"></div></td>
</tr>
<tr>
<td><div id="greenbox"></div></td>
<td><div id="greenbox"></div></td>
</tr>
</table>
</div>
<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 = ['0', '0'];
var wheelEventsOccurred = 0;
var expectedWheelEventsOccurred = ['0', '0'];
var scrollEventsOccurred = 0;
var expectedScrollEventsOccurred = '0';
var scrolledElement = 'document.body'
// 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(95, 12);
eventSender.gestureScrollUpdate(0, -100);
eventSender.gestureScrollUpdate(0, -10);
eventSender.gestureScrollEnd(0, 0);
// Wait for layout.
checkScrollOffset();
}
function secondGestureScroll()
{
debug("second gesture");
eventSender.gestureScrollBegin(12, 97);
eventSender.gestureScrollUpdate(0, -95);
eventSender.gestureScrollUpdate(0, -200);
eventSender.gestureScrollEnd(0, 0);
// Wait for layout.
checkScrollOffset();
// In this test we do not expect any scroll events to
// be received by the event listener, so we signal
// the end of the test by calling this function instead
// of relying on recordScroll() to do it.
finishTest();
}
if (window.testRunner)
testRunner.waitUntilDone();
function runTest()
{
buildPage();
if (window.eventSender) {
description('This tests that a page cannot be scrolled vertically with touch if its body has style overflow-y:hidden ' +
'and the scroll event is propogated from a scrollable child div.');
if (checkTestDependencies())
firstGestureScroll();
else
exitIfNecessary();
} else {
debug("This test requires DumpRenderTree. Touch scroll the red rect to log.");
}
}
function finishTest()
{
if (window.eventSender) {
if (gesturesOccurred == expectedGesturesTotal) {
shouldBe('scrollEventsOccurred', expectedScrollEventsOccurred);
successfullyParsed = true;
isSuccessfullyParsed();
if (window.testRunner)
testRunner.notifyDone();
}
}
}
</script>
</body>
</html>