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

Unified Diff: LayoutTests/crypto/resources/common.js

Issue 209853010: [ABANDONED] Enable V8 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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: 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);
+ });
}
// =====================================================

Powered by Google App Engine
This is Rietveld 408576698