From 4d72571b7c6ed617f9e43c51c72cd7d2d4d7755b Mon Sep 17 00:00:00 2001 From: youennf Date: Mon, 20 Jun 2016 23:37:57 +0200 Subject: [PATCH] Fix a flaky ReadableStream test Explicitly wait for the start promise instead of using a timeout. --- streams/readable-streams/general.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/streams/readable-streams/general.js b/streams/readable-streams/general.js index 30eb7ab81602d04..a8924be0532e3e5 100644 --- a/streams/readable-streams/general.js +++ b/streams/readable-streams/general.js @@ -293,8 +293,12 @@ promise_test(() => { promise_test(() => { let pullCount = 0; + const startPromise = Promise.resolve(); const rs = new ReadableStream({ + start() { + return startPromise; + }, pull(c) { // Don't enqueue immediately after start. We want the stream to be empty when we call .read() on it. if (pullCount > 0) { @@ -304,9 +308,9 @@ promise_test(() => { } }); - return delay(1).then(() => { + return startPromise.then(() => { assert_equals(pullCount, 1, 'pull should be called once start finishes'); - + }).then(() => { const reader = rs.getReader(); const read = reader.read(); assert_equals(pullCount, 2, 'pull should be called when read is called');