diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-25 15:48:44 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-25 15:48:44 +0200 |
commit | 3ab6c7feee8126bdfc5c9ab9371db41102e12e95 (patch) | |
tree | a309c45826300b888238b6a517051fe7e71d63eb /dom/promise | |
parent | b18a9cf86ea25bc52d9cfea584e3aa8bfbe81f0a (diff) | |
parent | b069dabc91b7e0f5f8d161cdbe598276a21d6d68 (diff) | |
download | UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar.gz UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar.lz UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.tar.xz UXP-3ab6c7feee8126bdfc5c9ab9371db41102e12e95.zip |
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into pm_url_1
Diffstat (limited to 'dom/promise')
-rw-r--r-- | dom/promise/Promise.cpp | 27 | ||||
-rw-r--r-- | dom/promise/Promise.h | 19 |
2 files changed, 26 insertions, 20 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; } diff --git a/dom/promise/Promise.h b/dom/promise/Promise.h index f2ad3bd6c..642603a11 100644 --- a/dom/promise/Promise.h +++ b/dom/promise/Promise.h @@ -188,23 +188,26 @@ public: WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aWrapper); - // Do the equivalent of Promise.resolve in the current compartment of aCx. - // Errorrs are reported on the ErrorResult; if aRv comes back !Failed(), this - // function MUST return a non-null value. + // Do the equivalent of Promise.resolve in the compartment of aGlobal. The + // compartment of aCx is ignored. Errors are reported on the ErrorResult; if + // aRv comes back !Failed(), this function MUST return a non-null value. static already_AddRefed<Promise> Resolve(nsIGlobalObject* aGlobal, JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv); - // Do the equivalent of Promise.reject in the current compartment of aCx. - // Errorrs are reported on the ErrorResult; if aRv comes back !Failed(), this - // function MUST return a non-null value. + // Do the equivalent of Promise.reject in the compartment of aGlobal. The + // compartment of aCx is ignored. Errors are reported on the ErrorResult; if + // aRv comes back !Failed(), this function MUST return a non-null value. static already_AddRefed<Promise> Reject(nsIGlobalObject* aGlobal, JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv); + // Do the equivalent of Promise.all in the current compartment of aCx. Errors + // are reported on the ErrorResult; if aRv comes back !Failed(), this function + // MUST return a non-null value. static already_AddRefed<Promise> - All(const GlobalObject& aGlobal, - const nsTArray<RefPtr<Promise>>& aPromiseList, ErrorResult& aRv); + All(JSContext* aCx, const nsTArray<RefPtr<Promise>>& aPromiseList, + ErrorResult& aRv); void Then(JSContext* aCx, |