summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJeremy Andrews <athenian200@outlook.com>2021-07-15 03:08:11 -0500
committerJeremy Andrews <athenian200@outlook.com>2021-07-15 03:08:11 -0500
commit82ec475ddf8f6b644cb30996684d5d0f3294661f (patch)
tree4c7f51653f183b12fb53b9e264b113fb3c38d1cb /js
parent2c9942895bd9d7302d741561c2bef775642f72fa (diff)
downloadaura-central-82ec475ddf8f6b644cb30996684d5d0f3294661f.tar.gz
Issue mcp-graveyard/UXP%1725 - Fix logic in PerformPromiseAllSettled.
This function essentially appears to work as written, there was an issue with it returning false too early in some situations that prevented it from working properly.
Diffstat (limited to 'js')
-rw-r--r--js/src/builtin/Promise.cpp59
1 files changed, 31 insertions, 28 deletions
diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
index 8ead6d9e7..faba01095 100644
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -1963,40 +1963,43 @@ PerformPromiseAllSettled(JSContext *cx, JS::ForOfIterator& iterator, HandleObjec
RootedValue nextPromise(cx);
RootedValue staticResolve(cx);
- if (!GetProperty(cx, CVal, cx->names().resolve, &staticResolve))
- return false;
- RootedValue staticReject(cx);
- if (!GetProperty(cx, CVal, cx->names().reject, &staticReject))
+ RootedValue staticReject(cx);
+
+ // Because Promise.allSettled can continue whether the promise is fulfilled or rejected, we
+ // should only return false if neither condition is true.
+
+ if (!GetProperty(cx, CVal, cx->names().resolve, &staticResolve) &&
+ !GetProperty(cx, CVal, cx->names().reject, &staticReject))
return false;
FixedInvokeArgs<1> resolveArgs(cx);
resolveArgs[0].set(nextValue);
- if (!Call(cx, staticResolve, CVal, resolveArgs, &nextPromise))
- return false;
FixedInvokeArgs<1> rejectArgs(cx);
rejectArgs[0].set(nextValue);
- if (!Call(cx, staticReject, CVal, rejectArgs, &nextPromise))
- return false;
-
- RootedFunction resolveFunc(cx, NewNativeFunction(cx, PromiseAllSettledResolveElementFunction,
- 1, nullptr,
- gc::AllocKind::FUNCTION_EXTENDED,
- GenericObject));
- if (!resolveFunc)
- return false;
- RootedFunction rejectFunc(cx, NewNativeFunction(cx, PromiseAllSettledRejectElementFunction,
- 1, nullptr,
- gc::AllocKind::FUNCTION_EXTENDED,
- GenericObject));
- if (!rejectFunc)
- return false;
-
- resolveFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_Data, dataHolderVal);
- resolveFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_ElementIndex,
- Int32Value(index));
- rejectFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_Data, dataHolderVal);
- rejectFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_ElementIndex,
- Int32Value(index));
+ if (!Call(cx, staticResolve, CVal, resolveArgs, &nextPromise) &&
+ !Call(cx, staticReject, CVal, rejectArgs, &nextPromise))
+ return false;
+
+
+ RootedFunction resolveFunc(cx, NewNativeFunction(cx, PromiseAllSettledResolveElementFunction,
+ 1, nullptr,
+ gc::AllocKind::FUNCTION_EXTENDED,
+ GenericObject));
+
+ RootedFunction rejectFunc(cx, NewNativeFunction(cx, PromiseAllSettledRejectElementFunction,
+ 1, nullptr,
+ gc::AllocKind::FUNCTION_EXTENDED,
+ GenericObject));
+ if (!resolveFunc && !rejectFunc) {
+ return false;
+ }
+
+ resolveFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_Data, dataHolderVal);
+ resolveFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_ElementIndex,
+ Int32Value(index));
+ rejectFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_Data, dataHolderVal);
+ rejectFunc->setExtendedSlot(PromiseAllResolveElementFunctionSlot_ElementIndex,
+ Int32Value(index));
dataHolder->increaseRemainingCount();