Bug 1379525 - Part 2: Properly handle rejection in async-from-sync iteration. r=shu
authorTooru Fujisawa <arai_a@mac.com>
Fri, 04 Aug 2017 13:04:31 +0900
changeset 422549 a7128448688ccf97e31048c912f4d5dabe15f628
parent 422548 a91dd87054d373849bdd6a3d5a26710b453164e0
child 422550 ab81d3d87d875cd6759e07b59a7834b7681e6f12
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1379525
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1379525 - Part 2: Properly handle rejection in async-from-sync iteration. r=shu
js/src/builtin/Promise.cpp
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -2294,16 +2294,19 @@ js::AsyncFunctionReturned(JSContext* cx,
 
 // Helper function that performs the equivalent steps as
 // Async Iteration proposal 4.1 Await steps 2-3, 6-9 or similar.
 template <typename T>
 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)
         return false;
 
     // Step 3.
     if (!ResolvePromiseInternal(cx, promise, value))
         return false;
@@ -2482,21 +2485,22 @@ js::AsyncFromSyncIteratorMethod(JSContex
     RootedValue value(cx);
     if (!GetProperty(cx, resultObj, resultObj, cx->names().value, &value))
         return AbruptRejectPromise(cx, args, resultPromise, nullptr);
 
     // Steps 13-14.
     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.
     args.rval().setObject(*resultPromise);
     return true;
 }
 
 static MOZ_MUST_USE bool