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 022c94012e31122db59e9f440b4095da6314f793..c4873770b3f0ddd59f253cf2ecdc07103f7b926f 100644 |
--- a/chrome/test/data/webui/polymer_browser_test_base.js |
+++ b/chrome/test/data/webui/polymer_browser_test_base.js |
@@ -102,20 +102,22 @@ PolymerTest.getLibraries = function(basePath) { |
* 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(); |
+ if (!PolymerTest.lastPromise_) { |
+ PolymerTest.lastPromise_ = new Promise(function(resolve) { |
+ setTimeout(fn); |
+ setTimeout(resolve); |
+ }); |
+ } else { |
+ PolymerTest.lastPromise_ = PolymerTest.lastPromise_.then(function() { |
+ return new Promise(function(resolve) { |
+ fn(); |
+ setTimeout(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); |
- }); |
- }, |
+ async: PolymerTest.async |
}; |
}; |