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

Unified Diff: chrome/test/data/webui/polymer_browser_test_base.js

Issue 2829383002: PolymerTest.clearBody: don't remove vulcanized styles (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/polymer_browser_test_base.js
diff --git a/chrome/test/data/webui/polymer_browser_test_base.js b/chrome/test/data/webui/polymer_browser_test_base.js
index b63110cd36f562c154c2028349724d90f5e5038f..40bd809b0d621122a52d9e91972aae14328477cb 100644
--- a/chrome/test/data/webui/polymer_browser_test_base.js
+++ b/chrome/test/data/webui/polymer_browser_test_base.js
@@ -188,10 +188,24 @@ PolymerTest.loadScript = function(src) {
};
/**
- * Removes all content from the body.
+ * Removes all content from the body, save for the global <style> elements
+ * used by a vulcanized build.
*/
PolymerTest.clearBody = function() {
- document.body.innerHTML = '';
+ var vulcanizeDiv = document.querySelector('body > div[hidden][by-vulcanize]');
dpapad 2017/04/24 18:35:15 Would it be simpler to do the following? var toRe
dpapad 2017/04/25 01:11:09 Or maybe even better to use the following selector
+ document.body.innerHTML='';
+ if (!vulcanizeDiv)
+ return;
+
+ if (!vulcanizeDiv.hasAttribute('processed-by-test')) {
dpapad 2017/04/24 18:35:15 What is "processed-by-test"?
+ for (var child of vulcanizeDiv.children) {
+ if (child.tagName != 'STYLE')
+ child.remove();
+ }
+ vulcanizeDiv.setAttribute('processed-by-test', '');
+ }
+
+ document.body.appendChild(vulcanizeDiv);
};
/**
« 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