summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryusukesuzuki@chromium.org <yusukesuzuki@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-09-27 02:22:12 +0000
committeryusukesuzuki@chromium.org <yusukesuzuki@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-09-27 02:22:12 +0000
commit7918de8cacf8c47337c311289ed8fa353ce8572d (patch)
treec70bb032e31d06d5a4be9884f9535c111b266dab
parent7c99b6899d7423cc319d82c9d70350cc14ed8c95 (diff)
downloadchromium_src-7918de8cacf8c47337c311289ed8fa353ce8572d.zip
chromium_src-7918de8cacf8c47337c311289ed8fa353ce8572d.tar.gz
chromium_src-7918de8cacf8c47337c311289ed8fa353ce8572d.tar.bz2
Implement Promise.all
Implement Promise.all static function. It is introduced in the Promises latest draft and Promise.every is replaced with it. BUG=295420 Review URL: https://chromiumcodereview.appspot.com/24641003 git-svn-id: svn://svn.chromium.org/blink/trunk@158412 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/LayoutTests/crypto/resources/common.js2
-rw-r--r--third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-video.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-recursive.html4
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/Promise-static-all-expected.txt32
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/Promise-static-all.html105
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/Promise-static-every-expected.txt21
-rw-r--r--third_party/WebKit/LayoutTests/fast/js/Promise-static-every.html72
-rw-r--r--third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.cpp58
-rw-r--r--third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.h12
-rw-r--r--third_party/WebKit/Source/core/dom/Promise.idl2
11 files changed, 183 insertions, 129 deletions
diff --git a/third_party/WebKit/LayoutTests/crypto/resources/common.js b/third_party/WebKit/LayoutTests/crypto/resources/common.js
index a8e2e30..f003e53 100644
--- a/third_party/WebKit/LayoutTests/crypto/resources/common.js
+++ b/third_party/WebKit/LayoutTests/crypto/resources/common.js
@@ -10,7 +10,7 @@ function importTestKeys()
var aesCbcPromise = crypto.subtle.importKey(keyFormat, data, {name: 'AES-CBC'}, extractable, keyUsages);
var aesCbcJustDecrypt = crypto.subtle.importKey(keyFormat, data, {name: 'AES-CBC'}, false, ['decrypt']);
- return Promise.every(hmacPromise, rsaSsaPromise, aesCbcPromise, aesCbcJustDecrypt).then(function(results) {
+ return Promise.all([hmacPromise, rsaSsaPromise, aesCbcPromise, aesCbcJustDecrypt]).then(function(results) {
return {
hmacSha1: results[0],
rsaSsaSha1: results[1],
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-video.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-video.html
index 83ca4dc..3ea06a1 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-video.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage-video.html
@@ -67,7 +67,7 @@ function videoLoaded() {
var p8 = createImageBitmap(video, -300, -300, 300, 300).then(function (image) { imageBitmaps.empty = image });
var p9 = createImageBitmap(video, 400, 300, 300, 300).then(function (image) { imageBitmaps.emptyTwo = image });
- Promise.every(p1, p2, p3, p4, p5, p6, p7, p8, p9).then(function() {
+ Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9]).then(function() {
checkNoCrop(imageBitmaps.noCrop);
checkCrop(imageBitmaps.crop);
checkCrop(imageBitmaps.cropRight);
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage.html
index 732ff33..ef66489 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-drawImage.html
@@ -177,7 +177,7 @@ function nextCheck(elementIndex) {
var p7 = createImageBitmap(element, 10, 10, -10, -10).then(function (image) { imageBitmaps.negativeCrop = image });
var p8 = createImageBitmap(element, -30, -30, 30, 30).then(function (image) { imageBitmaps.empty = image });
var p9 = createImageBitmap(element, 40, 30, 30, 30).then(function (image) { imageBitmaps.emptyTwo = image });
- Promise.every(p1, p2, p3, p4, p5, p6, p7, p8, p9).then(function() {
+ Promise.all([p1, p2, p3, p4, p5, p6, p7, p8, p9]).then(function() {
checkNoCrop(imageBitmaps.noCrop);
checkCrop(imageBitmaps.crop);
checkCropCenter(imageBitmaps.cropCenter);
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-recursive.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-recursive.html
index 06f6e6c..190c6f8 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-recursive.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-recursive.html
@@ -62,7 +62,7 @@ function imageLoaded() {
var bitmapFromImage, bitmapFromCanvas;
var p1 = createImageBitmap(image, -10, -10, 20, 20).then(function(imageBitmap) { bitmapFromImage = imageBitmap });
var p2 = createImageBitmap(aCanvas, 10, 10, 20, 20).then(function(imageBitmap) { bitmapFromCanvas = imageBitmap });
- Promise.every(p1, p2).then(function() {
+ Promise.all([p1, p2]).then(function() {
checkBitmaps(bitmapFromImage, bitmapFromCanvas);
}, shouldNotBeCalled);
}
@@ -87,7 +87,7 @@ function checkBitmaps(bitmapFromImage, bitmapFromCanvas) {
var p6 = createImageBitmap(bitmapFromCanvas, 5, 5, 10, 10).then(function(imageBitmap) {
funcs[5] = checkDrawnToRect(imageBitmap, 0, 0, 5, 5);
});
- Promise.every(p1, p2, p3, p4, p5, p6).then(function() {
+ Promise.all([p1, p2, p3, p4, p5, p6]).then(function() {
for (var i = 0; i < funcs.length; ++i)
funcs[i]();
finishJSTest();
diff --git a/third_party/WebKit/LayoutTests/fast/js/Promise-static-all-expected.txt b/third_party/WebKit/LayoutTests/fast/js/Promise-static-all-expected.txt
new file mode 100644
index 0000000..521fe20
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/js/Promise-static-all-expected.txt
@@ -0,0 +1,32 @@
+Test Promise.all
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS result is undefined
+PASS Promise.all() is fulfilled.
+PASS result.length is 0
+PASS Promise.all([p1, p2, p3]) is fulfilled.
+PASS result.length is 3
+PASS result[0] is "p1"
+PASS result[1] is "p2"
+PASS result[2] is "p3"
+PASS Promise.all([p1, p6, p5]) is rejected.
+PASS result is "p6"
+PASS Promise.all([p9]) is fulfilled.
+PASS result.length is 1
+PASS result[0] is "p2"
+PASS Promise.all([p9,,,]) is fulfilled.
+PASS result.length is 3
+PASS result[0] is "p2"
+PASS result[1] is undefined
+PASS result[2] is undefined
+PASS Promise.all([p9,42]) is fulfilled.
+PASS result.length is 2
+PASS result[0] is "p2"
+PASS result[1] is 42
+PASS Promise.all({}) is fulfilled.
+PASS result.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/third_party/WebKit/LayoutTests/fast/js/Promise-static-all.html b/third_party/WebKit/LayoutTests/fast/js/Promise-static-all.html
new file mode 100644
index 0000000..9dbcc8b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/js/Promise-static-all.html
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+description('Test Promise.all');
+
+window.jsTestIsAsync = true;
+result = undefined;
+
+var p1 = new Promise(function(resolve) { resolve('p1'); });
+var p2 = new Promise(function(resolve) { resolve('p2'); });
+var p3 = new Promise(function(resolve) { resolve('p3'); });
+var p4 = new Promise(function() {});
+var p5 = new Promise(function() {});
+var p6 = new Promise(function(_, reject) { reject('p6'); });
+var p7 = new Promise(function(_, reject) { reject('p7'); });
+var p8 = new Promise(function(_, reject) { reject('p8'); });
+var p9 = new Promise(function(resolve) { resolve(p2); });
+
+Promise.all([p1, p2, p5]).then(function(result) {
+ testFailed('Promise.all([p1, p2, p5]) is fulfilled.');
+}, function() {
+ testFailed('Promise.all([p1, p2, p5]) is rejected.');
+});
+
+Promise.all().then(function(result) {
+ testPassed('Promise.all() is fulfilled.');
+ window.result = result;
+ shouldBe('result.length', '0');
+}, function() {
+ testFailed('Promise.all() is rejected.');
+}).then(function() {
+ return Promise.all([p1, p2, p3]).then(function(result) {
+ testPassed('Promise.all([p1, p2, p3]) is fulfilled.');
+ window.result = result;
+ shouldBe('result.length', '3');
+ shouldBeEqualToString('result[0]', 'p1');
+ shouldBeEqualToString('result[1]', 'p2');
+ shouldBeEqualToString('result[2]', 'p3');
+ }, function() {
+ testFailed('Promise.all([p1, p2, p3]) is rejected.');
+ });
+}).then(function() {
+ return Promise.all([p1, p6, p5]).then(function(result) {
+ testFailed('Promise.all([p1, p6, p5]) is fulfilled.');
+ }, function(result) {
+ testPassed('Promise.all([p1, p6, p5]) is rejected.');
+ window.result = result;
+ shouldBeEqualToString('result', 'p6');
+ });
+}).then(function() {
+ return Promise.all([p9]).then(function(result) {
+ testPassed('Promise.all([p9]) is fulfilled.');
+ window.result = result;
+ shouldBe('result.length', '1');
+ shouldBeEqualToString('result[0]', 'p2');
+ }, function(result) {
+ testFailed('Promise.all([p9]) is rejected.');
+ });
+}).then(function() {
+ // Array hole should not be skipped.
+ return Promise.all([p9,,,]).then(function(result) {
+ testPassed('Promise.all([p9,,,]) is fulfilled.');
+ window.result = result;
+ shouldBe('result.length', '3');
+ shouldBeEqualToString('result[0]', 'p2');
+ shouldBe('result[1]', 'undefined');
+ shouldBe('result[2]', 'undefined');
+ }, function(result) {
+ testFailed('Promise.all([p9,,,]) is rejected.');
+ });
+}).then(function() {
+ // Immediate value should be converted to a promise object by the
+ // ToPromise operation.
+ return Promise.all([p9,42]).then(function(result) {
+ testPassed('Promise.all([p9,42]) is fulfilled.');
+ window.result = result;
+ shouldBe('result.length', '2');
+ shouldBeEqualToString('result[0]', 'p2');
+ shouldBe('result[1]', '42');
+ }, function(result) {
+ testFailed('Promise.all([p9,42]) is rejected.');
+ });
+}).then(function() {
+ // Not iterable object case.
+ return Promise.all({}).then(function(result) {
+ testPassed('Promise.all({}) is fulfilled.');
+ window.result = result;
+ shouldBe('result.length', '0');
+ }, function(result) {
+ testFailed('Promise.all({}) is rejected.');
+ });
+}).then(finishJSTest, finishJSTest);
+
+shouldBe('result', 'undefined');
+
+</script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/js/Promise-static-every-expected.txt b/third_party/WebKit/LayoutTests/fast/js/Promise-static-every-expected.txt
deleted file mode 100644
index 3a46951..0000000
--- a/third_party/WebKit/LayoutTests/fast/js/Promise-static-every-expected.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-Test Promise.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-PASS result is undefined
-PASS Promise.every() is fulfilled.
-PASS result is undefined
-PASS Promise.every(p1, p2, p3) is fulfilled.
-PASS result.length is 3
-PASS result[0] is "p1"
-PASS result[1] is "p2"
-PASS result[2] is "p3"
-PASS Promise.every(p1, p6, p5) is rejected.
-PASS result is "p6"
-PASS Promise.every(p9) is fulfilled.
-PASS result.length is 1
-PASS result[0] is "p2"
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/third_party/WebKit/LayoutTests/fast/js/Promise-static-every.html b/third_party/WebKit/LayoutTests/fast/js/Promise-static-every.html
deleted file mode 100644
index ee538be..0000000
--- a/third_party/WebKit/LayoutTests/fast/js/Promise-static-every.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src="resources/js-test-pre.js"></script>
-</head>
-<body>
-<div id="description"></div>
-<div id="console"></div>
-<script>
-description('Test Promise.');
-
-window.jsTestIsAsync = true;
-result = undefined;
-
-var p1 = new Promise(function(resolve) { resolve('p1'); });
-var p2 = new Promise(function(resolve) { resolve('p2'); });
-var p3 = new Promise(function(resolve) { resolve('p3'); });
-var p4 = new Promise(function() {});
-var p5 = new Promise(function() {});
-var p6 = new Promise(function(_, reject) { reject('p6'); });
-var p7 = new Promise(function(_, reject) { reject('p7'); });
-var p8 = new Promise(function(_, reject) { reject('p8'); });
-var p9 = new Promise(function(resolve) { resolve(p2); });
-
-Promise.every(p1, p2, p5).then(function(result) {
- testFailed('Promise.every(p1, p2, p5) is fulfilled.');
-}, function() {
- testFailed('Promise.every(p1, p2, p5) is rejected.');
-});
-
-Promise.every().then(function(result) {
- testPassed('Promise.every() is fulfilled.');
- window.result = result;
- shouldBe('result', 'undefined');
-}, function() {
- testFailed('Promise.every() is rejected.');
-}).then(function() {
- return Promise.every(p1, p2, p3).then(function(result) {
- testPassed('Promise.every(p1, p2, p3) is fulfilled.');
- window.result = result;
- shouldBe('result.length', '3');
- shouldBeEqualToString('result[0]', 'p1');
- shouldBeEqualToString('result[1]', 'p2');
- shouldBeEqualToString('result[2]', 'p3');
- }, function() {
- testFailed('Promise.every(p1, p2, p3) is rejected.');
- });
-}).then(function() {
- return Promise.every(p1, p6, p5).then(function(result) {
- testFailed('Promise.every(p1, p6, p5) is fulfilled.');
- }, function(result) {
- testPassed('Promise.every(p1, p6, p5) is rejected.');
- window.result = result;
- shouldBeEqualToString('result', 'p6');
- });
-}).then(function() {
- return Promise.every(p9).then(function(result) {
- testPassed('Promise.every(p9) is fulfilled.');
- window.result = result;
- shouldBe('result.length', '1');
- shouldBeEqualToString('result[0]', 'p2');
- }, function(result) {
- testFailed('Promise.every(p9) is rejected.');
- });
-}).then(finishJSTest, finishJSTest);
-
-shouldBe('result', 'undefined');
-
-</script>
-<script src="resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.cpp
index c133068..b3b278f 100644
--- a/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -73,11 +73,11 @@ v8::Local<v8::ObjectTemplate> wrapperCallbackEnvironmentObjectTemplate(v8::Isola
return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::WrapperCallbackEnvironmentFieldCount, isolate);
}
-v8::Local<v8::ObjectTemplate> promiseEveryEnvironmentObjectTemplate(v8::Isolate* isolate)
+v8::Local<v8::ObjectTemplate> promiseAllEnvironmentObjectTemplate(v8::Isolate* isolate)
{
// This is only for getting a unique pointer which we can pass to privateTemplate.
static int privateTemplateUniqueKey = 0;
- return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::PromiseEveryEnvironmentFieldCount, isolate);
+ return cachedObjectTemplate(&privateTemplateUniqueKey, V8PromiseCustom::PromiseAllEnvironmentFieldCount, isolate);
}
v8::Local<v8::ObjectTemplate> primitiveWrapperObjectTemplate(v8::Isolate* isolate)
@@ -222,7 +222,7 @@ void callCallbacks(v8::Handle<v8::Array> callbacks, v8::Handle<v8::Value> result
}
}
-void promiseEveryFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
+void promiseAllFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
ASSERT(!args.Data().IsEmpty());
@@ -231,10 +231,10 @@ void promiseEveryFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args
if (args.Length() > 0)
result = args[0];
- v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseIndex).As<v8::Object>();
- v8::Local<v8::Object> countdownWrapper = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex).As<v8::Object>();
- v8::Local<v8::Integer> index = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex).As<v8::Integer>();
- v8::Local<v8::Array> results = environment->GetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex).As<v8::Array>();
+ v8::Local<v8::Object> promise = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentPromiseIndex).As<v8::Object>();
+ v8::Local<v8::Object> countdownWrapper = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentCountdownIndex).As<v8::Object>();
+ v8::Local<v8::Integer> index = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentIndexIndex).As<v8::Integer>();
+ v8::Local<v8::Array> results = environment->GetInternalField(V8PromiseCustom::PromiseAllEnvironmentResultsIndex).As<v8::Array>();
results->Set(index->Value(), result);
@@ -247,15 +247,15 @@ void promiseEveryFulfillCallback(const v8::FunctionCallbackInfo<v8::Value>& args
countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(countdown->Value() - 1, isolate));
}
-v8::Local<v8::Object> promiseEveryEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> countdownWrapper, int index, v8::Handle<v8::Array> results, v8::Isolate* isolate)
+v8::Local<v8::Object> promiseAllEnvironment(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> countdownWrapper, int index, v8::Handle<v8::Array> results, v8::Isolate* isolate)
{
- v8::Local<v8::ObjectTemplate> objectTemplate = promiseEveryEnvironmentObjectTemplate(isolate);
+ v8::Local<v8::ObjectTemplate> objectTemplate = promiseAllEnvironmentObjectTemplate(isolate);
v8::Local<v8::Object> environment = objectTemplate->NewInstance();
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentPromiseIndex, promise);
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentCountdownIndex, countdownWrapper);
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentIndexIndex, v8::Integer::New(index, isolate));
- environment->SetInternalField(V8PromiseCustom::PromiseEveryEnvironmentResultsIndex, results);
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentPromiseIndex, promise);
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentCountdownIndex, countdownWrapper);
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentIndexIndex, v8::Integer::New(index, isolate));
+ environment->SetInternalField(V8PromiseCustom::PromiseAllEnvironmentResultsIndex, results);
return environment;
}
@@ -422,29 +422,39 @@ void V8Promise::raceMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args
v8SetReturnValue(args, promise);
}
-void V8Promise::everyMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8Promise::allMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::Local<v8::Object> promise = V8PromiseCustom::createPromise(args.Holder(), isolate);
+ v8::Local<v8::Array> results = v8::Array::New();
- if (!args.Length()) {
- V8PromiseCustom::resolve(promise, v8::Undefined(isolate), V8PromiseCustom::Asynchronous, isolate);
+ if (!args.Length() || !args[0]->IsArray()) {
+ V8PromiseCustom::resolve(promise, results, V8PromiseCustom::Asynchronous, isolate);
+ v8SetReturnValue(args, promise);
+ return;
+ }
+
+ // FIXME: Now we limit the iterable type to the Array type.
+ v8::Local<v8::Array> iterable = args[0].As<v8::Array>();
+
+ if (!iterable->Length()) {
+ V8PromiseCustom::resolve(promise, results, V8PromiseCustom::Asynchronous, isolate);
v8SetReturnValue(args, promise);
return;
}
v8::Local<v8::ObjectTemplate> objectTemplate = primitiveWrapperObjectTemplate(isolate);
v8::Local<v8::Object> countdownWrapper = objectTemplate->NewInstance();
- countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(args.Length(), isolate));
- v8::Local<v8::Array> results = v8::Array::New();
+ countdownWrapper->SetInternalField(V8PromiseCustom::PrimitiveWrapperPrimitiveIndex, v8::Integer::New(iterable->Length(), isolate));
v8::Local<v8::Function> rejectCallback = createClosure(promiseRejectCallback, promise, isolate);
- for (int i = 0; i < args.Length(); ++i) {
- v8::Local<v8::Object> environment = promiseEveryEnvironment(promise, countdownWrapper, i, results, isolate);
- v8::Local<v8::Function> fulfillCallback = createClosure(promiseEveryFulfillCallback, environment, isolate);
- v8::Local<v8::Object> eachPromise = V8PromiseCustom::createPromise(args.Holder(), isolate);
- V8PromiseCustom::resolve(eachPromise, args[i], V8PromiseCustom::Asynchronous, isolate);
- V8PromiseCustom::append(eachPromise, fulfillCallback, rejectCallback, isolate);
+ for (unsigned i = 0, length = iterable->Length(); i < length; ++i) {
+ // Array-holes should not be skipped by for-of iteration semantics.
+ v8::Local<v8::Object> environment = promiseAllEnvironment(promise, countdownWrapper, i, results, isolate);
+ v8::Local<v8::Function> fulfillCallback = createClosure(promiseAllFulfillCallback, environment, isolate);
+ V8TRYCATCH_VOID(v8::Local<v8::Value>, nextValue, iterable->Get(i));
+ v8::Local<v8::Object> nextPromise = V8PromiseCustom::toPromise(nextValue, isolate);
+ V8PromiseCustom::append(nextPromise, fulfillCallback, rejectCallback, isolate);
}
v8SetReturnValue(args, promise);
}
diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.h
index e93036e..a4b1334a 100644
--- a/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.h
+++ b/third_party/WebKit/Source/bindings/v8/custom/V8PromiseCustom.h
@@ -47,12 +47,12 @@ public:
WrapperCallbackEnvironmentFieldCount, // This entry must always be at the bottom.
};
- enum PromiseEveryEnvironmentFieldIndex {
- PromiseEveryEnvironmentPromiseIndex,
- PromiseEveryEnvironmentCountdownIndex,
- PromiseEveryEnvironmentIndexIndex,
- PromiseEveryEnvironmentResultsIndex,
- PromiseEveryEnvironmentFieldCount, // This entry must always be at the bottom.
+ enum PromiseAllEnvironmentFieldIndex {
+ PromiseAllEnvironmentPromiseIndex,
+ PromiseAllEnvironmentCountdownIndex,
+ PromiseAllEnvironmentIndexIndex,
+ PromiseAllEnvironmentResultsIndex,
+ PromiseAllEnvironmentFieldCount, // This entry must always be at the bottom.
};
enum PrimitiveWrapperFieldIndex {
diff --git a/third_party/WebKit/Source/core/dom/Promise.idl b/third_party/WebKit/Source/core/dom/Promise.idl
index 7e3dba9..bb6da2d 100644
--- a/third_party/WebKit/Source/core/dom/Promise.idl
+++ b/third_party/WebKit/Source/core/dom/Promise.idl
@@ -43,5 +43,5 @@ callback AnyCallback = any (optional any value);
[Custom] static Promise cast(any value);
[Custom] static Promise race(any iterable);
- [Custom] static Promise every(any... values);
+ [Custom] static Promise all(any iterable);
};