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

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

Issue 2639453002: [MD Bookmarks] Add Select for Bookmarks. (Closed)
Patch Set: fixed some comments Created 3 years, 10 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/store_test.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 if (children.length) { 45 if (children.length) {
46 for (var i = 0; i < children.length; i++) { 46 for (var i = 0; i < children.length; i++) {
47 children[i].index = i; 47 children[i].index = i;
48 children[i].parentId = newFolder.id; 48 children[i].parentId = newFolder.id;
49 } 49 }
50 } 50 }
51 return newFolder; 51 return newFolder;
52 } 52 }
53 53
54 /** 54 /**
55 * Splices out the item/folder at |index| and adjusts the indices of all the
56 * items after that.
57 * @param {BookmarkTreeNode} tree
58 * @param {Number} index
59 */
60 function removeChild(tree, index) {
61 tree.children.splice(index, 1);
62 for (var i = index; i < tree.children.length; i++) {
63 tree.children[i].index = i;
64 }
65 }
66
67 /**
55 * Creates a bookmark with given properties. 68 * Creates a bookmark with given properties.
56 * @param {string} id 69 * @param {string} id
57 * @param {Object=} config 70 * @param {Object=} config
58 * @return {BookmarkTreeNode} 71 * @return {BookmarkTreeNode}
59 */ 72 */
60 function createItem(id, config) { 73 function createItem(id, config) {
61 var newItem = { 74 var newItem = {
62 id: id, 75 id: id,
63 title: '', 76 title: '',
64 url: 'http://www.google.com/', 77 url: 'http://www.google.com/',
65 }; 78 };
66 if (config) { 79 if (config) {
67 for (var key in config) 80 for (var key in config)
68 newItem[key] = config[key]; 81 newItem[key] = config[key];
69 } 82 }
70 return newItem; 83 return newItem;
71 } 84 }
85
86 /**
87 * Sends a custom click event to |element|.
88 * @param {HTMLElement} element
89 * @param {Object=} config
90 */
91 function customClick(element, config) {
92 var props = {
93 bubbles: true,
94 cancelable: true,
95 buttons: 1,
96 shiftKey: false,
97 ctrlKey: false,
98 };
99
100 if (config) {
101 for (var key in config)
102 props[key] = config[key];
103 }
104
105 element.dispatchEvent(new MouseEvent('mousedown', props));
106 element.dispatchEvent(new MouseEvent('mouseup', props));
107 element.dispatchEvent(new MouseEvent('click', props));
108 }
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/store_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698