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

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

Issue 2077783002: Make limitations for input.ime.sendKeyEvents API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check lastError of sendKeyEvents. Created 4 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: chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js
diff --git a/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js b/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js
index d007bc68105ba5945bff9f498e52549d44355007..c8ac7b630b3b8643060d30fad792740be31ee9d2 100644
--- a/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js
+++ b/chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var failToSendKeyEvents = 'Could not send key events';
+
chrome.test.runTests([
function testActivate() {
var focused = false;
@@ -55,6 +57,7 @@ chrome.test.runTests([
},
function testSendKeyEvents() {
+ // Sends a normal character key.
chrome.input.ime.sendKeyEvents({
'contextID': 1,
'keyData': [{
@@ -68,6 +71,48 @@ chrome.test.runTests([
'key': 'a',
'code': 'KeyA'
}]
+ }, function() {
+ // Normal character key should be allowed to send on any page.
+ chrome.test.assertNoLastError();
+ });
+
+ // Sends Ctrl+A that should fail on special pages.
+ chrome.input.ime.sendKeyEvents({
+ 'contextID': 1,
+ 'keyData': [{
+ 'type': 'keydown',
+ 'requestId': '2',
+ 'key': 'a',
+ 'code': 'KeyA',
+ 'ctrlKey': true
+ }, {
+ 'type': 'keyup',
+ 'requestId': '3',
+ 'key': 'a',
+ 'code': 'KeyA',
+ 'ctrlKey': true
+ }]
+ }, function() {
+ if (chrome.runtime.lastError) {
+ chrome.test.assertEq(failToSendKeyEvents,
Devlin 2016/06/23 18:43:22 nit: indentation chrome.test.assertEq(failToSendKe
Azure Wei 2016/06/24 06:38:19 Done. Thanks for the comments.
+ chrome.runtime.lastError.message);
+ }
+ });
+
+ // Sends Tab key that should fail on special pages.
+ chrome.input.ime.sendKeyEvents({
+ 'contextID': 1,
+ 'keyData': [{
+ 'type': 'keydown',
+ 'requestId': '4',
+ 'key': '\u0009',
+ 'code': 'Tab'
+ }]
+ }, function() {
+ if (chrome.runtime.lastError) {
+ chrome.test.assertEq(failToSendKeyEvents,
+ chrome.runtime.lastError.message);
+ }
});
chrome.test.succeed();
}

Powered by Google App Engine
This is Rietveld 408576698