Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / arrow-keys-on-body.html
blobdab61a6e57e93378f20b116bcafbcc63e3134c37
1 <body
2 onkeypress="log(eventInfo(event))"
3 onkeydown="log(eventInfo(event))"
4 onkeyup="log(eventInfo(event))">
5 <p>Test that arrow keys do not dispatch keypress events even if there is no default handler.</p>
6 <p>To test manually, press arrow keys and verify that no keypress events are logged.</p>
7 <div id="log"></div>
9 <script>
10 function log(msg) {
11 document.getElementById("log").innerHTML+= msg + "<br />";
15 function locationName(code) {
16 switch (code) {
17 case 0:
18 return "DOM_KEY_LOCATION_STANDARD";
19 case 1:
20 return "DOM_KEY_LOCATION_LEFT";
21 case 2:
22 return "DOM_KEY_LOCATION_RIGHT";
23 case 3:
24 return "DOM_KEY_LOCATION_NUMPAD";
25 default:
26 return code.toString();
30 function eventInfo(event, where) {
31 try {
32 if (!event)
33 event = window.event;
34 target = event.srcElement ? event.srcElement : event.target;
35 if (event.type == "textInput")
36 return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type + " - " + event.data
37 + '. Value: "' + target.value + '".';
38 else if (event.type == "keydown" || event.type == "keypress" || event.type == "keyup")
39 return (where ? "(" + where + ") " : "") + target.tagName
40 + (target.tagName == "INPUT" ? " " + target.type : "")
41 + " - " + event.type
42 + ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
43 + ' - ' + event.keyIdentifier
44 + ' - ' + (event.location === undefined ? "undefined" : locationName(event.location))
45 + ' - ' + event.keyCode
46 + ' - ' + event.charCode;
48 } catch (ex) {
49 alert(ex);
52 log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
53 + ' - ' + "keyIdentifier"
54 + ' - ' + "location"
55 + ' - ' + "keyCode"
56 + ' - ' + "charCode");
58 if (window.testRunner) {
59 testRunner.dumpAsText();
60 eventSender.keyDown("leftArrow", []);
63 </script>
65 </body>