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

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

Issue 1310843010: Add Polymer tests for cr-settings-prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 b768ef76f555a034a033641b08b6ae2c3845b7de..022c94012e31122db59e9f440b4095da6314f793 100644
--- a/chrome/test/data/webui/polymer_browser_test_base.js
+++ b/chrome/test/data/webui/polymer_browser_test_base.js
@@ -95,3 +95,27 @@ PolymerTest.getLibraries = function(basePath) {
return basePath + library;
});
};
+
+/**
+ * Allows chaining asynchronous function to avoid having to write nested
+ * Promises or setTimeouts.
+ * Example: PolymerTest.async(fn1).async(fn2).async(fn3).async(done);
+ */
+PolymerTest.async = function(fn) {
+ // Wrap the asynchronous call to |fn| in a Promise.
+ var p = new Promise(function(resolve, reject) {
+ setTimeout(function() {
+ fn.call();
+ resolve();
+ });
+ });
+ // Return a helper function of the same name which adds this function to the
+ // Promise chain.
+ return {
+ async: function(fn) {
+ p.then(function() {
+ return PolymerTest.async(fn);
michaelpg 2015/09/08 06:26:59 this doesn't quite work. what I actually want is s
michaelpg 2015/09/11 20:14:38 Ignore this comment, see new patch.
+ });
+ },
+ };
+};

Powered by Google App Engine
This is Rietveld 408576698