Bug 1379525 - Part 2: Properly handle rejection in async-from-sync iteration.

Tag #1287
This commit is contained in:
Gaming4JC 2019-12-14 10:32:39 -05:00 committed by Roy Tam
commit 586cd0b71b

View file

@ -2295,6 +2295,9 @@ static MOZ_MUST_USE bool
InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise,
HandleValue onFulfilled, HandleValue onRejected, T extraStep)
{
MOZ_ASSERT(onFulfilled.isNumber() || onFulfilled.isObject());
MOZ_ASSERT(onRejected.isNumber() || onRejected.isObject());
// Step 2.
Rooted<PromiseObject*> promise(cx, CreatePromiseObjectWithoutResolutionFunctions(cx));
if (!promise)
@ -2483,11 +2486,12 @@ js::AsyncFromSyncIteratorMethod(JSContext* cx, CallArgs& args, CompletionKind co
RootedValue onFulfilled(cx, Int32Value(done
? PromiseHandlerAsyncFromSyncIteratorValueUnwrapDone
: PromiseHandlerAsyncFromSyncIteratorValueUnwrapNotDone));
RootedValue onRejected(cx, Int32Value(PromiseHandlerThrower));
// Steps 11-12, 15.
auto extra = [](Handle<PromiseReactionRecord*> reaction) {
};
if (!InternalAwait(cx, value, resultPromise, onFulfilled, UndefinedHandleValue, extra))
if (!InternalAwait(cx, value, resultPromise, onFulfilled, onRejected, extra))
return false;
// Step 16.