OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 children[i].parentId = newFolder.id; | 47 children[i].parentId = newFolder.id; |
48 } | 48 } |
49 } | 49 } |
50 return newFolder; | 50 return newFolder; |
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 } | 63 } |
64 | 64 |
65 /** | 65 /** |
66 * Creates a bookmark with given properties. | 66 * Creates a bookmark with given properties. |
67 * @param {string} id | 67 * @param {string} id |
(...skipping 24 matching lines...) Expand all Loading... |
92 | 92 |
93 /** | 93 /** |
94 * Sends a custom click event to |element|. | 94 * Sends a custom click event to |element|. |
95 * @param {HTMLElement} element | 95 * @param {HTMLElement} element |
96 * @param {Object=} config | 96 * @param {Object=} config |
97 */ | 97 */ |
98 function customClick(element, config) { | 98 function customClick(element, config) { |
99 var props = { | 99 var props = { |
100 bubbles: true, | 100 bubbles: true, |
101 cancelable: true, | 101 cancelable: true, |
| 102 button: 0, |
102 buttons: 1, | 103 buttons: 1, |
103 shiftKey: false, | 104 shiftKey: false, |
104 ctrlKey: false, | 105 ctrlKey: false, |
| 106 detail: 1, |
105 }; | 107 }; |
106 | 108 |
107 if (config) { | 109 if (config) { |
108 for (var key in config) | 110 for (var key in config) |
109 props[key] = config[key]; | 111 props[key] = config[key]; |
110 } | 112 } |
111 | 113 |
112 element.dispatchEvent(new MouseEvent('mousedown', props)); | 114 element.dispatchEvent(new MouseEvent('mousedown', props)); |
113 element.dispatchEvent(new MouseEvent('mouseup', props)); | 115 element.dispatchEvent(new MouseEvent('mouseup', props)); |
114 element.dispatchEvent(new MouseEvent('click', props)); | 116 element.dispatchEvent(new MouseEvent('click', props)); |
| 117 if (config && config.detail == 2) |
| 118 element.dispatchEvent(new MouseEvent('dblclick', props)); |
115 } | 119 } |
116 | 120 |
117 /** | 121 /** |
118 * Returns a folder node beneath |rootNode| which matches |id|. | 122 * Returns a folder node beneath |rootNode| which matches |id|. |
119 * @param {BookmarksFolderNodeElement} rootNode | 123 * @param {BookmarksFolderNodeElement} rootNode |
120 * @param {string} id | 124 * @param {string} id |
121 * @return {BookmarksFolderNodeElement} | 125 * @return {BookmarksFolderNodeElement} |
122 */ | 126 */ |
123 function findFolderNode(rootNode, id) { | 127 function findFolderNode(rootNode, id) { |
124 var nodes = [rootNode]; | 128 var nodes = [rootNode]; |
125 var node; | 129 var node; |
126 while (nodes.length) { | 130 while (nodes.length) { |
127 node = nodes.pop(); | 131 node = nodes.pop(); |
128 if (node.itemId == id) | 132 if (node.itemId == id) |
129 return node; | 133 return node; |
130 | 134 |
131 node.root.querySelectorAll('bookmarks-folder-node') | 135 node.root.querySelectorAll('bookmarks-folder-node') |
132 .forEach((x) => {nodes.unshift(x)}); | 136 .forEach((x) => {nodes.unshift(x)}); |
133 } | 137 } |
134 } | 138 } |
OLD | NEW |