| 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 * Waits for queued up tasks to finish before proceeding. Inspired by: | 6 * Waits for queued up tasks to finish before proceeding. Inspired by: |
| 7 * https://github.com/Polymer/web-component-tester/blob/master/browser/environme
nt/helpers.js#L97 | 7 * https://github.com/Polymer/web-component-tester/blob/master/browser/environme
nt/helpers.js#L97 |
| 8 */ | 8 */ |
| 9 function flush() { | 9 function flush() { |
| 10 Polymer.dom.flush(); | 10 Polymer.dom.flush(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 */ | 68 */ |
| 69 function createHistoryInfo(searchTerm) { | 69 function createHistoryInfo(searchTerm) { |
| 70 return { | 70 return { |
| 71 finished: true, | 71 finished: true, |
| 72 hasSyncedResults: false, | 72 hasSyncedResults: false, |
| 73 queryEndTime: 'Monday', | 73 queryEndTime: 'Monday', |
| 74 queryStartTime: 'Tuesday', | 74 queryStartTime: 'Tuesday', |
| 75 term: searchTerm || '' | 75 term: searchTerm || '' |
| 76 }; | 76 }; |
| 77 } | 77 } |
| 78 |
| 79 /** |
| 80 * @param {Element} element |
| 81 * @param {string} selector |
| 82 * @return {Element} |
| 83 */ |
| 84 function polymerSelectAll(element, selector) { |
| 85 return Polymer.dom(element.root).querySelectorAll(selector); |
| 86 } |
| 87 |
| 88 /** |
| 89 * Returns a promise which is resolved when |eventName| is fired on |element| |
| 90 * and |predicate| is true. |
| 91 * @param {HTMLElement} element |
| 92 * @param {string} eventName |
| 93 * @param {function(Event): boolean} predicate |
| 94 * @return {Promise} |
| 95 */ |
| 96 function waitForEvent(element, eventName, predicate) { |
| 97 if (!predicate) |
| 98 predicate = function() { return true; }; |
| 99 |
| 100 return new Promise(function(resolve) { |
| 101 var listener = function(e) { |
| 102 if (!predicate(e)) |
| 103 return; |
| 104 |
| 105 resolve(); |
| 106 element.removeEventListener(eventName, listener); |
| 107 } |
| 108 |
| 109 element.addEventListener(eventName, listener); |
| 110 }); |
| 111 } |
| OLD | NEW |