blob: b0d05708b1fdfe3215a98cf538fd56ef7dee56ed [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
<style type="text/css">
#touchtarget {
width: 100px;
height: 100px;
background: blue;
}
</style>
</head>
<body onload="runTest();">
<div id="touchtarget">
<p id="description"></p>
<div id="console"></div>
<script>
var clickEventsReceived = 0;
var expectedMouseEvents = 4;
var mouseEventsReceived = 0;
var eventTypes = [ 'mousemove', 'mousedown', 'mouseup', 'click' ];
function gestureEventCallback(event)
{
if (window.eventSender) {
shouldBeEqualToString('event.type', eventTypes[mouseEventsReceived]);
shouldBe('event.clientX', '20');
shouldBe('event.clientY', '24');
shouldBe("event.shiftKey", "false");
shouldBe("event.altKey", "false");
shouldBe("event.ctrlKey", "false");
shouldBe("event.metaKey", "false");
mouseEventsReceived++;
} else {
debug(event.type);
debug(event.clientX);
debug(event.clientY);
}
}
// Because we may not have a gesture recognizer, we send a key press
// event to end the test without temporal flakiness.
function quitKeyToEndTest(event) {
endTest();
}
// Log that we still got the touch events.
function touchEventCallback(event) {
touchEventsReceived++;
debug('have received: ' + touchEventsReceived + ' touch events');
return true;
}
function endTest()
{
if (mouseEventsReceived < expectedMouseEvents) {
debug('Gesture manager not implemented on this platform.');
}
// Bail.
isSuccessfullyParsed();
testRunner.notifyDone();
}
function runTest() {
if (window.internals) {
window.internals.setPageScaleFactor(0.5, 0, 0);
}
var div = document.getElementById('touchtarget');
div.addEventListener("mousedown", gestureEventCallback, false);
div.addEventListener("click", gestureEventCallback, false);
div.addEventListener("mouseup", gestureEventCallback, false);
div.addEventListener("mousemove", gestureEventCallback, false);
document.addEventListener("keydown", quitKeyToEndTest, false);
if (window.testRunner)
testRunner.waitUntilDone();
if (window.eventSender) {
description("This tests basic single touch gesture generation.");
if (eventSender.clearTouchPoints) {
eventSender.gestureTap(10, 12);
eventSender.leapForward(10);
eventSender.keyDown(' ');
} else {
endTest();
}
} else {
debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
}
}
</script>
</body>
</html>