| 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 /* | |
| 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 | |
| 8 */ | |
| 9 function flush() { | |
| 10 Polymer.dom.flush(); | |
| 11 // Promises have microtask timing, so we use setTimeout to explicity force a | |
| 12 // new task. | |
| 13 return new Promise(function(resolve, reject) { | |
| 14 window.setTimeout(resolve, 0); | |
| 15 }); | |
| 16 } | |
| 17 | |
| 18 /** | 5 /** |
| 19 * Replace the current primary element of the test with a new element. Useful | 6 * Replace the current primary element of the test with a new element. Useful |
| 20 * as an alternative to PolymerTest.clearBody() which preserves styling. | 7 * as an alternative to PolymerTest.clearBody() which preserves styling. |
| 21 * @param {Element} element | 8 * @param {Element} element |
| 22 */ | 9 */ |
| 23 function replaceBody(element) { | 10 function replaceBody(element) { |
| 24 var body = document.body; | 11 var body = document.body; |
| 25 var currentBody = | 12 var currentBody = |
| 26 body.querySelector('history-app') || body.querySelector('.test-body'); | 13 body.querySelector('history-app') || body.querySelector('.test-body'); |
| 27 body.removeChild(currentBody); | 14 body.removeChild(currentBody); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 var tabs = tabUrls.map(function(tabUrl) { | 185 var tabs = tabUrls.map(function(tabUrl) { |
| 199 return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl}; | 186 return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl}; |
| 200 }); | 187 }); |
| 201 | 188 |
| 202 return { | 189 return { |
| 203 tabs: tabs, | 190 tabs: tabs, |
| 204 sessionId: '123', | 191 sessionId: '123', |
| 205 userVisibleTimestamp: "A while ago" | 192 userVisibleTimestamp: "A while ago" |
| 206 }; | 193 }; |
| 207 } | 194 } |
| OLD | NEW |