Index: LayoutTests/fast/events/keyboardevent-code.html |
diff --git a/LayoutTests/fast/events/keyboardevent-code.html b/LayoutTests/fast/events/keyboardevent-code.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..857b124086f0d028be11a8d629849ecacf61fbfc |
--- /dev/null |
+++ b/LayoutTests/fast/events/keyboardevent-code.html |
@@ -0,0 +1,116 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent-code" /> |
+<script src="../../resources/js-test.js"></script>- |
+</head> |
+<body> |
+<textarea id="textarea"></textarea> |
+<script> |
+description('Tests KeyboardEvent.code attribute'); |
+var textarea = document.getElementById('textarea'); |
+textarea.addEventListener('keydown', recordKeyEvent, false); |
+textarea.addEventListener('keyup', recordKeyEvent, false); |
+textarea.addEventListener('keypress', recordKeyEvent, false); |
+textarea.focus(); |
+ |
+var lastKeyboardEvent; |
+ |
+function recordKeyEvent(ev) { |
+ if (window.eventSender) |
+ lastKeyboardEvent = ev; |
+ else |
+ debug('Type=' + ev.type + ',' + 'code=' + ev.code + ','+ 'keycode=' + ev.keyCode); |
+} |
+ |
+if (window.eventSender) { |
+ debug('AlphaNumeric Keys'); |
+ eventSender.keyDown('A'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'KeyA\'') ; |
+ eventSender.keyDown('a'); // Small letters. |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'KeyA\'') ; |
+ eventSender.keyDown('M'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'KeyM\'') ; |
+ eventSender.keyDown('m'); // Small letters. |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'KeyM\''); |
+ eventSender.keyDown('Z'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'KeyZ\'') ; |
+ eventSender.keyDown('z'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'KeyZ\''); |
+ eventSender.keyDown('0'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Digit0\''); |
+ eventSender.keyDown('4'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Digit4\''); |
+ eventSender.keyDown('9'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Digit9\''); |
+ eventSender.keyDown('backspace'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Backspace\''); |
+ |
+ debug('Functional Keys'); |
+ eventSender.keyDown('leftControl'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ControlLeft\''); |
+ eventSender.keyDown('rightControl'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ControlRight\''); |
+ eventSender.keyDown('leftShift'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ShiftLeft\''); |
+ eventSender.keyDown('rightShift'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ShiftRight\''); |
+ eventSender.keyDown('leftAlt'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'AltLeft\''); |
+ eventSender.keyDown('rightAlt'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'AltRight\''); |
+ eventSender.keyDown('\n'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Enter\''); |
+ eventSender.keyDown('menu'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ContextMenu\''); |
+ eventSender.keyDown(' '); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Space\''); |
+ eventSender.keyDown('\t'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Tab\''); |
+ |
+ debug('Control Pad'); |
+ eventSender.keyDown('insert'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Insert\''); |
+ eventSender.keyDown('delete'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Delete\''); |
+ eventSender.keyDown('home'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Home\''); |
+ eventSender.keyDown('end'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'End\''); |
+ eventSender.keyDown('pageUp'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'PageUp\''); |
+ eventSender.keyDown('pageDown'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'PageDown\''); |
+ |
+ debug('Arrow Pad Section'); |
+ eventSender.keyDown('rightArrow'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ArrowRight\''); |
+ eventSender.keyDown('downArrow'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ArrowDown\''); |
+ eventSender.keyDown('leftArrow'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ArrowLeft\''); |
+ eventSender.keyDown('upArrow'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'ArrowUp\''); |
+ |
+ debug('Number Pad Section'); |
+ eventSender.keyDown('numLock'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'NumLock\''); |
+ eventSender.keyDown('numLock'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'NumLock\''); |
+ |
+ debug('Function Section'); |
+ eventSender.keyDown('escape'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'Escape\''); |
+ eventSender.keyDown('F1'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'F1\''); |
+ eventSender.keyDown('F6'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'F6\''); |
+ eventSender.keyDown('F12'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'F12\''); |
+ eventSender.keyDown('printScreen'); |
+ shouldEvaluateTo('lastKeyboardEvent.code', '\'PrintScreen\''); |
+} |
+ |
+</script> |
+</body> |
+</html> |