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

Unified Diff: chrome/test/data/webui/md_bookmarks/command_manager_test.js

Issue 2885353002: MD Bookmarks: Prevent keyboard shortcuts when the toolbar/dialogs are focused (Closed)
Patch Set: Created 3 years, 7 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/webui/md_bookmarks/command_manager_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/command_manager_test.js b/chrome/test/data/webui/md_bookmarks/command_manager_test.js
index d103eafa7ca76082ba8f01812bf5b21491f676fe..99a0e73fce83f203e80b1e608db5b56e74d14ba3 100644
--- a/chrome/test/data/webui/md_bookmarks/command_manager_test.js
+++ b/chrome/test/data/webui/md_bookmarks/command_manager_test.js
@@ -185,6 +185,33 @@ suite('<bookmarks-command-manager>', function() {
assertTrue(commandItem[Command.OPEN_INCOGNITO].disabled);
assertFalse(commandItem[Command.OPEN_INCOGNITO].hidden);
});
+
+ test('ignores key events from outside the keyTarget', function() {
+ store.data.selection.items = new Set(['12']);
+ store.notifyObservers();
+
+ var section1 = document.createElement('section');
+ var subsection = document.createElement('div');
+ var section2 = document.createElement('section');
+
+ section1.appendChild(subsection);
+ document.body.appendChild(section1);
+ document.body.appendChild(section2);
+
+ commandManager.keyTarget = section1;
+
+ // Shortcuts are allowed from within the keyTarget.
+ MockInteractions.pressAndReleaseKeyOn(subsection, 13, 'shift', 'Enter');
+ assertLastCommand(Command.OPEN_NEW_WINDOW);
+
+ // Shortcuts are not allowed from outside the keyTarget.
+ MockInteractions.pressAndReleaseKeyOn(section2, 13, 'shift', 'Enter');
+ assertLastCommand(null);
+
+ // Shortcuts are always allowed on <body>.
+ MockInteractions.pressAndReleaseKeyOn(document.body, 13, 'shift', 'Enter');
+ assertLastCommand(Command.OPEN_NEW_WINDOW);
+ });
});
suite('<bookmarks-item> CommandManager integration', function() {

Powered by Google App Engine
This is Rietveld 408576698