73 lines
2.2 KiB
HTML
73 lines
2.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
|
<html>
|
|
<head>
|
|
<script src="../../../resources/js-test-pre.js"></script>
|
|
<!--
|
|
Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchcancel callbacks
|
|
should be written in an asynchronous fashion so they can be run on mobile platforms like Android.
|
|
This template will generate an asynchronous style test by using the js-test-post-function script.
|
|
You will need to invoke isSuccessfullyParsed() in your test script when the test completes.
|
|
-->
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
<script>
|
|
var targetDiv = document.createElement("div");
|
|
targetDiv.id = "targetDiv";
|
|
targetDiv.setAttribute('style', "position: absolute; top: 100px; left: 10px; width: 400px; height: 400px; overflow: scroll;");
|
|
|
|
var innerDiv = document.createElement("div");
|
|
innerDiv.setAttribute('style', "width: 800px; height: 800px;");
|
|
|
|
targetDiv.appendChild(innerDiv);
|
|
|
|
document.body.insertBefore(targetDiv, document.getElementById('console'));
|
|
|
|
description("Tests that touch events cause an overflow:scroll div to scroll.");
|
|
|
|
function verifyScrollOffset(offsetX, offsetY)
|
|
{
|
|
shouldBe("targetDiv.scrollLeft", offsetX.toString());
|
|
shouldBe("targetDiv.scrollTop", offsetY.toString());
|
|
}
|
|
|
|
if (window.eventSender) {
|
|
verifyScrollOffset(0, 0);
|
|
|
|
// Test vertical up scroll.
|
|
eventSender.clearTouchPoints();
|
|
eventSender.addTouchPoint(20, 220);
|
|
eventSender.touchStart();
|
|
eventSender.updateTouchPoint(0, 20, 120);
|
|
eventSender.touchMove();
|
|
eventSender.touchEnd();
|
|
verifyScrollOffset(0, 100);
|
|
|
|
// Test vertical down scroll.
|
|
eventSender.clearTouchPoints();
|
|
eventSender.addTouchPoint(20, 120);
|
|
eventSender.touchStart();
|
|
eventSender.updateTouchPoint(0, 20, 170);
|
|
eventSender.touchMove();
|
|
eventSender.touchEnd();
|
|
verifyScrollOffset(0, 50);
|
|
|
|
// Test diagonal scroll
|
|
eventSender.clearTouchPoints();
|
|
eventSender.addTouchPoint(120, 120);
|
|
eventSender.touchStart();
|
|
eventSender.updateTouchPoint(0, 20, 20);
|
|
eventSender.touchMove();
|
|
eventSender.touchEnd();
|
|
|
|
verifyScrollOffset(100, 150);
|
|
|
|
} else
|
|
debug('This test requires DRT.');
|
|
|
|
var successfullyParsed = true;
|
|
</script>
|
|
</body>
|
|
</html>
|