OLD | NEW |
| (Empty) |
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 testi
ng.</p> | |
4 <pre id="console"> | |
5 </pre> | |
6 <script> | |
7 | |
8 if (window.testRunner) | |
9 testRunner.dumpAsText(); | |
10 | |
11 var link = document.getElementById("link"); | |
12 link.focus(); | |
13 | |
14 var expectedCtrl; | |
15 var expectedAlt; | |
16 var expectedShift; | |
17 var expectedMeta; | |
18 | |
19 function test(ctrlKey, altKey, shiftKey, metaKey) | |
20 { | |
21 expectedCtrl = ctrlKey; | |
22 expectedAlt = altKey; | |
23 expectedShift = shiftKey; | |
24 expectedMeta = metaKey; | |
25 var event = new KeyboardEvent("keydown", {bubbles: true, cancelable: true, v
iew: document.defaultView, key: "Enter", ctrlKey: ctrlKey, altKey: altKey, shift
Key: shiftKey, metaKey: metaKey}); | |
26 link.dispatchEvent(event); | |
27 } | |
28 | |
29 function checkKeyState(event) | |
30 { | |
31 if (event.ctrlKey == expectedCtrl && event.altKey == expectedAlt && event.sh
iftKey == expectedShift && event.metaKey == expectedMeta) | |
32 document.getElementById("console").innerHTML += "PASS: " + event.type +
" event had all the right key state.\n"; | |
33 else | |
34 document.getElementById("console").innerHTML += "FAIL: " + event.type +
" event did not have the right key state.\n"; | |
35 } | |
36 | |
37 test(false, false, false, false); | |
38 test(true, false, false, false); | |
39 test(false, true, false, false); | |
40 test(false, false, true, false); | |
41 test(false, false, false, true); | |
42 test(true, true, true, true); | |
43 | |
44 link.blur(); | |
45 | |
46 </script> | |
OLD | NEW |