| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../../resources/js-test-pre.js"></script> |
| <input type="text" id="testInput"> |
| <script> |
| description("Test the code attribute on KeyboardEvent."); |
| |
| var expectedCode; |
| |
| function testEvent(event) |
| { |
| keyboardEvent = event; |
| debug("* " + event.type); |
| shouldBeEqualToString("keyboardEvent.code", "" + expectedCode); |
| } |
| |
| var input = document.getElementById("testInput"); |
| input.onkeydown = testEvent; |
| input.onkeyup = testEvent; |
| input.focus(); |
| |
| function sendKeyAndTest(key, modifiers, expected) |
| { |
| debug(""); |
| expectedCode = expected; |
| eventSender.keyDown(key, []); |
| } |
| |
| sendKeyAndTest(" ", [], "Space"); |
| sendKeyAndTest("a", [], "KeyA"); |
| sendKeyAndTest("\x08", [], "Backspace"); |
| sendKeyAndTest("\x1B", [], "Minus"); |
| sendKeyAndTest("leftArrow", [], "ArrowLeft"); |
| sendKeyAndTest("rightArrow", [], "ArrowRight"); |
| sendKeyAndTest("upArrow", [], "ArrowUp"); |
| sendKeyAndTest("downArrow", [], "ArrowDown"); |
| sendKeyAndTest("pageUp", [], "PageUp"); |
| sendKeyAndTest("pageDown", [], "PageDown"); |
| sendKeyAndTest("home", [], "Home"); |
| sendKeyAndTest("end", [], "End"); |
| sendKeyAndTest("delete", [], "Delete"); |
| sendKeyAndTest("leftControl", ["ctrlKey"], "ControlLeft"); |
| sendKeyAndTest("leftShift", ["shiftKey"], "ShiftLeft"); |
| sendKeyAndTest("leftAlt", ["altKey"], "AltLeft"); |
| sendKeyAndTest("rightControl", ["ctrlKey"], "ControlRight"); |
| sendKeyAndTest("rightShift", ["shiftKey"], "ShiftRight"); |
| sendKeyAndTest("rightAlt", ["altKey"], "AltRight"); |
| for (var i = 1; i <= 12; i++) |
| sendKeyAndTest("F" + i, [], "F" + i); |
| sendKeyAndTest("\n", [], "NumpadEnter"); |
| sendKeyAndTest("A", [], "KeyA"); |
| sendKeyAndTest("a", ["ctrlKey"], "KeyA"); |
| sendKeyAndTest("a", ["metaKey"], "KeyA"); |
| sendKeyAndTest("1", ['altKey'], "Digit1"); |
| |
| debug(""); |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |