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

Unified Diff: chrome/browser/resources/md_bookmarks/actions.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/folder_node.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_bookmarks/actions.js
diff --git a/chrome/browser/resources/md_bookmarks/actions.js b/chrome/browser/resources/md_bookmarks/actions.js
index 9f6a63d11ab0d670608a17b3c0fae6f2cb4fba1a..8f52ef8a34b7481efa5b9ee1c0c622610d22ae43 100644
--- a/chrome/browser/resources/md_bookmarks/actions.js
+++ b/chrome/browser/resources/md_bookmarks/actions.js
@@ -97,10 +97,15 @@ cr.define('bookmarks.actions', function() {
/**
* @param {string} id
+ * @param {NodeList} nodes Current node state. Can be ommitted in tests.
calamity 2017/04/11 04:13:37 Doesn't omitting this always result in a no-op? Wh
tsergeant 2017/05/02 03:20:24 If nodes is falsey, the check for validity will be
* @return {!Action}
*/
- function selectFolder(id) {
- assert(id != '0', 'Cannot select root folder');
+ function selectFolder(id, nodes) {
+ if (nodes && (id == ROOT_NODE_ID || !nodes[id] || nodes[id].url)) {
+ return {
+ name: 'no-op',
+ };
calamity 2017/04/11 04:13:37 Make no-op a private action and early return in re
tsergeant 2017/05/02 03:20:24 I've replace 'no-op' with returning null, which do
+ }
return {
name: 'select-folder',
id: id,
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/folder_node.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698