Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/test/data/webui/polymer_browser_test_base.js

Issue 2829383002: PolymerTest.clearBody: don't remove vulcanized styles (Closed)
Patch Set: comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @fileoverview Framework for running JavaScript tests of Polymer elements. 6 * @fileoverview Framework for running JavaScript tests of Polymer elements.
7 */ 7 */
8 8
9 /** 9 /**
10 * Test fixture for Polymer element testing. 10 * Test fixture for Polymer element testing.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 var promise = new Promise(function(resolve, reject) { 181 var promise = new Promise(function(resolve, reject) {
182 script.onload = resolve; 182 script.onload = resolve;
183 script.onerror = reject; 183 script.onerror = reject;
184 }); 184 });
185 script.src = src; 185 script.src = src;
186 document.head.appendChild(script); 186 document.head.appendChild(script);
187 return promise; 187 return promise;
188 }; 188 };
189 189
190 /** 190 /**
191 * Removes all content from the body. 191 * Removes all content from the body. In a vulcanized build, this retains the
192 * inlined tags so stylesheets and dom-modules are not discarded.
192 */ 193 */
193 PolymerTest.clearBody = function() { 194 PolymerTest.clearBody = function() {
195 // Save the div where vulcanize inlines content before clearing the page.
196 var vulcanizeDiv = document.querySelector('body > div[hidden][by-vulcanize]');
194 document.body.innerHTML = ''; 197 document.body.innerHTML = '';
198 if (vulcanizeDiv)
199 document.body.appendChild(vulcanizeDiv);
195 }; 200 };
196 201
197 /** 202 /**
198 * Helper function to return the list of extra libraries relative to basePath. 203 * Helper function to return the list of extra libraries relative to basePath.
199 */ 204 */
200 PolymerTest.getLibraries = function(basePath) { 205 PolymerTest.getLibraries = function(basePath) {
201 // Ensure basePath ends in '/'. 206 // Ensure basePath ends in '/'.
202 if (basePath.length && basePath[basePath.length - 1] != '/') 207 if (basePath.length && basePath[basePath.length - 1] != '/')
203 basePath += '/'; 208 basePath += '/';
204 209
205 return PolymerTest.prototype.extraLibraries.map(function(library) { 210 return PolymerTest.prototype.extraLibraries.map(function(library) {
206 return basePath + library; 211 return basePath + library;
207 }); 212 });
208 }; 213 };
209 214
210 /* 215 /*
211 * Waits for queued up tasks to finish before proceeding. Inspired by: 216 * Waits for queued up tasks to finish before proceeding. Inspired by:
212 * https://github.com/Polymer/web-component-tester/blob/master/browser/environme nt/helpers.js#L97 217 * https://github.com/Polymer/web-component-tester/blob/master/browser/environme nt/helpers.js#L97
213 */ 218 */
214 PolymerTest.flushTasks = function() { 219 PolymerTest.flushTasks = function() {
215 Polymer.dom.flush(); 220 Polymer.dom.flush();
216 // Promises have microtask timing, so we use setTimeout to explicity force a 221 // Promises have microtask timing, so we use setTimeout to explicity force a
217 // new task. 222 // new task.
218 return new Promise(function(resolve, reject) { 223 return new Promise(function(resolve, reject) {
219 window.setTimeout(resolve, 0); 224 window.setTimeout(resolve, 0);
220 }); 225 });
221 }; 226 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698