Commit 969db5bf authored by dpapad's avatar dpapad Committed by Commit Bot

Extensions: Restore focus after clearing keyboard shortcut.

Fixed: 1065659
Change-Id: I39f314af200c8256eb31a6ffe20b7210dd9ac5a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392997
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806929}
parent 1cb4c9a7
...@@ -32,6 +32,6 @@ ...@@ -32,6 +32,6 @@
slot="suffix" class="icon-cancel no-overlap" slot="suffix" class="icon-cancel no-overlap"
invisible$="[[computeClearInvisible_(capturing_, shortcut)]]" invisible$="[[computeClearInvisible_(capturing_, shortcut)]]"
hidden$="[[computeClearHidden_(shortcut)]]" hidden$="[[computeClearHidden_(shortcut)]]"
on-click="onClearTap_"></cr-icon-button> on-click="onClearClick_"></cr-icon-button>
</cr-input> </cr-input>
</div> </div>
...@@ -96,8 +96,7 @@ Polymer({ ...@@ -96,8 +96,7 @@ Polymer({
} }
this.pendingShortcut_ = ''; this.pendingShortcut_ = '';
this.capturing_ = false; this.capturing_ = false;
const input = this.$.input; this.$.input.blur();
input.blur();
this.error_ = ShortcutError.NO_ERROR; this.error_ = ShortcutError.NO_ERROR;
this.delegate.setShortcutHandlingSuspended(false); this.delegate.setShortcutHandlingSuspended(false);
}, },
...@@ -261,11 +260,12 @@ Polymer({ ...@@ -261,11 +260,12 @@ Polymer({
}, },
/** @private */ /** @private */
onClearTap_() { onClearClick_() {
assert(this.shortcut); assert(this.shortcut);
this.pendingShortcut_ = ''; this.pendingShortcut_ = '';
this.commitPending_(); this.commitPending_();
this.endCapture_(); this.endCapture_();
this.$.input.focus();
}, },
}); });
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
import 'chrome://extensions/extensions.js'; import 'chrome://extensions/extensions.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {keyDownOn, keyUpOn, tap} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; import {keyDownOn, keyUpOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {isChildVisible} from '../test_util.m.js'; import {isChildVisible} from '../test_util.m.js';
...@@ -45,8 +45,8 @@ suite(extension_shortcut_input_tests.suiteName, function() { ...@@ -45,8 +45,8 @@ suite(extension_shortcut_input_tests.suiteName, function() {
const isClearVisible = isChildVisible.bind(null, input, '#clear', false); const isClearVisible = isChildVisible.bind(null, input, '#clear', false);
expectFalse(isClearVisible()); expectFalse(isClearVisible());
// Click the input. Capture should start. // Focus the input. Capture should start.
tap(field); field.focus();
return input.delegate.whenCalled('setShortcutHandlingSuspended') return input.delegate.whenCalled('setShortcutHandlingSuspended')
.then((arg) => { .then((arg) => {
assertTrue(arg); assertTrue(arg);
...@@ -96,16 +96,18 @@ suite(extension_shortcut_input_tests.suiteName, function() { ...@@ -96,16 +96,18 @@ suite(extension_shortcut_input_tests.suiteName, function() {
expectTrue(isClearVisible()); expectTrue(isClearVisible());
// Test clearing the shortcut. // Test clearing the shortcut.
tap(input.$['clear']); input.$['clear'].click();
assertEquals(input.$.input, input.shadowRoot.activeElement);
return input.delegate.whenCalled('updateExtensionCommandKeybinding'); return input.delegate.whenCalled('updateExtensionCommandKeybinding');
}) })
.then((arg) => { .then((arg) => {
field.blur();
input.delegate.reset(); input.delegate.reset();
expectDeepEquals(['itemid', 'Command', ''], arg); expectDeepEquals(['itemid', 'Command', ''], arg);
assertEquals('', input.shortcut); assertEquals('', input.shortcut);
expectFalse(isClearVisible()); expectFalse(isClearVisible());
tap(field); field.focus();
return input.delegate.whenCalled('setShortcutHandlingSuspended'); return input.delegate.whenCalled('setShortcutHandlingSuspended');
}) })
.then((arg) => { .then((arg) => {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
-BrowserViewTest.GetAccessibleTabModalDialogTitle -BrowserViewTest.GetAccessibleTabModalDialogTitle
-ChromeSitePerProcessTest.PopupWindowFocus -ChromeSitePerProcessTest.PopupWindowFocus
-ClipboardApiTest.Extension -ClipboardApiTest.Extension
-CrExtensionsShortcutInputTest.Basic
-DesktopCaptureApiTest.ChooseDesktopMedia -DesktopCaptureApiTest.ChooseDesktopMedia
-ExtensionDialogTest.TextInputViaKeyEvent -ExtensionDialogTest.TextInputViaKeyEvent
-ExternalProtocolDialogBrowserTest.TestFocus -ExternalProtocolDialogBrowserTest.TestFocus
......
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