[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: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51902}
This commit is contained in:
Kevin Gibbons 2018-03-12 18:42:32 -07:00 committed by Commit Bot
parent 3966891a6a
commit b3c03ff2ec
2 changed files with 14 additions and 1 deletions

View File

@ -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());

View File

@ -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;