blob: 4e8b0ba556379acb680381c6d0977a3839e79862 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
</head>
<body onload="runTest();">
<div id="gesture">
<p id="description"></p>
<div id="console"></div>
<script>
var mouseEventsReceived = 0;
var expectedEvents = [
{ type: 'mousemove', detail: 0 },
{ type: 'mousedown', detail: 1 },
{ type: 'mouseup', detail: 1 },
{ type: 'click', detail: 1 },
];
function gestureEventCallback(event)
{
if (window.eventSender) {
shouldBeEqualToString('event.type', expectedEvents[mouseEventsReceived].type);
shouldBe('event.clientX', '10');
shouldBe('event.clientY', '12');
shouldEvaluateTo('event.detail', expectedEvents[mouseEventsReceived].detail);
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();
}
function endTest()
{
if (mouseEventsReceived < expectedEvents.length) {
debug('Gesture manager not implemented on this platform.');
}
// Bail.
isSuccessfullyParsed();
testRunner.notifyDone();
}
function runTest() {
var div = document.getElementById('gesture');
div.addEventListener("mousedown", gestureEventCallback, false);
div.addEventListener("click", gestureEventCallback, false);
div.addEventListener("dblclick", gestureEventCallback, false);
div.addEventListener("mouseup", gestureEventCallback, false);
div.addEventListener("mousemove", gestureEventCallback, false);
document.addEventListener("keydown", quitKeyToEndTest, false);
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
if (window.eventSender) {
description("This tests basic gesture callbacks.");
// A 'tap' gesture event should generate a sequence of mouse events.
eventSender.gestureTap(10, 12);
eventSender.leapForward(10);
eventSender.keyDown(' ');
} else {
debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
}
}
</script>
</body>
</html>