Chromium Code Reviews| Index: LayoutTests/crypto/resources/common.js |
| diff --git a/LayoutTests/crypto/resources/common.js b/LayoutTests/crypto/resources/common.js |
| index 2038b3795a1430a6ef426839d0e5f277ad7c5bca..06e534bc77c1048f3ddcda7e200a2344f0068381 100644 |
| --- a/LayoutTests/crypto/resources/common.js |
| +++ b/LayoutTests/crypto/resources/common.js |
| @@ -98,32 +98,35 @@ function failAndFinishJSTest(error) |
| // FIXME: Delete the addTask() functions (better to test results directly) |
| // ===================================================== |
| -numOutstandingTasks = 0; |
| +var tasks = []; |
| -function addTask(promise) |
| +function runLoop() |
| { |
| - numOutstandingTasks++; |
| - |
| - function taskFinished() |
| - { |
| - numOutstandingTasks--; |
| - completeTestWhenAllTasksDone(); |
| + if (tasks.length === 0) { |
| + finishJSTest(); |
| + return; |
| } |
| + var task = tasks.shift(); |
| + task().then(runLoop); |
| +} |
| - promise.then(taskFinished, taskFinished); |
| +function addTask(task) |
| +{ |
| + tasks.push(task); |
| + if (tasks.length === 1) { |
| + runLoop(); |
| + } |
| } |
| function completeTestWhenAllTasksDone() |
| { |
| - if (numOutstandingTasks == 0) { |
| + if (tasks.length === 0) { |
| finishJSTest(); |
| } |
| } |
| function shouldRejectPromiseWithNull(code) |
| { |
| - var promise = eval(code); |
| - |
| function acceptCallback(result) |
| { |
| debug("FAIL: '" + code + "' accepted with " + result + " but should have been rejected"); |
| @@ -137,13 +140,14 @@ function shouldRejectPromiseWithNull(code) |
| debug("FAIL: '" + code + "' rejected with " + result + " but was expecting null"); |
| } |
| - addTask(promise.then(acceptCallback, rejectCallback)); |
| + addTask(function() { |
| + var promise = eval(code); |
|
eroman
2014/03/26 09:07:58
In general this change is not a good idea, since "
|
| + return promise.then(acceptCallback, rejectCallback); |
| + }); |
| } |
| function shouldAcceptPromise(code) |
| { |
| - var promise = eval(code); |
| - |
| function acceptCallback(result) |
| { |
| debug("PASS: '" + code + "' accepted with " + result); |
| @@ -154,7 +158,10 @@ function shouldAcceptPromise(code) |
| debug("FAIL: '" + code + "' rejected with " + result); |
| } |
| - addTask(promise.then(acceptCallback, rejectCallback)); |
| + addTask(function() { |
| + var promise = eval(code); |
|
eroman
2014/03/26 09:07:58
Same comment as above.
|
| + return promise.then(acceptCallback, rejectCallback); |
| + }); |
| } |
| // ===================================================== |