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

Side by Side Diff: chrome/test/data/webui/md_bookmarks/command_manager_test.js

Issue 2939873004: MD Bookmarks: Fix issue where keyboard shortcuts could fire incorrectly (Closed)
Patch Set: Fix mac 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 suite('<bookmarks-command-manager>', function() { 5 suite('<bookmarks-command-manager>', function() {
6 var commandManager; 6 var commandManager;
7 var store; 7 var store;
8 var lastCommand; 8 var lastCommand;
9 var lastCommandIds; 9 var lastCommandIds;
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 store.notifyObservers(); 117 store.notifyObservers();
118 118
119 MockInteractions.pressAndReleaseKeyOn(document.body, keyCode, '', key); 119 MockInteractions.pressAndReleaseKeyOn(document.body, keyCode, '', key);
120 commandManager.assertLastCommand('edit', ['11']); 120 commandManager.assertLastCommand('edit', ['11']);
121 }); 121 });
122 122
123 test('undo and redo commands trigger', function() { 123 test('undo and redo commands trigger', function() {
124 var undoModifier = cr.isMac ? 'meta' : 'ctrl'; 124 var undoModifier = cr.isMac ? 'meta' : 'ctrl';
125 var undoKey = 'z'; 125 var undoKey = 'z';
126 var redoModifier = cr.isMac ? ['meta', 'shift'] : 'ctrl' 126 var redoModifier = cr.isMac ? ['meta', 'shift'] : 'ctrl'
127 var redoKey = cr.isMac ? 'z' : 'y'; 127 var redoKey = cr.isMac ? 'Z' : 'y';
128 128
129 MockInteractions.pressAndReleaseKeyOn( 129 MockInteractions.pressAndReleaseKeyOn(
130 document.body, '', undoModifier, undoKey); 130 document.body, '', undoModifier, undoKey);
131 commandManager.assertLastCommand('undo'); 131 commandManager.assertLastCommand('undo');
132 132
133 MockInteractions.pressAndReleaseKeyOn( 133 MockInteractions.pressAndReleaseKeyOn(
134 document.body, '', redoModifier, redoKey); 134 document.body, '', redoModifier, redoKey);
135 commandManager.assertLastCommand('redo'); 135 commandManager.assertLastCommand('redo');
136 }); 136 });
137 137
(...skipping 26 matching lines...) Expand all
164 chrome.windows.create = function(createConfig) { 164 chrome.windows.create = function(createConfig) {
165 lastCreate = createConfig; 165 lastCreate = createConfig;
166 }; 166 };
167 167
168 MockInteractions.pressAndReleaseKeyOn(document.body, 13, 'shift', 'Enter'); 168 MockInteractions.pressAndReleaseKeyOn(document.body, 13, 'shift', 'Enter');
169 commandManager.assertLastCommand(Command.OPEN_NEW_WINDOW, ['12', '13']); 169 commandManager.assertLastCommand(Command.OPEN_NEW_WINDOW, ['12', '13']);
170 assertDeepEquals(['http://121/', 'http://13/'], lastCreate.url); 170 assertDeepEquals(['http://121/', 'http://13/'], lastCreate.url);
171 assertFalse(lastCreate.incognito); 171 assertFalse(lastCreate.incognito);
172 }); 172 });
173 173
174 test('shift-enter does not trigger enter commands', function() {
175 // Enter by itself performs an edit (Mac) or open (non-Mac). Ensure that
176 // shift-enter doesn't trigger those commands.
177 store.data.selection.items = new Set(['13']);
178 store.notifyObservers();
179
180 MockInteractions.pressAndReleaseKeyOn(document.body, 13, 'shift', 'Enter');
181 commandManager.assertLastCommand(Command.OPEN_NEW_WINDOW);
182 });
183
174 test('cannot execute "Open in New Tab" on folders with no items', function() { 184 test('cannot execute "Open in New Tab" on folders with no items', function() {
175 var items = new Set(['2']); 185 var items = new Set(['2']);
176 assertFalse(commandManager.canExecute(Command.OPEN_NEW_TAB, items)); 186 assertFalse(commandManager.canExecute(Command.OPEN_NEW_TAB, items));
177 187
178 store.data.selection.items = items; 188 store.data.selection.items = items;
179 189
180 commandManager.openCommandMenuAtPosition(0, 0); 190 commandManager.openCommandMenuAtPosition(0, 0);
181 var commandItem = {}; 191 var commandItem = {};
182 commandManager.root.querySelectorAll('.dropdown-item').forEach(element => { 192 commandManager.root.querySelectorAll('.dropdown-item').forEach(element => {
183 commandItem[element.getAttribute('command')] = element; 193 commandItem[element.getAttribute('command')] = element;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 assertOpenedTabs(['http://111/', 'http://12/']); 306 assertOpenedTabs(['http://111/', 'http://12/']);
297 }); 307 });
298 308
299 test('control-double click opens full selection', function() { 309 test('control-double click opens full selection', function() {
300 customClick(items[0]); 310 customClick(items[0]);
301 simulateDoubleClick(items[2], {ctrlKey: true}); 311 simulateDoubleClick(items[2], {ctrlKey: true});
302 312
303 assertOpenedTabs(['http://111/', 'http://13/']); 313 assertOpenedTabs(['http://111/', 'http://13/']);
304 }); 314 });
305 }); 315 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698