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

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

Issue 2885353002: MD Bookmarks: Prevent keyboard shortcuts when the toolbar/dialogs are focused (Closed)
Patch Set: Add a test Created 3 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/webui/md_bookmarks/md_bookmarks_focus_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js b/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js
index 27072b0c9b5056dbf9a4f137ebe821dc13d36eb4..e31a9201e7b6e220304b77b477ef572bab797885 100644
--- a/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js
+++ b/chrome/test/data/webui/md_bookmarks/md_bookmarks_focus_test.js
@@ -24,6 +24,7 @@ MaterialBookmarksFocusTest.prototype = {
[{switchName: 'enable-features', switchValue: 'MaterialDesignBookmarks'}],
extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
+ 'test_command_manager.js',
'test_store.js',
'test_util.js',
]),
@@ -178,6 +179,20 @@ TEST_F('MaterialBookmarksFocusTest', 'All', function() {
document.body.style.direction = 'ltr';
});
+
+ test('keyboard commands are passed to command manager', function() {
+ var commandManager = new TestCommandManager();
+ document.body.appendChild(commandManager);
+ chrome.bookmarkManagerPrivate.removeTrees = function() {}
+
+ store.data.selection.items = new Set(['3', '4']);
+ store.notifyObservers();
+
+ getFolderNode('1').$.container.focus();
+ keydown('1', 'delete');
+
+ commandManager.assertLastCommand(Command.DELETE, ['1']);
+ });
});
suite('<bookmarks-list>', function() {
@@ -344,6 +359,37 @@ TEST_F('MaterialBookmarksFocusTest', 'All', function() {
assertDeepEquals(
['2', '4', '5', '6'], normalizeSet(store.data.selection.items));
});
+
+ test('keyboard commands are passed to command manager', function() {
+ var commandManager = new TestCommandManager();
+ document.body.appendChild(commandManager);
+ chrome.bookmarkManagerPrivate.removeTrees = function() {}
+
+ store.data.selection.items = new Set(['2', '3']);
+ store.notifyObservers();
+
+ var focusedItem = items[4];
+ focusedItem.focus();
+
+ keydown(focusedItem, 'Delete');
+ // Commands should take affect on the selection, even if something else is
+ // focused.
+ commandManager.assertLastCommand(Command.DELETE, ['2', '3']);
+ });
+
+ test('iron-list does not steal focus on enter', function() {
+ // Iron-list attempts to focus the whole <bookmarks-item> when pressing
+ // enter on the menu button. This checks that we block this behavior
+ // during keydown on <bookmarks-list>.
+ var commandManager = new TestCommandManager();
+ document.body.appendChild(commandManager);
+
+ var button = items[0].$$('.more-vert-button');
+ button.focus();
+ keydown(button, 'Enter');
+
+ assertEquals(button, items[0].root.activeElement);
+ });
});
mocha.run();
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/command_manager_test.js ('k') | chrome/test/data/webui/md_bookmarks/toolbar_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698