Index: src/js/promise.js |
diff --git a/src/js/promise.js b/src/js/promise.js |
index c057238af696d78416a6198b3c0f68dabb8c31c1..32c6af15ce466f6f012df4d5eb1d6bb1fcc5bc81 100644 |
--- a/src/js/promise.js |
+++ b/src/js/promise.js |
@@ -12,6 +12,8 @@ |
// Imports |
var InternalArray = utils.InternalArray; |
+var promiseAwaitHandlerSymbol = |
+ utils.ImportNow("promise_await_handler_symbol"); |
var promiseCombinedDeferredSymbol = |
utils.ImportNow("promise_combined_deferred_symbol"); |
var promiseHasHandlerSymbol = |
@@ -22,6 +24,8 @@ var promiseFulfillReactionsSymbol = |
utils.ImportNow("promise_fulfill_reactions_symbol"); |
var promiseDeferredReactionsSymbol = |
utils.ImportNow("promise_deferred_reactions_symbol"); |
+var promiseHandledHintSymbol = |
+ utils.ImportNow("promise_handled_hint_symbol"); |
var promiseRawSymbol = utils.ImportNow("promise_raw_symbol"); |
var promiseStateSymbol = utils.ImportNow("promise_state_symbol"); |
var promiseResultSymbol = utils.ImportNow("promise_result_symbol"); |
@@ -381,16 +385,6 @@ function PromiseReject(r) { |
} |
} |
-function PromiseCastResolved(value) { |
- if (IsPromise(value)) { |
- return value; |
- } else { |
- var promise = PromiseInit(new GlobalPromise(promiseRawSymbol)); |
- var resolveResult = ResolvePromise(promise, value); |
- return promise; |
- } |
-} |
- |
function PerformPromiseThen(promise, onResolve, onReject, resultCapability) { |
if (!IS_CALLABLE(onResolve)) onResolve = PromiseIdResolveHandler; |
if (!IS_CALLABLE(onReject)) onReject = PromiseIdRejectHandler; |
@@ -543,6 +537,7 @@ function PromiseRace(iterable) { |
// Utility for debugger |
function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) { |
+ if (GET_PRIVATE(handler, promiseAwaitHandlerSymbol)) return false; |
if (handler !== PromiseIdRejectHandler) { |
var combinedDeferred = GET_PRIVATE(handler, promiseCombinedDeferredSymbol); |
if (IS_UNDEFINED(combinedDeferred)) return true; |
@@ -556,6 +551,8 @@ function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) { |
} |
function PromiseHasUserDefinedRejectHandlerRecursive(promise) { |
+ var handledHintSymbol = GET_PRIVATE(promise, promiseHandledHintSymbol); |
+ if (handledHintSymbol) return true; |
var queue = GET_PRIVATE(promise, promiseRejectReactionsSymbol); |
var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol); |
if (IS_UNDEFINED(queue)) return false; |
@@ -567,13 +564,15 @@ function PromiseHasUserDefinedRejectHandlerRecursive(promise) { |
return true; |
} |
} |
+ return false; |
} |
- return false; |
} |
// Return whether the promise will be handled by a user-defined reject |
// handler somewhere down the promise chain. For this, we do a depth-first |
// search for a reject handler that's not the default PromiseIdRejectHandler. |
+// If the Promise was awaited as part of async/await, then an associated |
+// dependency graph is traversed. |
function PromiseHasUserDefinedRejectHandler() { |
return PromiseHasUserDefinedRejectHandlerRecursive(this); |
}; |
@@ -623,12 +622,14 @@ utils.InstallFunctions(extrasUtils, 0, [ |
]); |
utils.Export(function(to) { |
- to.PromiseCastResolved = PromiseCastResolved; |
+ to.IsPromise = IsPromise; |
+ to.PromiseCreate = PromiseCreate; |
to.PromiseThen = PromiseThen; |
to.GlobalPromise = GlobalPromise; |
to.NewPromiseCapability = NewPromiseCapability; |
to.PerformPromiseThen = PerformPromiseThen; |
+ to.ResolvePromise = ResolvePromise; |
to.RejectPromise = RejectPromise; |
}); |