Commit 7a9ac631 authored by jamiewalch's avatar jamiewalch Committed by Commit bot

Remove the JS key log summary, since it's of limited value without the "code"...

Remove the JS key log summary, since it's of limited value without the "code" field. Also includes misc fixes for release.

* Change the title, since we're no longer just JS.
* Add a description for CWS.
* Update version number.

Review URL: https://codereview.chromium.org/910483002

Cr-Commit-Position: refs/heads/master@{#315427}
parent cfd26c4a
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
'tools/javascript_key_tester/background.js', 'tools/javascript_key_tester/background.js',
'tools/javascript_key_tester/chord_tracker.js', 'tools/javascript_key_tester/chord_tracker.js',
'tools/javascript_key_tester/event_listeners.js', 'tools/javascript_key_tester/event_listeners.js',
'tools/javascript_key_tester/keyboard_map.js',
'tools/javascript_key_tester/main.js', 'tools/javascript_key_tester/main.js',
], ],
}, },
......
...@@ -17,30 +17,26 @@ var ChordTracker = function(parentDiv) { ...@@ -17,30 +17,26 @@ var ChordTracker = function(parentDiv) {
}; };
/** /**
* @param {number|string} keyId Either a Javascript key-code, or a PNaCl "code" * @param {string} code The PNaCl "code" string.
* string.
* @param {string} title * @param {string} title
* @return {void} * @return {void}
*/ */
ChordTracker.prototype.addKeyUpEvent = function(keyId, title) { ChordTracker.prototype.addKeyUpEvent = function(code, title) {
var text = this.keyName_(keyId); var span = this.addSpanElement_('key-up', code, title);
var span = this.addSpanElement_('key-up', text, title); delete this.pressedKeys_[code];
delete this.pressedKeys_[keyId];
if (!this.keysPressed_()) { if (!this.keysPressed_()) {
this.end_(); this.end_();
} }
}; };
/** /**
* @param {number|string} keyId Either a Javascript key-code, or a PNaCl "code" * @param {string} code The PNaCl "code" string.
* string.
* @param {string} title * @param {string} title
* @return {void} * @return {void}
*/ */
ChordTracker.prototype.addKeyDownEvent = function(keyId, title) { ChordTracker.prototype.addKeyDownEvent = function(code, title) {
var text = this.keyName_(keyId); var span = this.addSpanElement_('key-down', code, title);
var span = this.addSpanElement_('key-down', text, title); this.pressedKeys_[code] = span;
this.pressedKeys_[keyId] = span;
}; };
/** /**
...@@ -118,20 +114,3 @@ ChordTracker.prototype.keysPressed_ = function() { ...@@ -118,20 +114,3 @@ ChordTracker.prototype.keysPressed_ = function() {
} }
return false; return false;
}; };
/**
* @param {number|string} keyId Either a Javascript key-code, or a PNaCl "code"
* string.
* @return {string} A human-readable representation of the key.
* @private
*/
ChordTracker.prototype.keyName_ = function(keyId) {
if (typeof keyId == 'string') {
return keyId;
}
var result = keyboardMap[keyId];
if (!result) {
result = '<' + keyId + '>';
}
return result;
};
...@@ -19,15 +19,13 @@ var PNaClEvent = function() { ...@@ -19,15 +19,13 @@ var PNaClEvent = function() {
/** /**
* @param {HTMLElement} jsLog
* @param {HTMLElement} pnaclLog * @param {HTMLElement} pnaclLog
* @param {HTMLElement} textLog * @param {HTMLElement} textLog
* @param {HTMLElement} pnaclPlugin * @param {HTMLElement} pnaclPlugin
* @param {HTMLElement} pnaclListener * @param {HTMLElement} pnaclListener
* @constructor * @constructor
*/ */
var EventListeners = function(jsLog, pnaclLog, textLog, var EventListeners = function(pnaclLog, textLog, pnaclPlugin, pnaclListener) {
pnaclPlugin, pnaclListener) {
this.pnaclPlugin_ = pnaclPlugin; this.pnaclPlugin_ = pnaclPlugin;
this.pnaclListener_ = pnaclListener; this.pnaclListener_ = pnaclListener;
this.textLog_ = textLog; this.textLog_ = textLog;
...@@ -39,7 +37,6 @@ var EventListeners = function(jsLog, pnaclLog, textLog, ...@@ -39,7 +37,6 @@ var EventListeners = function(jsLog, pnaclLog, textLog,
this.onPluginBlurHandler_ = this.onPluginBlur_.bind(this); this.onPluginBlurHandler_ = this.onPluginBlur_.bind(this);
this.onWindowBlurHandler_ = this.onWindowBlur_.bind(this); this.onWindowBlurHandler_ = this.onWindowBlur_.bind(this);
this.jsChordTracker_ = new ChordTracker(jsLog);
this.pnaclChordTracker_ = new ChordTracker(pnaclLog); this.pnaclChordTracker_ = new ChordTracker(pnaclLog);
this.startTime_ = new Date(); this.startTime_ = new Date();
...@@ -78,8 +75,6 @@ EventListeners.prototype.deactivate = function() { ...@@ -78,8 +75,6 @@ EventListeners.prototype.deactivate = function() {
*/ */
EventListeners.prototype.onKeyDown_ = function(event) { EventListeners.prototype.onKeyDown_ = function(event) {
this.appendToTextLog_(this.jsonifyJavascriptKeyEvent_(event, 'keydown')); this.appendToTextLog_(this.jsonifyJavascriptKeyEvent_(event, 'keydown'));
this.jsChordTracker_.addKeyDownEvent(
event.keyCode, this.jsonifyJavascriptKeyEvent_(event, 'keydown', 2));
}; };
/** /**
...@@ -88,8 +83,6 @@ EventListeners.prototype.onKeyDown_ = function(event) { ...@@ -88,8 +83,6 @@ EventListeners.prototype.onKeyDown_ = function(event) {
*/ */
EventListeners.prototype.onKeyUp_ = function(event) { EventListeners.prototype.onKeyUp_ = function(event) {
this.appendToTextLog_(this.jsonifyJavascriptKeyEvent_(event, 'keyup')); this.appendToTextLog_(this.jsonifyJavascriptKeyEvent_(event, 'keyup'));
this.jsChordTracker_.addKeyUpEvent(
event.keyCode, this.jsonifyJavascriptKeyEvent_(event, 'keyup', 2));
} }
/** /**
...@@ -98,9 +91,6 @@ EventListeners.prototype.onKeyUp_ = function(event) { ...@@ -98,9 +91,6 @@ EventListeners.prototype.onKeyUp_ = function(event) {
*/ */
EventListeners.prototype.onKeyPress_ = function(event) { EventListeners.prototype.onKeyPress_ = function(event) {
this.appendToTextLog_(this.jsonifyJavascriptKeyEvent_(event, 'keypress')); this.appendToTextLog_(this.jsonifyJavascriptKeyEvent_(event, 'keypress'));
this.jsChordTracker_.addCharEvent(
String.fromCharCode(event.keyCode),
this.jsonifyJavascriptKeyEvent_(event, 'keypress', 2));
} }
/** /**
...@@ -134,7 +124,6 @@ EventListeners.prototype.onPluginBlur_ = function() { ...@@ -134,7 +124,6 @@ EventListeners.prototype.onPluginBlur_ = function() {
* @return {void} * @return {void}
*/ */
EventListeners.prototype.onWindowBlur_ = function() { EventListeners.prototype.onWindowBlur_ = function() {
this.jsChordTracker_.releaseAllKeys();
this.pnaclChordTracker_.releaseAllKeys(); this.pnaclChordTracker_.releaseAllKeys();
}; };
...@@ -160,7 +149,7 @@ EventListeners.prototype.jsonifyJavascriptKeyEvent_ = ...@@ -160,7 +149,7 @@ EventListeners.prototype.jsonifyJavascriptKeyEvent_ =
return "JavaScript '" + eventName + "' event = " + JSON.stringify( return "JavaScript '" + eventName + "' event = " + JSON.stringify(
event, event,
['type', 'alt', 'shift', 'control', 'meta', 'charCode', 'keyCode', ['type', 'alt', 'shift', 'control', 'meta', 'charCode', 'keyCode',
'keyIdentifier', 'repeat'], 'keyIdentifier', 'repeat', 'code'],
opt_space); opt_space);
}; };
......
/* Copyright (c) 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/** @type {Array.<string>} */
var keyboardMap = [
'',
'',
'',
'Cancel',
'',
'',
'Help',
'',
'Backspace',
'Tab',
'',
'',
'Clear',
'Enter',
'Return',
'',
'Shift',
'Control',
'Alt',
'Pause',
'CapsLock',
'Kana',
'Eisu',
'Junja',
'Final',
'Hanja',
'',
'Escape',
'Convert',
'NonConvert',
'Accept',
'ModeChange',
'Space',
'PageUp',
'PageDown',
'End',
'Home',
'Left',
'Up',
'Right',
'Down',
'Selse',
'Print',
'Execute',
'PrtScn',
'Insert',
'Delete',
'',
'Digit0',
'Digit1',
'Digit2',
'Digit3',
'Digit4',
'Digit5',
'Digit6',
'Digit7',
'Digit8',
'Digit9',
'Colon',
'Semicolon',
'LessThan',
'Equals',
'GreaterThen',
'QuestionMark',
'At',
'KeyA',
'KeyB',
'KeyC',
'KeyD',
'KeyE',
'KeyF',
'KeyG',
'KeyH',
'KeyI',
'KeyJ',
'KeyK',
'KeyL',
'KeyM',
'KeyN',
'KeyO',
'KeyP',
'KeyQ',
'KeyR',
'KeyS',
'KeyT',
'KeyU',
'KeyV',
'KeyW',
'KeyX',
'KeyY',
'KeyZ',
'OSLeft',
'OSRight',
'ContextMenu',
'',
'Sleep',
'Numpad0',
'Numpad1',
'Numpad2',
'Numpad3',
'Numpad4',
'Numpad5',
'Numpad6',
'Numpad7',
'Numpad8',
'Numpad9',
'NumpadMultiply',
'NumpadAdd',
'Separator',
'NumpadSubtract',
'NumpadDecimal',
'NumpadDivide',
'F1',
'F2',
'F3',
'F4',
'F5',
'F6',
'F7',
'F8',
'F9',
'F10',
'F11',
'F12',
'F13',
'F14',
'F15',
'F16',
'F17',
'F18',
'F19',
'F20',
'F21',
'F22',
'F23',
'F24',
'',
'',
'',
'',
'',
'',
'',
'',
'NumLock',
'ScrollLock',
'WIN_OEM_FJ_JISHO',
'WIN_OEM_FJ_MASSHOU',
'WIN_OEM_FJ_TOUROKU',
'WIN_OEM_FJ_LOYA',
'WIN_OEM_FJ_ROYA',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'Circumflex',
'Exclamation',
'DoubleQuote',
'Hash',
'Dollar',
'Percent',
'Ampersand',
'Underscore',
'OpenParenthesis',
'CloseParenthesis',
'Asterisk',
'Plus',
'Pipe',
'HypenMinus',
'OpenBrace',
'CloseBrace',
'Tilde',
'',
'',
'',
'',
'VolumeMute',
'VolumeDown',
'VolumeUp',
'',
'',
'',
'Equal',
'Comma',
'Minus',
'Period',
'Slash',
'Backquote',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'OpenBracket',
'Backslash',
'CloseBracket',
'Quote',
'',
'Meta',
'AltGr',
'',
'WIN_ICO_HELP',
'WIN_ICO_00',
'',
'WIN_ICO_CLEAR',
'',
'',
'WIN_OEM_RESET',
'WIN_OEM_JUMP',
'WIN_OEM_PA1',
'WIN_OEM_PA2',
'WIN_OEM_PA3',
'WIN_OEM_WSCTRL',
'WIN_OEM_CUSEL',
'WIN_OEM_ATTN',
'WIN_OEM_FINISH',
'WIN_OEM_COPY',
'WIN_OEM_AUTO',
'WIN_OEM_ENLW',
'WIN_OEM_BACKTAB',
'ATTN',
'CRSEL',
'EXSEL',
'EREOF',
'PLAY',
'ZOOM',
'',
'PA1',
'WIN_OEM_CLEAR',
''
];
...@@ -13,10 +13,8 @@ html { ...@@ -13,10 +13,8 @@ html {
} }
.summary-log-container { .summary-log-container {
width: 50%;
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
float: left;
} }
#text-log-container { #text-log-container {
...@@ -35,6 +33,10 @@ html { ...@@ -35,6 +33,10 @@ html {
padding: 8px; padding: 8px;
} }
#pnacl-listener {
height: 0;
}
.selectable { .selectable {
-webkit-user-select: text; -webkit-user-select: text;
cursor: text; cursor: text;
......
...@@ -25,15 +25,7 @@ found in the LICENSE file. ...@@ -25,15 +25,7 @@ found in the LICENSE file.
src="remoting_key_tester.nmf" type="application/x-pnacl" /> src="remoting_key_tester.nmf" type="application/x-pnacl" />
</div> </div>
<div class="logs"> <div class="logs">
<div class="summary-log-container"> <div id="pnacl-log" class="summary-log-container">
Summary of JavaScript logs:
<div id="javascript-log">
</div>
</div>
<div class="summary-log-container">
Summary of PNaCl logs:
<div id="pnacl-log">
</div>
</div> </div>
<div id="text-log-container" hidden> <div id="text-log-container" hidden>
<div> <div>
......
...@@ -4,21 +4,19 @@ ...@@ -4,21 +4,19 @@
*/ */
function onLoad() { function onLoad() {
var jsLog = document.getElementById('javascript-log');
var pnaclLog = document.getElementById('pnacl-log'); var pnaclLog = document.getElementById('pnacl-log');
var pnaclPlugin = document.getElementById('pnacl-plugin'); var pnaclPlugin = document.getElementById('pnacl-plugin');
var pnaclListener = document.getElementById('pnacl-listener'); var pnaclListener = document.getElementById('pnacl-listener');
var textLog = document.getElementById('text-log'); var textLog = document.getElementById('text-log');
var textLogContainer = document.getElementById('text-log-container'); var textLogContainer = document.getElementById('text-log-container');
var eventListeners = new EventListeners(jsLog, pnaclLog, textLog, var eventListeners = new EventListeners(pnaclLog, textLog,
pnaclPlugin, pnaclListener); pnaclPlugin, pnaclListener);
eventListeners.activate(); eventListeners.activate();
document.getElementById('clear-log').addEventListener( document.getElementById('clear-log').addEventListener(
'click', 'click',
function() { function() {
jsLog.innerText = '';
pnaclLog.innerText = ''; pnaclLog.innerText = '';
textLog.innerText = ''; textLog.innerText = '';
}, },
......
{ {
"name": "Javascript key event tester", "name": "Chrome Key Event Tester",
"version": "1.1", "description": "Test press, release and character events for JavaScript and PPAPI.",
"version": "1.2",
"manifest_version": 2, "manifest_version": 2,
"icons": { "icons": {
"128": "icon_128.png" "128": "icon_128.png"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment