1 description("This tests what mouse events we send.");
3 var div = document.createElement("div");
4 div.style.width = "100px";
5 div.style.height = "100px";
6 div.style.backgroundColor = "blue";
10 function appendEventLog() {
11 if (window.eventSender) {
12 eventLog += event.type + "(" + event.button + ") ";
14 debug(event.type + "(" + event.button + ")");
18 function clearEventLog() {
22 div.addEventListener("click", appendEventLog, false);
23 div.addEventListener("dblclick", appendEventLog, false);
24 div.addEventListener("mousedown", appendEventLog, false);
25 div.addEventListener("mouseup", appendEventLog, false);
26 document.body.insertBefore(div, document.body.firstChild);
28 if (window.eventSender)
29 eventSender.mouseMoveTo(10, 10);
31 function sendEvents(button) {
32 if (!window.eventSender) {
33 debug("This test requires DumpRenderTree. Click on the blue rect with different mouse buttons to log.")
36 eventSender.mouseDown(button);
37 eventSender.mouseUp(button);
38 eventSender.mouseDown(button);
39 eventSender.mouseUp(button);
40 // could test dragging here too
43 function testEvents(description, button, expectedString) {
46 shouldBeEqualToString("eventLog", expectedString);
50 if (window.eventSender) {
51 testEvents("Left Mouse Button", 0, "mousedown(0) mouseup(0) click(0) mousedown(0) mouseup(0) click(0) dblclick(0) ");
52 testEvents("Middle Mouse Button", 1, "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) ");
53 testEvents("Right Mouse Button", 2, "mousedown(2) mouseup(2) mousedown(2) mouseup(2) ");
54 testEvents("4th Mouse Button", 3, "mousedown(1) mouseup(1) click(1) mousedown(1) mouseup(1) click(1) dblclick(1) ");