Chromium Code Reviews| 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..e1056db7f428927c83533cba6a9593a13946957c |
| --- /dev/null |
| +++ b/LayoutTests/fast/events/keyboardevent-code.html |
| @@ -0,0 +1,128 @@ |
| +<!DOCTYPE html> |
| +<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent-code" /> |
| +<script src="../../resources/js-test.js"></script>- |
| +<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 lastKeyboardDownEvent, lastKeyboardPressEvent, lastKeyboardUpEvent; |
| + |
| +function recordKeyEvent(ev) { |
| + if (window.eventSender) { |
| + if (ev.type === "keydown") |
| + lastKeyboardDownEvent = ev; |
| + else if (ev.type === "keyup") |
| + lastKeyboardUpEvent = ev; |
| + else if (ev.type === "keypress") |
| + lastKeyboardPressEvent = ev; |
|
Rick Byers
2015/01/23 20:38:30
nit: remove extra space
Habib Virji
2015/01/26 11:32:35
Done.
|
| + } else { |
| + debug('Type=' + ev.type + ',' + 'code=' + ev.code); |
| + } |
| +} |
| + |
| +if (window.eventSender) { |
| + debug('AlphaNumeric Keys'); |
| + eventSender.keyDown('A'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'KeyA\'') ; |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'KeyA\'') ; |
| + shouldEvaluateTo('lastKeyboardPressEvent.code', '\'KeyA\'') ; |
| + eventSender.keyDown('a'); // Small letters. |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'KeyA\'') ; |
| + eventSender.keyDown('M'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'KeyM\'') ; |
| + eventSender.keyDown('m'); // Small letters. |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'KeyM\''); |
| + eventSender.keyDown('Z'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'KeyZ\'') ; |
| + eventSender.keyDown('z'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'KeyZ\''); |
| + eventSender.keyDown('0'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Digit0\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'Digit0\''); |
| + shouldEvaluateTo('lastKeyboardPressEvent.code', '\'Digit0\''); |
| + eventSender.keyDown('4'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Digit4\''); |
| + eventSender.keyDown('9'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Digit9\''); |
| + eventSender.keyDown('backspace'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Backspace\''); |
| + |
| + debug('Functional Keys'); |
| + eventSender.keyDown('leftControl'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ControlLeft\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'ControlLeft\''); |
| + eventSender.keyDown('rightControl'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ControlRight\''); |
| + eventSender.keyDown('leftShift'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ShiftLeft\''); |
| + eventSender.keyDown('rightShift'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ShiftRight\''); |
| + eventSender.keyDown('leftAlt'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'AltLeft\''); |
| + eventSender.keyDown('rightAlt'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'AltRight\''); |
| + eventSender.keyDown('\n'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Enter\''); |
| + eventSender.keyDown('menu'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ContextMenu\''); |
| + eventSender.keyDown(' '); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Space\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'Space\''); |
| + shouldEvaluateTo('lastKeyboardPressEvent.code', '\'Space\''); |
| + eventSender.keyDown('\t'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Tab\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'Tab\''); |
| + |
| + debug('Control Pad'); |
| + eventSender.keyDown('insert'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Insert\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'Insert\''); |
| + eventSender.keyDown('delete'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Delete\''); |
| + eventSender.keyDown('home'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Home\''); |
| + eventSender.keyDown('end'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'End\''); |
| + eventSender.keyDown('pageUp'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'PageUp\''); |
| + eventSender.keyDown('pageDown'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'PageDown\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'PageDown\''); |
| + |
| + debug('Arrow Pad Section'); |
| + eventSender.keyDown('rightArrow'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ArrowRight\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'ArrowRight\''); |
| + eventSender.keyDown('downArrow'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ArrowDown\''); |
| + eventSender.keyDown('leftArrow'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ArrowLeft\''); |
| + eventSender.keyDown('upArrow'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'ArrowUp\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'ArrowUp\''); |
| + |
| + debug('Number Pad Section'); |
| + eventSender.keyDown('numLock'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'NumLock\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'NumLock\''); |
| + |
| + debug('Function Section'); |
| + eventSender.keyDown('escape'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'Escape\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'Escape\''); |
| + eventSender.keyDown('F1'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'F1\''); |
| + eventSender.keyDown('F6'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'F6\''); |
| + eventSender.keyDown('F12'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'F12\''); |
| + eventSender.keyDown('printScreen'); |
| + shouldEvaluateTo('lastKeyboardDownEvent.code', '\'PrintScreen\''); |
| + shouldEvaluateTo('lastKeyboardUpEvent.code', '\'PrintScreen\''); |
| +} |
| +</script> |