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

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

Issue 2960143002: MD Bookmarks: Remove '/?id=1' from URL when displaying Bookmarks Bar (Closed)
Patch Set: Tweak logic to remove extra dispatch, add tests Created 3 years, 5 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);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 assertEquals('chrome://bookmarks/?q=bloop', window.location.href); 55 assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
56 56
57 // Ensure that the route doesn't change when the search finishes. 57 // Ensure that the route doesn't change when the search finishes.
58 store.data.selectedFolder = null; 58 store.data.selectedFolder = null;
59 store.notifyObservers(); 59 store.notifyObservers();
60 }) 60 })
61 .then(function() { 61 .then(function() {
62 assertEquals('chrome://bookmarks/?q=bloop', window.location.href); 62 assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
63 }); 63 });
64 }); 64 });
65
66 test('bookmarks bar selected with empty route', function() {
67 navigateTo('/?id=2');
68 navigateTo('/');
69 assertEquals('select-folder', store.lastAction.name);
70 assertEquals('1', store.lastAction.id);
71 });
72
73 test('selecting bookmarks bar clears route', function() {
74 store.data.selectedFolder = '2';
75 store.notifyObservers();
76
77 return Promise.resolve().then(function() {
78 store.data.selectedFolder = '1';
79 store.notifyObservers();
80 }).then(function() {
81 assertEquals('chrome://bookmarks/', window.location.href);
calamity 2017/07/05 04:04:39 Assert above this that the route was ?id=2 at some
tsergeant 2017/07/05 07:37:36 Done, by moving this extra check up into the test
82 });
83 });
65 }); 84 });
66 85
67 suite('URL preload', function() { 86 suite('URL preload', function() {
68 /** 87 /**
69 * Reset the page state with a <bookmarks-app> and a clean Store, with the 88 * Reset the page state with a <bookmarks-app> and a clean Store, with the
70 * given |url| to trigger routing initialization code. 89 * given |url| to trigger routing initialization code.
71 */ 90 */
72 function setupWithUrl(url) { 91 function setupWithUrl(url) {
73 PolymerTest.clearBody(); 92 PolymerTest.clearBody();
74 bookmarks.Store.instance_ = undefined; 93 bookmarks.Store.instance_ = undefined;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 var state = bookmarks.Store.getInstance().data; 132 var state = bookmarks.Store.getInstance().data;
114 assertEquals('2', state.selectedFolder); 133 assertEquals('2', state.selectedFolder);
115 assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state)); 134 assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state));
116 }); 135 });
117 136
118 test('loading an invalid folder URL selects the Bookmarks Bar', function() { 137 test('loading an invalid folder URL selects the Bookmarks Bar', function() {
119 setupWithUrl('/?id=42'); 138 setupWithUrl('/?id=42');
120 var state = bookmarks.Store.getInstance().data; 139 var state = bookmarks.Store.getInstance().data;
121 assertEquals('1', state.selectedFolder); 140 assertEquals('1', state.selectedFolder);
122 return Promise.resolve().then(function() { 141 return Promise.resolve().then(function() {
123 assertEquals('chrome://bookmarks/?id=1', window.location.href); 142 assertEquals('chrome://bookmarks/', window.location.href);
124 }); 143 });
125 }); 144 });
126 }); 145 });
OLDNEW
« chrome/browser/ui/chrome_pages.cc ('K') | « chrome/browser/ui/webui/bookmarks_ui_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698