From b5c0ad7df796676983666f5de1dbd489c6d17d1b Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Tue, 1 Apr 2014 15:17:11 -0400 Subject: [PATCH] Alter the test then function a little Before this change all the chained then calls got grouped into the same setTimeout bucket, which meant that other setTimeouts all get called after all the then chained calls. Fixes https://github.com/Polymer/ShadowDOM/issues/412 --- tests/tests.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/tests.js b/tests/tests.js index c835d44..f02c4d1 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -28,15 +28,20 @@ function doTeardown() { assert.strictEqual(0, Observer._allObserversCount); } -function then(fn) { +function then(fn, n) { + // We need to ensure that all chained calls are not grouped into the same + // setTimeout bucket. This is to allow other scheduled functions to have a go + // too. + n = n || 10; setTimeout(function() { Platform.performMicrotaskCheckpoint(); fn(); - }, 0); + }, n); return { then: function(next) { - return then(next); + n += 10; + return then(next, n); } }; }