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

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: Fix chromeos error. 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 29ba67700309872f09f0dcc2b868f3a0a47e5f1f..6f0b371a4bd39c2796d25394f8cc13846fca6281 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([
// Tests input.ime.activate and input.ime.onFocus APIs.
function testActivateAndFocus() {
@@ -55,25 +57,6 @@ chrome.test.runTests([
chrome.test.succeed();
});
},
- // Test input.ime.sendKeyEvents API.
- function testSendKeyEvents() {
- chrome.input.ime.sendKeyEvents({
- 'contextID': 1,
- 'keyData': [{
- 'type': 'keydown',
- 'requestId': '0',
- 'key': 'a',
- 'code': 'KeyA'
- }, {
- 'type': 'keyup',
- 'requestId': '1',
- 'key': 'a',
- 'code': 'KeyA'
- }]
- });
- chrome.test.succeed();
- },
- // Test input.ime.commitText API.
function testCommitText() {
chrome.input.ime.commitText({
contextID: 1,
@@ -100,17 +83,75 @@ chrome.test.runTests([
chrome.test.succeed();
});
},
+ // Test input.ime.sendKeyEvents API.
+ function testSendKeyEvents() {
+ // Sends a normal character key.
+ chrome.input.ime.sendKeyEvents({
+ contextID: 1,
+ keyData: [{
+ type: 'keydown',
+ requestId: '0',
+ key: 'a',
+ code: 'KeyA'
+ }, {
+ type: 'keyup',
+ requestId: '1',
+ 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,
+ 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', // Unicode value for Tab key.
+ code: 'Tab'
+ }]
+ }, function() {
+ if (chrome.runtime.lastError) {
+ chrome.test.assertEq(failToSendKeyEvents,
+ chrome.runtime.lastError.message);
+ }
+ });
+ chrome.test.succeed();
+ },
// Tests input.ime.onBlur API.
function testBlur() {
chrome.input.ime.onBlur.addListener(function(context) {
- if (context.type == 'none') {
- chrome.test.fail();
- return;
+ if (context.type != 'none') {
+ // Waits for the 'get_blur_event' message in
+ // InputImeApiTest.BasicApiTest.
+ chrome.test.sendMessage('get_blur_event');
}
- // Waits for the 'get_blur_event' message in InputImeApiTest.BasicApiTest.
- chrome.test.sendMessage('get_blur_event');
chrome.test.succeed();
});
chrome.test.succeed();
- },
+ }
]);
« no previous file with comments | « chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc ('k') | ui/base/ime/chromeos/mock_ime_input_context_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698