| 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 app = body.querySelector('history-app'); | 12 var app = body.querySelector('history-app'); |
| 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 | 13 |
| 17 var currentBody = app || body.querySelector('.test-body'); | 14 var currentBody = app || body.querySelector('.test-body'); |
| 18 body.removeChild(currentBody); | 15 body.removeChild(currentBody); |
| 19 | 16 |
| 17 // Clear any query in the URL. |
| 18 window.history.replaceState({}, '', '/'); |
| 19 |
| 20 element.classList.add('test-body'); | 20 element.classList.add('test-body'); |
| 21 body.appendChild(element); | 21 body.appendChild(element); |
| 22 } | 22 } |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Replace the document body with a new instance of <history-app>. | 25 * Replace the document body with a new instance of <history-app>. |
| 26 * @return {HistoryAppElement} The app which was created. | 26 * @return {HistoryAppElement} The app which was created. |
| 27 */ | 27 */ |
| 28 function replaceApp() { | 28 function replaceApp() { |
| 29 var app = document.createElement('history-app'); | 29 var app = document.createElement('history-app'); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 var tabs = tabUrls.map(function(tabUrl) { | 190 var tabs = tabUrls.map(function(tabUrl) { |
| 191 return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl}; | 191 return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl}; |
| 192 }); | 192 }); |
| 193 | 193 |
| 194 return { | 194 return { |
| 195 tabs: tabs, | 195 tabs: tabs, |
| 196 sessionId: '123', | 196 sessionId: '123', |
| 197 userVisibleTimestamp: "A while ago" | 197 userVisibleTimestamp: "A while ago" |
| 198 }; | 198 }; |
| 199 } | 199 } |
| OLD | NEW |