1 <p>This tests that modifier keys are propagated to the fake mouse event created when you press return and a link has focus.</p>
2 <p>If the test succeeds, you should see six "PASS" messages below.</p>
3 <p>This is the <a id="link" href="#" onclick="checkKeyState(event)" onmousedown="checkKeyState(event)" onmouseuup="checkKeyState(event)">link</a> used for testing.</p>
8 if (window.layoutTestController)
9 layoutTestController.dumpAsText();
11 var link = document.getElementById("link");
19 function test(ctrlKey, altKey, shiftKey, metaKey)
21 expectedCtrl = ctrlKey;
23 expectedShift = shiftKey;
24 expectedMeta = metaKey;
25 var event = document.createEvent("KeyboardEvents");
26 event.initKeyboardEvent("keydown", true, true, document.defaultView, "Enter", 0, ctrlKey, altKey, shiftKey, metaKey, false);
27 link.dispatchEvent(event);
30 function checkKeyState(event)
32 if (event.ctrlKey == expectedCtrl && event.altKey == expectedAlt && event.shiftKey == expectedShift && event.metaKey == expectedMeta)
33 document.getElementById("console").innerHTML += "PASS: " + event.type + " event had all the right key state.\n";
35 document.getElementById("console").innerHTML += "FAIL: " + event.type + " event did not have the right key state.\n";
38 test(false, false, false, false);
39 test(true, false, false, false);
40 test(false, true, false, false);
41 test(false, false, true, false);
42 test(false, false, false, true);
43 test(true, true, true, true);