1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
2 <script src=
"../../resources/js-test.js"></script>
4 description("Tests MouseEvent.getModifierState()");
8 function recordMouseEvent(ev
) {
12 var allEventModifiers
= ["ctrlKey", "shiftKey", "metaKey", "altKey"];
13 var allKeyModifiers
= ["Control", "Shift", "Meta", "Alt"];
15 function testMouseEventWithModifiers(button
, eventModifiers
) {
16 eventSender
.mouseDown(button
, eventModifiers
);
17 shouldBe("lastMouseEvent.type", '"mousedown"');
18 shouldEvaluateTo("lastMouseEvent.button", button
);
19 for (var i
= 0; i
< allEventModifiers
.length
; ++i
) {
20 var expectedModifierState
= eventModifiers
.indexOf(allEventModifiers
[i
]) >= 0;
21 shouldEvaluateTo("lastMouseEvent.getModifierState('" + allKeyModifiers
[i
] + "')", expectedModifierState
);
22 shouldEvaluateTo("lastMouseEvent." + allEventModifiers
[i
], expectedModifierState
);
26 if (window
.eventSender
) {
27 document
.addEventListener("mousedown", recordMouseEvent
, false);
28 testMouseEventWithModifiers(0, ["ctrlKey"]);
29 testMouseEventWithModifiers(1, ["shiftKey"]);
30 testMouseEventWithModifiers(2, ["altKey"]);
31 testMouseEventWithModifiers(0, ["metaKey"]);
32 testMouseEventWithModifiers(1, ["ctrlKey", "shiftKey"]);
33 testMouseEventWithModifiers(2, ["ctrlKey", "shiftKey", "altKey"]);
34 testMouseEventWithModifiers(1, ["ctrlKey", "shiftKey", "altKey", "metaKey"]);
36 debug("This test requires DumpRenderTree.");