Commit b3c03ff2 authored by Kevin Gibbons's avatar Kevin Gibbons Committed by Commit Bot

[promise] Promise.all with broken iterable rejects rather than throwing

When Promise.all is called with something which violates the iterable
contract, the resulting error should be provided by returning a rejected
promise, not by throwing.

Bug: v8:7553
Change-Id: I2769b09b49c9b80ef380419489416fc0fabff51b
Reviewed-on: https://chromium-review.googlesource.com/959599
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51902}
parent 3966891a
......@@ -40,7 +40,11 @@ IteratorRecord IteratorBuiltinsAssembler::GetIterator(Node* context,
Branch(IsJSReceiver(iterator), &get_next, &if_notobject);
BIND(&if_notobject);
{ ThrowTypeError(context, MessageTemplate::kNotAnIterator, iterator); }
{
Node* ret = CallRuntime(Runtime::kThrowSymbolIteratorInvalid, context);
GotoIfException(ret, if_exception, exception);
Unreachable();
}
BIND(&get_next);
Node* const next = GetProperty(context, iterator, factory()->next_string());
......
......@@ -582,6 +582,15 @@ function assertAsyncDone(iteration) {
testPromiseAllNonIterable(42);
})();
(function() {
Promise.all({[symbolIterator](){ return null; }}).then(
assertUnreachable,
function(r) {
assertAsync(r instanceof TypeError, 'all/non iterable');
});
assertAsyncRan();
})();
(function() {
var deferred = defer(Promise);
var p = deferred.promise;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment