Commit a4db0d64 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fixes sendSyntheticKeyEvent containing modifiers

Modifiers specified as:
{ ctrl: true }
worked, but
{ ctrl: false }

got interpreted as having ctrl down (as the code only checked the presence of the value and not its boolean state).

Change-Id: Icec8959441c193d548fcaf45b163c41fdb351472
Reviewed-on: https://chromium-review.googlesource.com/985967
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548106}
parent 3415bfc0
......@@ -234,13 +234,13 @@ AccessibilityPrivateSendSyntheticKeyEventFunction::Run() {
int modifiers = 0;
if (key_data->modifiers.get()) {
if (key_data->modifiers->ctrl)
if (key_data->modifiers->ctrl && *key_data->modifiers->ctrl)
modifiers |= ui::EF_CONTROL_DOWN;
if (key_data->modifiers->alt)
if (key_data->modifiers->alt && *key_data->modifiers->alt)
modifiers |= ui::EF_ALT_DOWN;
if (key_data->modifiers->search)
if (key_data->modifiers->search && *key_data->modifiers->search)
modifiers |= ui::EF_COMMAND_DOWN;
if (key_data->modifiers->shift)
if (key_data->modifiers->shift && *key_data->modifiers->shift)
modifiers |= ui::EF_SHIFT_DOWN;
}
......
// Copyright 2018 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.
#include "chrome/browser/chromeos/ash_config.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
namespace extensions {
using AccessibilityPrivateApiTest = ExtensionApiTest;
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(AccessibilityPrivateApiTest, SendSyntheticKeyEvent) {
// Not yet supported on mash.
if (chromeos::GetAshConfig() == ash::Config::MASH)
return;
ASSERT_TRUE(RunExtensionSubtest("accessibility_private/",
"send_synthetic_key_event.html"))
<< message_;
}
#endif // defined (OS_CHROMEOS)
} // namespace extensions
......@@ -1122,6 +1122,7 @@ test("browser_tests") {
if (enable_extensions) {
sources += [
"../browser/accessibility/accessibility_extension_api_browsertest.cc",
"../browser/apps/app_browsertest_util.cc",
"../browser/apps/app_browsertest_util.h",
"../browser/extensions/active_tab_apitest.cc",
......
{
"name": "A test extension for accessibilityPrivate API",
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEGBi/oD7Yl/Y16w3+gee/95/EUpRZ2U6c+8orV5ei+3CRsBsoXI/DPGBauZ3rWQ47aQnfoG00sXigFdJA2NhNK9OgmRA2evnsRRbjYm2BG1twpaLsgQPPus3PyczbDCvhFu8k24wzFyEtxLrfxAGBseBPb9QrCz7B4k2QgxD/CwIDAQAB",
"version": "0.0.1",
"manifest_version": 2,
"permissions": [
"accessibilityPrivate",
"tabs"
]
}
<!--
* Copyright 2018 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.
-->
<script src="send_synthetic_key_event.js"></script>
// Copyright 2018 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.
var allTests = [
function testSendModifiedKeyEvent() {
let tabCount = 0;
chrome.tabs.onCreated.addListener(function(tab) {
tabCount++;
if (tabCount == 2)
chrome.test.succeed();
});
chrome.accessibilityPrivate.sendSyntheticKeyEvent({
type: 'keydown',
keyCode: 84 /* T */,
modifiers: {
ctrl: true
}
});
chrome.accessibilityPrivate.sendSyntheticKeyEvent({
type: 'keydown',
keyCode: 84 /* T */,
modifiers: {
ctrl: true,
alt: false,
shift: false,
search: false
}
});
}
];
chrome.test.runTests(allTests);
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