| OLD | NEW |
| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 assertTrue(commandItem[Command.OPEN_NEW_TAB].disabled); | 179 assertTrue(commandItem[Command.OPEN_NEW_TAB].disabled); |
| 180 assertFalse(commandItem[Command.OPEN_NEW_TAB].hidden); | 180 assertFalse(commandItem[Command.OPEN_NEW_TAB].hidden); |
| 181 | 181 |
| 182 assertTrue(commandItem[Command.OPEN_NEW_WINDOW].disabled); | 182 assertTrue(commandItem[Command.OPEN_NEW_WINDOW].disabled); |
| 183 assertFalse(commandItem[Command.OPEN_NEW_WINDOW].hidden); | 183 assertFalse(commandItem[Command.OPEN_NEW_WINDOW].hidden); |
| 184 | 184 |
| 185 assertTrue(commandItem[Command.OPEN_INCOGNITO].disabled); | 185 assertTrue(commandItem[Command.OPEN_INCOGNITO].disabled); |
| 186 assertFalse(commandItem[Command.OPEN_INCOGNITO].hidden); | 186 assertFalse(commandItem[Command.OPEN_INCOGNITO].hidden); |
| 187 }); | 187 }); |
| 188 |
| 189 test('ignores key events from outside the keyTarget', function() { |
| 190 store.data.selection.items = new Set(['12']); |
| 191 store.notifyObservers(); |
| 192 |
| 193 var section1 = document.createElement('section'); |
| 194 var subsection = document.createElement('div'); |
| 195 var section2 = document.createElement('section'); |
| 196 |
| 197 section1.appendChild(subsection); |
| 198 document.body.appendChild(section1); |
| 199 document.body.appendChild(section2); |
| 200 |
| 201 commandManager.keyTarget = section1; |
| 202 |
| 203 // Shortcuts are allowed from within the keyTarget. |
| 204 MockInteractions.pressAndReleaseKeyOn(subsection, 13, 'shift', 'Enter'); |
| 205 assertLastCommand(Command.OPEN_NEW_WINDOW); |
| 206 |
| 207 // Shortcuts are not allowed from outside the keyTarget. |
| 208 MockInteractions.pressAndReleaseKeyOn(section2, 13, 'shift', 'Enter'); |
| 209 assertLastCommand(null); |
| 210 |
| 211 // Shortcuts are always allowed on <body>. |
| 212 MockInteractions.pressAndReleaseKeyOn(document.body, 13, 'shift', 'Enter'); |
| 213 assertLastCommand(Command.OPEN_NEW_WINDOW); |
| 214 }); |
| 188 }); | 215 }); |
| 189 | 216 |
| 190 suite('<bookmarks-item> CommandManager integration', function() { | 217 suite('<bookmarks-item> CommandManager integration', function() { |
| 191 var list; | 218 var list; |
| 192 var items; | 219 var items; |
| 193 var commandManager; | 220 var commandManager; |
| 194 var openedTabs; | 221 var openedTabs; |
| 195 | 222 |
| 196 setup(function() { | 223 setup(function() { |
| 197 store = new bookmarks.TestStore({ | 224 store = new bookmarks.TestStore({ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 assertOpenedTabs(['http://111/', 'http://12/']); | 283 assertOpenedTabs(['http://111/', 'http://12/']); |
| 257 }); | 284 }); |
| 258 | 285 |
| 259 test('control-double click opens full selection', function() { | 286 test('control-double click opens full selection', function() { |
| 260 customClick(items[0]); | 287 customClick(items[0]); |
| 261 simulateDoubleClick(items[2], {ctrlKey: true}); | 288 simulateDoubleClick(items[2], {ctrlKey: true}); |
| 262 | 289 |
| 263 assertOpenedTabs(['http://111/', 'http://13/']); | 290 assertOpenedTabs(['http://111/', 'http://13/']); |
| 264 }); | 291 }); |
| 265 }); | 292 }); |
| OLD | NEW |