| 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('Incognito policy', function() { | 5 suite('Bookmarks policies', function() { |
| 6 var store; | 6 var store; |
| 7 var app; | 7 var app; |
| 8 | 8 |
| 9 setup(function() { | 9 setup(function() { |
| 10 store = new bookmarks.TestStore({ | 10 store = new bookmarks.TestStore({ |
| 11 nodes: testTree(createFolder( | 11 nodes: testTree(createFolder( |
| 12 '1', | 12 '1', |
| 13 [ | 13 [ |
| 14 createItem('11'), | 14 createItem('11'), |
| 15 ])), | 15 ])), |
| 16 selectedFolder: '1', | 16 selectedFolder: '1', |
| 17 }); | 17 }); |
| 18 store.setReducersEnabled(true); | 18 store.setReducersEnabled(true); |
| 19 store.expectAction('set-incognito-availability'); | 19 store.expectAction('set-incognito-availability'); |
| 20 store.expectAction('set-can-edit'); |
| 20 store.replaceSingleton(); | 21 store.replaceSingleton(); |
| 21 | 22 |
| 22 app = document.createElement('bookmarks-app'); | 23 app = document.createElement('bookmarks-app'); |
| 23 replaceBody(app); | 24 replaceBody(app); |
| 24 }); | 25 }); |
| 25 | 26 |
| 26 test('updates when changed by the browser', function() { | 27 test('incognito availability updates when changed', function() { |
| 27 var commandManager = bookmarks.CommandManager.getInstance(); | 28 var commandManager = bookmarks.CommandManager.getInstance(); |
| 28 // Incognito is disabled during testGenPreamble(). Wait for the front-end to | 29 // Incognito is disabled during testGenPreamble(). Wait for the front-end to |
| 29 // load the config. | 30 // load the config. |
| 30 return store.waitForAction('set-incognito-availability').then(action => { | 31 return store.waitForAction('set-incognito-availability').then(action => { |
| 31 assertEquals(IncognitoAvailability.DISABLED, | 32 assertEquals(IncognitoAvailability.DISABLED, |
| 32 store.data.prefs.incognitoAvailability); | 33 store.data.prefs.incognitoAvailability); |
| 33 assertFalse( | 34 assertFalse( |
| 34 commandManager.canExecute(Command.OPEN_INCOGNITO, new Set(['11']))); | 35 commandManager.canExecute(Command.OPEN_INCOGNITO, new Set(['11']))); |
| 35 | 36 |
| 36 return cr.sendWithPromise( | 37 return cr.sendWithPromise( |
| 37 'testSetIncognito', IncognitoAvailability.ENABLED); | 38 'testSetIncognito', IncognitoAvailability.ENABLED); |
| 38 }).then(() => { | 39 }).then(() => { |
| 39 assertEquals(IncognitoAvailability.ENABLED, | 40 assertEquals(IncognitoAvailability.ENABLED, |
| 40 store.data.prefs.incognitoAvailability); | 41 store.data.prefs.incognitoAvailability); |
| 41 assertTrue( | 42 assertTrue( |
| 42 commandManager.canExecute(Command.OPEN_INCOGNITO, new Set(['11']))); | 43 commandManager.canExecute(Command.OPEN_INCOGNITO, new Set(['11']))); |
| 43 }); | 44 }); |
| 44 }); | 45 }); |
| 46 |
| 47 test('canEdit updates when changed', function() { |
| 48 var commandManager = bookmarks.CommandManager.getInstance(); |
| 49 return store.waitForAction('set-can-edit').then(action => { |
| 50 assertFalse(store.data.prefs.canEdit); |
| 51 assertFalse(commandManager.canExecute(Command.DELETE, new Set(['11']))); |
| 52 |
| 53 return cr.sendWithPromise('testSetCanEdit', true); |
| 54 }).then(() => { |
| 55 assertTrue(store.data.prefs.canEdit); |
| 56 assertTrue(commandManager.canExecute(Command.DELETE, new Set(['11']))); |
| 57 }); |
| 58 }); |
| 45 }); | 59 }); |
| OLD | NEW |