Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: LayoutTests/fast/events/mouseevent-getModifierState.html

Issue 1350933003: Implement MouseEvent.getModifierState (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add LayoutTests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/mouseevent-getModifierState.html
diff --git a/LayoutTests/fast/events/mouseevent-getModifierState.html b/LayoutTests/fast/events/mouseevent-getModifierState.html
new file mode 100644
index 0000000000000000000000000000000000000000..01f45919561e0cf4ee15d6b3dfd16a949bf08a71
--- /dev/null
+++ b/LayoutTests/fast/events/mouseevent-getModifierState.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<script src="../../resources/js-test.js"></script>
+<script>
+description("Tests MouseEvent.getModifierState()");
+
+var lastMouseEvent;
+
+function recordMouseEvent(ev) {
+ lastMouseEvent = ev;
+}
+
+var allEventModifiers = ["ctrlKey", "shiftKey", "metaKey", "altKey"];
+var allKeyModifiers = ["Control", "Shift", "Meta", "Alt"];
+
+function testMouseEventWithModifiers(button, eventModifiers) {
+ eventSender.mouseDown(button, eventModifiers);
+ shouldBe("lastMouseEvent.type", '"mousedown"');
+ shouldEvaluateTo("lastMouseEvent.button", button);
+ for (var i = 0; i < allEventModifiers.length; ++i) {
+ var expectedModifierState = eventModifiers.indexOf(allEventModifiers[i]) >= 0;
+ shouldEvaluateTo("lastMouseEvent.getModifierState('" + allKeyModifiers[i] + "')", expectedModifierState);
+ shouldEvaluateTo("lastMouseEvent." + allEventModifiers[i], expectedModifierState);
+ }
+}
+
+if (window.eventSender) {
+ document.addEventListener("mousedown", recordMouseEvent, false);
+ testMouseEventWithModifiers(0, ["ctrlKey"]);
+ testMouseEventWithModifiers(1, ["shiftKey"]);
+ testMouseEventWithModifiers(2, ["altKey"]);
+ testMouseEventWithModifiers(0, ["metaKey"]);
+ testMouseEventWithModifiers(1, ["ctrlKey", "shiftKey"]);
+ testMouseEventWithModifiers(2, ["ctrlKey", "shiftKey", "altKey"]);
+ testMouseEventWithModifiers(1, ["ctrlKey", "shiftKey", "altKey", "metaKey"]);
+} else {
+ debug("This test requires DumpRenderTree.");
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698