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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 id: id, | 62 id: id, |
63 title: '', | 63 title: '', |
64 url: 'http://www.google.com/', | 64 url: 'http://www.google.com/', |
65 }; | 65 }; |
66 if (config) { | 66 if (config) { |
67 for (var key in config) | 67 for (var key in config) |
68 newItem[key] = config[key]; | 68 newItem[key] = config[key]; |
69 } | 69 } |
70 return newItem; | 70 return newItem; |
71 } | 71 } |
| 72 |
| 73 /** |
| 74 * Sends a custom click event to |element|. |
| 75 * @param {HTMLElement} element |
| 76 * @param {Object=} config |
| 77 */ |
| 78 function customClick(element, config) { |
| 79 var props = { |
| 80 bubbles: true, |
| 81 cancelable: true, |
| 82 buttons: 1, |
| 83 shiftKey: false, |
| 84 ctrlKey: false, |
| 85 }; |
| 86 |
| 87 if (config) { |
| 88 for (var key in config) |
| 89 props[key] = config[key]; |
| 90 } |
| 91 |
| 92 element.dispatchEvent(new MouseEvent('mousedown', props)); |
| 93 element.dispatchEvent(new MouseEvent('mouseup', props)); |
| 94 element.dispatchEvent(new MouseEvent('click', props)); |
| 95 } |
OLD | NEW |