<script src="../../../resources/js-test.js"></script>
<style>
#pusher {
width: 1000px;
height: 1000px;
outline: 1px solid black;
}
</style>
<div id="console"></div>
<div id="testArea">
<div id="pusher">This box is here to create scrollbars.</div>
</div>
<script>
var event;
var floatPrecision = 0.00001;
function sendTouchStart(x, y)
{
if (window.eventSender) {
eventSender.clearTouchPoints();
eventSender.addTouchPoint(x, y);
eventSender.touchStart();
}
}
function zoomPageIn()
{
if (window.testRunner) {
testRunner.zoomPageIn();
}
}
function zoomPageOut()
{
if (window.testRunner) {
testRunner.zoomPageOut();
}
}
function scrollPage(x, y)
{
window.scrollTo(x, y);
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
// Default.
function base(e)
{
event = e;
debug("Base");
shouldBe("event.touches[0].clientX", "100");
shouldBe("event.touches[0].clientY", "100");
shouldBe("event.touches[0].pageX", "100");
shouldBe("event.touches[0].pageY", "100");
}
window.addEventListener("touchstart", base, false);
sendTouchStart(100, 100);
window.removeEventListener("touchstart", base, false);
// Just zoomed.
function justZoomed(e)
{
event = e;
debug("\nJust zoomed");
shouldBeCloseTo("event.touches[0].clientX", 83.33333, floatPrecision);
shouldBeCloseTo("event.touches[0].clientY", 83.33333, floatPrecision);
shouldBeCloseTo("event.touches[0].pageX", 83.33333, floatPrecision);
shouldBeCloseTo("event.touches[0].pageY", 83.33333, floatPrecision);
}
window.addEventListener("touchstart", justZoomed, false);
zoomPageIn();
sendTouchStart(100, 100);
zoomPageOut();
window.removeEventListener("touchstart", justZoomed, false);
// Just scrolled.
function justScrolled(e)
{
event = e;
debug("\nJust scrolled");
shouldBe("event.touches[0].clientX", "100");
shouldBe("event.touches[0].clientY", "100");
shouldBe("event.touches[0].pageX", "150");
shouldBe("event.touches[0].pageY", "150");
}
window.addEventListener("touchstart", justScrolled, false);
scrollPage(50, 50);
sendTouchStart(100, 100);
scrollPage(0, 0);
window.removeEventListener("touchstart", justScrolled, false);
// Zoomed and scrolled.
function zoomedAndScrolled(e)
{
event = e;
debug("\nZoomed and scrolled");
shouldBeCloseTo("event.touches[0].clientX", 83.33333, floatPrecision);
shouldBeCloseTo("event.touches[0].clientY", 83.33333, floatPrecision);
shouldBeCloseTo("event.touches[0].pageX", 133.33333, floatPrecision);
shouldBeCloseTo("event.touches[0].pageY", 133.33333, floatPrecision);
}
window.addEventListener("touchstart", zoomedAndScrolled, false);
zoomPageIn();
scrollPage(50, 50);
sendTouchStart(100, 100);
zoomPageOut();
scrollPage(0, 0);
window.removeEventListener("touchstart", zoomedAndScrolled, false);
if (window.eventSender) {
eventSender.touchEnd();
eventSender.clearTouchPoints();
}
if (window.testRunner) {
var area = document.getElementById('testArea');
area.parentNode.removeChild(area);
isSuccessfullyParsed();
testRunner.notifyDone();
}
</script>