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

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

Issue 2813503002: MD Bookmarks: Prevent navigating to invalid folders (Closed)
Patch Set: Add positive test case Created 3 years, 8 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-router>', function() { 5 suite('<bookmarks-router>', function() {
6 var store; 6 var store;
7 var router; 7 var router;
8 8
9 function navigateTo(route) { 9 function navigateTo(route) {
10 window.history.replaceState({}, '', route); 10 window.history.replaceState({}, '', route);
11 window.dispatchEvent(new CustomEvent('location-changed')); 11 window.dispatchEvent(new CustomEvent('location-changed'));
12 } 12 }
13 13
14 setup(function() { 14 setup(function() {
15 store = new bookmarks.TestStore({ 15 store = new bookmarks.TestStore({
16 nodes: testTree(createFolder('1', [createFolder('2', [])])),
16 selectedId: '1', 17 selectedId: '1',
17 search: { 18 search: {
18 term: '', 19 term: '',
19 }, 20 },
20 }); 21 });
21 bookmarks.Store.instance_ = store; 22 bookmarks.Store.instance_ = store;
22 23
23 router = document.createElement('bookmarks-router'); 24 router = document.createElement('bookmarks-router');
24 replaceBody(router); 25 replaceBody(router);
25 }); 26 });
26 27
27 test('search updates from route', function() { 28 test('search updates from route', function() {
28 navigateTo('/?q=bleep'); 29 navigateTo('/?q=bleep');
29 assertEquals('start-search', store.lastAction.name); 30 assertEquals('start-search', store.lastAction.name);
30 assertEquals('bleep', store.lastAction.term); 31 assertEquals('bleep', store.lastAction.term);
31 }); 32 });
32 33
33 test('selected folder updates from route', function() { 34 test('selected folder updates from route', function() {
34 navigateTo('/?id=5'); 35 navigateTo('/?id=2');
35 assertEquals('select-folder', store.lastAction.name); 36 assertEquals('select-folder', store.lastAction.name);
36 assertEquals('5', store.lastAction.id); 37 assertEquals('2', store.lastAction.id);
37 }); 38 });
38 39
39 test('route updates from ID', function() { 40 test('route updates from ID', function() {
40 store.data.selectedFolder = '6'; 41 store.data.selectedFolder = '2';
41 store.notifyObservers(); 42 store.notifyObservers();
42 43
43 return Promise.resolve().then(function() { 44 return Promise.resolve().then(function() {
44 assertEquals('chrome://bookmarks/?id=6', window.location.href); 45 assertEquals('chrome://bookmarks/?id=2', window.location.href);
45 }); 46 });
46 }); 47 });
47 48
48 test('route updates from search', function() { 49 test('route updates from search', function() {
49 store.data.search = {term: 'bloop'}; 50 store.data.search = {term: 'bloop'};
50 store.notifyObservers(); 51 store.notifyObservers();
51 52
52 return Promise.resolve() 53 return Promise.resolve()
53 .then(function() { 54 .then(function() {
54 assertEquals('chrome://bookmarks/?q=bloop', window.location.href); 55 assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
(...skipping 16 matching lines...) Expand all
71 } 72 }
72 73
73 if (window.searchedQuery) { 74 if (window.searchedQuery) {
74 verifySearch(window.searchedQuery); 75 verifySearch(window.searchedQuery);
75 return; 76 return;
76 } 77 }
77 78
78 chrome.bookmarks.search = verifySearch; 79 chrome.bookmarks.search = verifySearch;
79 }); 80 });
80 }); 81 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698