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

Side by Side Diff: chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js

Issue 1771173002: Implement input.ime.sendKeyEvents API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix patch conflict. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 chrome.test.runTests([ 5 chrome.test.runTests([
6 function testActivate() { 6 function testActivate() {
7 var focused = false; 7 var focused = false;
8 var activated = false; 8 var activated = false;
9 chrome.input.ime.onFocus.addListener(function(context) { 9 chrome.input.ime.onFocus.addListener(function(context) {
10 if (context.type == 'none') { 10 if (context.type == 'none') {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 chrome.test.assertNoLastError() 45 chrome.test.assertNoLastError()
46 chrome.test.assertTrue(!!win); 46 chrome.test.assertTrue(!!win);
47 chrome.test.assertTrue(win instanceof Window); 47 chrome.test.assertTrue(win instanceof Window);
48 chrome.test.assertFalse(win.document.webkitHidden); 48 chrome.test.assertFalse(win.document.webkitHidden);
49 // test for security origin. 49 // test for security origin.
50 // If security origin is not correctly set, there will be securtiy 50 // If security origin is not correctly set, there will be securtiy
51 // exceptions when accessing DOM or add event listeners. 51 // exceptions when accessing DOM or add event listeners.
52 win.addEventListener('unload', function() {}); 52 win.addEventListener('unload', function() {});
53 chrome.test.succeed(); 53 chrome.test.succeed();
54 }); 54 });
55 },
56
57 function testSendKeyEvent() {
58 var key_vent_count = 0;
Devlin 2016/03/10 23:21:14 nit: event, not vent nit: use js-style here (so ke
Azure Wei 2016/03/11 07:29:01 Done.
59
60 chrome.input.ime.onKeyEvent.addListener(function(engineID, keyData) {
Devlin 2016/03/10 23:21:14 Hmm... it's expected behavior to receive key event
Azure Wei 2016/03/11 07:29:01 Actually the extension won't handle the key events
61 if (key_vent_count == 0) {
62 chrome.test.assertEq(keyData.type, 'keydown');
63 }
64 else if (key_vent_count == 1) {
65 chrome.test.assertEq(keyData.type, 'keyup');
66 chrome.test.succeed();
67 }
68 chrome.test.assertEq(keyData.key, 'a');
69 chrome.test.assertEq(keyData.code, 'KeyA');
70 chrome.test.assertFalse(keyData.ctrlKey);
71 chrome.test.assertFalse(keyData.altKey);
72 chrome.test.assertFalse(keyData.shiftKey);
73 chrome.test.assertFalse(keyData.capsLock);
74 ++key_vent_count;
75 return false;
76 });
77
78 chrome.input.ime.sendKeyEvents({
79 'contextID': 1,
80 'keyData': [{
81 'type': 'keydown',
82 'requestId': '0',
83 'key': 'a',
84 'code': 'KeyA'
85 }, {
86 'type': 'keyup',
87 'requestId': '1',
88 'key': 'a',
89 'code': 'KeyA'
90 }]
91 });
55 } 92 }
56 ]); 93 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698