Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent.js

Issue 2961493002: [DevTools] Migrate inspector-protocol/{input,network} tests to new harness (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent.js b/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent.js
new file mode 100644
index 0000000000000000000000000000000000000000..f6e22e72e313d75521aed26d6f8ce3fdd26e40f3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent.js
@@ -0,0 +1,70 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startBlank(``);
allada 2017/06/26 22:02:53 let?
dgozman 2017/06/26 23:22:07 I will follow up with let->var in all tests.
+
+ await session.evaluate(`
+ window.addEventListener('keydown', logEvent);
+ window.addEventListener('keypress', logEvent);
+ window.addEventListener('keyup', logEvent);
+
+ window.logs = [];
allada 2017/06/26 22:02:53 In test mode maybe have a "log" function already s
dgozman 2017/06/26 23:22:07 I think this breaks the absolutely fresh context i
+ function log(text) {
+ logs.push(text);
+ }
+
+ function logEvent(event) {
+ log('-----Event-----');
+ log('type: ' + event.type);
+ if (event.altKey)
+ log('altKey');
+ if (event.ctrlKey)
+ log('ctrlKey');
+ if (event.metaKey)
+ log('metaKey');
+ if (event.shiftKey)
+ log('shiftKey');
+ if (event.keyCode)
+ log('keyCode: ' + event.keyCode);
+ if (event.key)
+ log('key: ' + event.key);
+ if (event.charCode)
+ log('charCode: ' + event.charCode);
+ if (event.text)
+ log('text: ' + event.text);
+ log('');
+ }
+ `);
+
+
+ var events = [
+ {
+ 'type': 'rawKeyDown',
+ 'windowsVirtualKeyCode': 65, // VK_A
+ 'key': 'A'
+ },
+ {
+ 'type': 'char',
+ 'modifiers': 8, // shift
+ 'text': 'A',
+ 'unmodifiedText': 'a'
+ },
+ {
+ 'type': 'keyUp',
+ 'windowsVirtualKeyCode': 65,
+ 'key': 'A'
+ },
+ {
+ 'type': 'char',
+ 'text': '\u05E9', // Hebrew Shin (sh)
+ 'unmodifiedText': '\u05E9'
+ }
+ ];
+
+ for (var event of events) {
+ var msg = await dp.Input.dispatchKeyEvent(event);
+ if (msg.error)
+ testRunner.log('Error: ' + msg.error.message);
+ }
+
+ testRunner.log(await session.evaluate(`window.logs.join('\\n')`));
+ testRunner.completeTest();
+})

Powered by Google App Engine
This is Rietveld 408576698