blob: f77cfa3598fc1b80e3df172b5abb9163a029ab5e [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<input type="text" id="testInput">
<script>
description("Test the key attribute on KeyboardEvent.");
var expectedKey;
function testEvent(event)
{
keyboardEvent = event;
debug("* " + event.type);
shouldBeEqualToString("keyboardEvent.key", "" + expectedKey);
}
var input = document.getElementById("testInput");
input.onkeydown = testEvent;
input.onkeyup = testEvent;
input.focus();
function sendKeyAndTest(key, modifiers, expected)
{
debug("");
expectedKey = expected;
eventSender.keyDown(key, []);
}
sendKeyAndTest(" ", [], " ");
sendKeyAndTest("a", [], "a");
sendKeyAndTest("\x08", [], "Backspace");
sendKeyAndTest("\x1B", [], "Escape");
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("insert", [], "Insert");
sendKeyAndTest("delete", [], "Delete");
sendKeyAndTest("printScreen", [], "PrintScreen");
sendKeyAndTest("leftControl", ["ctrlKey"], "Control");
sendKeyAndTest("leftShift", ["shiftKey"], "Shift");
sendKeyAndTest("leftAlt", ["altKey"], "Alt");
sendKeyAndTest("rightControl", ["ctrlKey"], "Control");
sendKeyAndTest("rightShift", ["shiftKey"], "Shift");
sendKeyAndTest("rightAlt", ["altKey"], "Alt");
for (var i = 1; i <= 12; i++)
sendKeyAndTest("F" + i, [], "F" + i);
sendKeyAndTest("\n", [], "Enter");
sendKeyAndTest("A", [], "A");
sendKeyAndTest("a", ["ctrlKey"], "a");
sendKeyAndTest("a", ["metaKey"], "a");
sendKeyAndTest("1", ['altKey'], "1");
debug("");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>