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

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

Issue 1575953004: PolymerTestBase: Load mock-interactions.js instead of importing HTML (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: closure type Created 4 years, 11 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 17da94bd9463e9d44554704b3794721f6a3c5f80..bab6405dd7878eadc1873ab6d0d87a80073ef453 100644
--- a/chrome/test/data/webui/polymer_browser_test_base.js
+++ b/chrome/test/data/webui/polymer_browser_test_base.js
@@ -60,6 +60,7 @@ PolymerTest.prototype = {
// List of imported URLs for debugging purposes.
PolymerTest.importUrls_ = [];
+ PolymerTest.scriptUrls_ = [];
// Importing a URL like "chrome://md-settings/foo" redirects to the base
// ("chrome://md-settings") page, which due to how browsePreload works can
@@ -78,6 +79,8 @@ PolymerTest.prototype = {
'sure the following URLs are correct and unique:\n';
for (var i = 0; i < PolymerTest.importUrls_.length; i++)
msg += ' ' + PolymerTest.importUrls_[i] + '\n';
+ for (var i = 0; i < PolymerTest.scriptUrls_.length; i++)
+ msg += ' ' + PolymerTest.scriptUrls_[i] + '\n';
console.error(msg);
// Mocha will handle the error.
@@ -93,11 +96,13 @@ PolymerTest.prototype = {
PolymerTest.importHtml(
'chrome://resources/polymer/v1_0/polymer/polymer.html'));
}
- if (typeof TestHelpers != 'object') {
+ if (typeof MockInteractions != 'object') {
+ // Avoid importing the HTML file because iron-test-helpers assumes it is
+ // not being imported separately alongside a vulcanized Polymer.
promises.push(
- PolymerTest.importHtml(
+ PolymerTest.loadScript(
'chrome://resources/polymer/v1_0/iron-test-helpers/' +
- 'iron-test-helpers.html'));
+ 'mock-interactions.js'));
}
return Promise.all(promises);
});
@@ -125,7 +130,7 @@ PolymerTest.prototype = {
/**
* Imports the HTML file.
* @param {string} src The URL to load.
- * @return {Promise} A promise that is resolved/rejected on success/failure.
+ * @return {!Promise} A promise that is resolved/rejected on success/failure.
*/
PolymerTest.importHtml = function(src) {
PolymerTest.importUrls_.push(src);
@@ -141,6 +146,23 @@ PolymerTest.importHtml = function(src) {
};
/**
+ * Loads the script file.
+ * @param {string} src The URL to load.
+ * @return {!Promise} A promise that is resolved/rejected on success/failure.
+ */
+PolymerTest.loadScript = function(src) {
+ PolymerTest.scriptUrls_.push(src);
+ var script = document.createElement('script');
+ var promise = new Promise(function(resolve, reject) {
+ script.onload = resolve;
+ script.onerror = reject;
+ });
+ script.src = src;
+ document.head.appendChild(script);
+ return promise;
+};
+
+/**
* Removes all content from the body.
*/
PolymerTest.clearBody = function() {
« 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