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

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

Issue 2820153003: [MD Bookmarks] Add keyboard navigation to sidebar. (Closed)
Patch Set: address comments 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
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/test_store.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * Replace the current body of the test with a new element. 6 * Replace the current body of the test with a new element.
7 * @param {Element} element 7 * @param {Element} element
8 */ 8 */
9 function replaceBody(element) { 9 function replaceBody(element) {
10 PolymerTest.clearBody(); 10 PolymerTest.clearBody();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 /** 53 /**
54 * Splices out the item/folder at |index| and adjusts the indices of all the 54 * Splices out the item/folder at |index| and adjusts the indices of all the
55 * items after that. 55 * items after that.
56 * @param {BookmarkTreeNode} tree 56 * @param {BookmarkTreeNode} tree
57 * @param {Number} index 57 * @param {Number} index
58 */ 58 */
59 function removeChild(tree, index) { 59 function removeChild(tree, index) {
60 tree.children.splice(index, 1); 60 tree.children.splice(index, 1);
61 for (var i = index; i < tree.children.length; i++) { 61 for (var i = index; i < tree.children.length; i++)
62 tree.children[i].index = i; 62 tree.children[i].index = i;
63 }
64 } 63 }
65 64
66 /** 65 /**
67 * Creates a bookmark with given properties. 66 * Creates a bookmark with given properties.
68 * @param {string} id 67 * @param {string} id
69 * @param {Object=} config 68 * @param {Object=} config
70 * @return {BookmarkTreeNode} 69 * @return {BookmarkTreeNode}
71 */ 70 */
72 function createItem(id, config) { 71 function createItem(id, config) {
73 var newItem = { 72 var newItem = {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 106
108 if (config) { 107 if (config) {
109 for (var key in config) 108 for (var key in config)
110 props[key] = config[key]; 109 props[key] = config[key];
111 } 110 }
112 111
113 element.dispatchEvent(new MouseEvent('mousedown', props)); 112 element.dispatchEvent(new MouseEvent('mousedown', props));
114 element.dispatchEvent(new MouseEvent('mouseup', props)); 113 element.dispatchEvent(new MouseEvent('mouseup', props));
115 element.dispatchEvent(new MouseEvent('click', props)); 114 element.dispatchEvent(new MouseEvent('click', props));
116 } 115 }
116
117 /**
118 * Returns a folder node beneath |rootNode| which matches |id|.
119 * @param {BookmarksFolderNodeElement} rootNode
120 * @param {string} id
121 * @return {BookmarksFolderNodeElement}
122 */
123 function findFolderNode(rootNode, id) {
124 var nodes = [rootNode];
125 var node;
126 while (nodes.length) {
127 node = nodes.pop();
128 if (node.itemId == id)
129 return node;
130
131 node.root.querySelectorAll('bookmarks-folder-node')
132 .forEach((x) => {nodes.unshift(x)});
133 }
134 }
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/test_store.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698