Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / mouseevent-getModifierState.html
blob01f45919561e0cf4ee15d6b3dfd16a949bf08a71
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 description("Tests MouseEvent.getModifierState()");
6 var lastMouseEvent;
8 function recordMouseEvent(ev) {
9 lastMouseEvent = 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"]);
35 } else {
36 debug("This test requires DumpRenderTree.");
38 </script>