summaryrefslogtreecommitdiffstats
path: root/dom/promise/Promise.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/promise/Promise.cpp')
-rw-r--r--dom/promise/Promise.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp
index 00b78143e..557f3a1f9 100644
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -561,37 +561,40 @@ Promise::Reject(nsIGlobalObject* aGlobal, JSContext* aCx,
// static
already_AddRefed<Promise>
-Promise::All(const GlobalObject& aGlobal,
+Promise::All(JSContext* aCx,
const nsTArray<RefPtr<Promise>>& aPromiseList, ErrorResult& aRv)
{
- nsCOMPtr<nsIGlobalObject> global;
- global = do_QueryInterface(aGlobal.GetAsSupports());
- if (!global) {
+ JS::Rooted<JSObject*> globalObj(aCx, JS::CurrentGlobalOrNull(aCx));
+ if (!globalObj) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
- JSContext* cx = aGlobal.Context();
+ nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(globalObj);
+ if (!global) {
+ aRv.Throw(NS_ERROR_UNEXPECTED);
+ return nullptr;
+ }
- JS::AutoObjectVector promises(cx);
+ JS::AutoObjectVector promises(aCx);
if (!promises.reserve(aPromiseList.Length())) {
- aRv.NoteJSContextException(cx);
+ aRv.NoteJSContextException(aCx);
return nullptr;
}
for (auto& promise : aPromiseList) {
- JS::Rooted<JSObject*> promiseObj(cx, promise->PromiseObj());
+ JS::Rooted<JSObject*> promiseObj(aCx, promise->PromiseObj());
// Just in case, make sure these are all in the context compartment.
- if (!JS_WrapObject(cx, &promiseObj)) {
- aRv.NoteJSContextException(cx);
+ if (!JS_WrapObject(aCx, &promiseObj)) {
+ aRv.NoteJSContextException(aCx);
return nullptr;
}
promises.infallibleAppend(promiseObj);
}
- JS::Rooted<JSObject*> result(cx, JS::GetWaitForAllPromise(cx, promises));
+ JS::Rooted<JSObject*> result(aCx, JS::GetWaitForAllPromise(aCx, promises));
if (!result) {
- aRv.NoteJSContextException(cx);
+ aRv.NoteJSContextException(aCx);
return nullptr;
}