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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 url: 'http://www.google.com/', | 76 url: 'http://www.google.com/', |
77 }; | 77 }; |
78 if (config) { | 78 if (config) { |
79 for (var key in config) | 79 for (var key in config) |
80 newItem[key] = config[key]; | 80 newItem[key] = config[key]; |
81 } | 81 } |
82 return newItem; | 82 return newItem; |
83 } | 83 } |
84 | 84 |
85 /** | 85 /** |
| 86 * @param {Set<T>} |
| 87 * @return {Array<T>} |
| 88 * @template T |
| 89 */ |
| 90 function normalizeSet(set) { |
| 91 return Array.from(set).sort(); |
| 92 } |
| 93 |
| 94 /** |
86 * Sends a custom click event to |element|. | 95 * Sends a custom click event to |element|. |
87 * @param {HTMLElement} element | 96 * @param {HTMLElement} element |
88 * @param {Object=} config | 97 * @param {Object=} config |
89 */ | 98 */ |
90 function customClick(element, config) { | 99 function customClick(element, config) { |
91 var props = { | 100 var props = { |
92 bubbles: true, | 101 bubbles: true, |
93 cancelable: true, | 102 cancelable: true, |
94 buttons: 1, | 103 buttons: 1, |
95 shiftKey: false, | 104 shiftKey: false, |
96 ctrlKey: false, | 105 ctrlKey: false, |
97 }; | 106 }; |
98 | 107 |
99 if (config) { | 108 if (config) { |
100 for (var key in config) | 109 for (var key in config) |
101 props[key] = config[key]; | 110 props[key] = config[key]; |
102 } | 111 } |
103 | 112 |
104 element.dispatchEvent(new MouseEvent('mousedown', props)); | 113 element.dispatchEvent(new MouseEvent('mousedown', props)); |
105 element.dispatchEvent(new MouseEvent('mouseup', props)); | 114 element.dispatchEvent(new MouseEvent('mouseup', props)); |
106 element.dispatchEvent(new MouseEvent('click', props)); | 115 element.dispatchEvent(new MouseEvent('click', props)); |
107 } | 116 } |
OLD | NEW |