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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/simulated-key-state.html

Issue 2045603002: Handle the "key" field as opposed to keyIdentifier field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove initialization of the view Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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> 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> 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> 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"> 4 <pre id="console">
5 </pre> 5 </pre>
6 <script> 6 <script>
7 7
8 if (window.testRunner) 8 if (window.testRunner)
9 testRunner.dumpAsText(); 9 testRunner.dumpAsText();
10 10
11 var link = document.getElementById("link"); 11 var link = document.getElementById("link");
12 link.focus(); 12 link.focus();
13 13
14 var expectedCtrl; 14 var expectedCtrl;
15 var expectedAlt; 15 var expectedAlt;
16 var expectedShift; 16 var expectedShift;
17 var expectedMeta; 17 var expectedMeta;
18 18
19 function test(ctrlKey, altKey, shiftKey, metaKey) 19 function test(ctrlKey, altKey, shiftKey, metaKey)
20 { 20 {
21 expectedCtrl = ctrlKey; 21 expectedCtrl = ctrlKey;
22 expectedAlt = altKey; 22 expectedAlt = altKey;
23 expectedShift = shiftKey; 23 expectedShift = shiftKey;
24 expectedMeta = metaKey; 24 expectedMeta = metaKey;
25 var event = document.createEvent("KeyboardEvents"); 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 event.initKeyboardEvent("keydown", true, true, document.defaultView, "Enter" , 0, ctrlKey, altKey, shiftKey, metaKey, false);
27 link.dispatchEvent(event); 26 link.dispatchEvent(event);
28 } 27 }
29 28
30 function checkKeyState(event) 29 function checkKeyState(event)
31 { 30 {
32 if (event.ctrlKey == expectedCtrl && event.altKey == expectedAlt && event.sh iftKey == expectedShift && event.metaKey == expectedMeta) 31 if (event.ctrlKey == expectedCtrl && event.altKey == expectedAlt && event.sh iftKey == expectedShift && event.metaKey == expectedMeta)
33 document.getElementById("console").innerHTML += "PASS: " + event.type + " event had all the right key state.\n"; 32 document.getElementById("console").innerHTML += "PASS: " + event.type + " event had all the right key state.\n";
34 else 33 else
35 document.getElementById("console").innerHTML += "FAIL: " + event.type + " event did not have the right key state.\n"; 34 document.getElementById("console").innerHTML += "FAIL: " + event.type + " event did not have the right key state.\n";
36 } 35 }
37 36
38 test(false, false, false, false); 37 test(false, false, false, false);
39 test(true, false, false, false); 38 test(true, false, false, false);
40 test(false, true, false, false); 39 test(false, true, false, false);
41 test(false, false, true, false); 40 test(false, false, true, false);
42 test(false, false, false, true); 41 test(false, false, false, true);
43 test(true, true, true, true); 42 test(true, true, true, true);
44 43
45 link.blur(); 44 link.blur();
46 45
47 </script> 46 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698