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 primary element of the test with a new element. Useful | 6 * Replace the current primary element of the test with a new element. Useful |
7 * as an alternative to PolymerTest.clearBody() which preserves styling. | 7 * as an alternative to PolymerTest.clearBody() which preserves styling. |
8 * @param {Element} element | 8 * @param {Element} element |
9 */ | 9 */ |
10 function replaceBody(element) { | 10 function replaceBody(element) { |
11 var body = document.body; | 11 var body = document.body; |
12 var currentBody = | 12 var app = body.querySelector('history-app'); |
13 body.querySelector('history-app') || body.querySelector('.test-body'); | 13 // Clear the query on the app, if it exists. This clears any query in the URL. |
| 14 if (app) |
| 15 app.set('queryState_.searchTerm', ''); |
| 16 |
| 17 var currentBody = app || body.querySelector('.test-body'); |
14 body.removeChild(currentBody); | 18 body.removeChild(currentBody); |
15 | 19 |
16 element.classList.add('test-body'); | 20 element.classList.add('test-body'); |
17 body.appendChild(element); | 21 body.appendChild(element); |
18 } | 22 } |
19 | 23 |
20 /** | 24 /** |
21 * Replace the document body with a new instance of <history-app>. | 25 * Replace the document body with a new instance of <history-app>. |
22 * @return {HistoryAppElement} The app which was created. | 26 * @return {HistoryAppElement} The app which was created. |
23 */ | 27 */ |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 var tabs = tabUrls.map(function(tabUrl) { | 189 var tabs = tabUrls.map(function(tabUrl) { |
186 return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl}; | 190 return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl}; |
187 }); | 191 }); |
188 | 192 |
189 return { | 193 return { |
190 tabs: tabs, | 194 tabs: tabs, |
191 sessionId: '123', | 195 sessionId: '123', |
192 userVisibleTimestamp: "A while ago" | 196 userVisibleTimestamp: "A while ago" |
193 }; | 197 }; |
194 } | 198 } |
OLD | NEW |