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

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: Rebase & Implement deferred actions Created 3 years, 7 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 /** 68 /**
69 * Reset the page state with a <bookmarks-app> and a clean Store, with the 69 * Reset the page state with a <bookmarks-app> and a clean Store, with the
70 * given |url| to trigger routing initialization code. 70 * given |url| to trigger routing initialization code.
71 */ 71 */
72 function setupWithUrl(url) { 72 function setupWithUrl(url) {
73 PolymerTest.clearBody(); 73 PolymerTest.clearBody();
74 bookmarks.Store.instance_ = undefined; 74 bookmarks.Store.instance_ = undefined;
75 window.history.replaceState({}, '', url); 75 window.history.replaceState({}, '', url);
76 76
77 chrome.bookmarks.getTree = function(callback) { 77 chrome.bookmarks.getTree = function(callback) {
78 console.log('getTree');
79 console.log(window.location.href);
calamity 2017/05/02 08:27:15 rebase?
tsergeant 2017/05/03 02:57:31 I'm not sure exactly what you mean, but this was l
80 callback([ 78 callback([
81 createFolder( 79 createFolder(
82 '0', 80 '0',
83 [ 81 [
84 createFolder( 82 createFolder(
85 '1', 83 '1',
86 [ 84 [
87 createFolder('11', []), 85 createFolder('11', []),
88 ]), 86 ]),
89 createFolder( 87 createFolder(
(...skipping 19 matching lines...) Expand all
109 setupWithUrl('/?q=testQuery'); 107 setupWithUrl('/?q=testQuery');
110 assertEquals('testQuery', lastQuery); 108 assertEquals('testQuery', lastQuery);
111 }); 109 });
112 110
113 test('loading a folder URL selects that folder', function() { 111 test('loading a folder URL selects that folder', function() {
114 setupWithUrl('/?id=2'); 112 setupWithUrl('/?id=2');
115 var state = bookmarks.Store.getInstance().data; 113 var state = bookmarks.Store.getInstance().data;
116 assertEquals('2', state.selectedFolder); 114 assertEquals('2', state.selectedFolder);
117 assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state)); 115 assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state));
118 }); 116 });
117
118 test('loading an invalid folder URL selects the Bookmarks Bar', function() {
119 setupWithUrl('/?id=42');
120 var state = bookmarks.Store.getInstance().data;
121 assertEquals('1', state.selectedFolder);
122 return Promise.resolve().then(function() {
123 assertEquals('chrome://bookmarks/?id=1', window.location.href);
124 });
125 });
119 }); 126 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698