mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Backed out changeset 91406356569c (bug 1453339) for landing without review.
This commit is contained in:
parent
0b8872867b
commit
effc958e89
@ -395,6 +395,8 @@ nsFrameLoader::FireWillChangeProcessEvent()
|
||||
return nullptr;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
GlobalObject global(cx, mOwnerContent->GetOwnerGlobal()->GetGlobalJSObject());
|
||||
MOZ_ASSERT(!global.Failed());
|
||||
|
||||
// Set our mBrowserChangingProcessBlockers property to refer to the blockers
|
||||
// list. We will synchronously dispatch a DOM event to collect this list of
|
||||
@ -416,7 +418,7 @@ nsFrameLoader::FireWillChangeProcessEvent()
|
||||
mBrowserChangingProcessBlockers = nullptr;
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> allPromise = Promise::All(cx, blockers, rv);
|
||||
RefPtr<Promise> allPromise = Promise::All(global, blockers, rv);
|
||||
return allPromise.forget();
|
||||
}
|
||||
|
||||
|
2
dom/cache/Cache.cpp
vendored
2
dom/cache/Cache.cpp
vendored
@ -630,7 +630,7 @@ Cache::AddAll(const GlobalObject& aGlobal,
|
||||
new FetchHandler(mActor->GetWorkerHolder(), this,
|
||||
Move(aRequestList), promise);
|
||||
|
||||
RefPtr<Promise> fetchPromise = Promise::All(aGlobal.Context(), fetchList, aRv);
|
||||
RefPtr<Promise> fetchPromise = Promise::All(aGlobal, fetchList, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -135,40 +135,37 @@ Promise::Reject(nsIGlobalObject* aGlobal, JSContext* aCx,
|
||||
|
||||
// static
|
||||
already_AddRefed<Promise>
|
||||
Promise::All(JSContext* aCx,
|
||||
Promise::All(const GlobalObject& aGlobal,
|
||||
const nsTArray<RefPtr<Promise>>& aPromiseList, ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> globalObj(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||
if (!globalObj) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(globalObj);
|
||||
nsCOMPtr<nsIGlobalObject> global;
|
||||
global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!global) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::AutoObjectVector promises(aCx);
|
||||
JSContext* cx = aGlobal.Context();
|
||||
|
||||
JS::AutoObjectVector promises(cx);
|
||||
if (!promises.reserve(aPromiseList.Length())) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
aRv.NoteJSContextException(cx);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (auto& promise : aPromiseList) {
|
||||
JS::Rooted<JSObject*> promiseObj(aCx, promise->PromiseObj());
|
||||
JS::Rooted<JSObject*> promiseObj(cx, promise->PromiseObj());
|
||||
// Just in case, make sure these are all in the context compartment.
|
||||
if (!JS_WrapObject(aCx, &promiseObj)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
if (!JS_WrapObject(cx, &promiseObj)) {
|
||||
aRv.NoteJSContextException(cx);
|
||||
return nullptr;
|
||||
}
|
||||
promises.infallibleAppend(promiseObj);
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> result(aCx, JS::GetWaitForAllPromise(aCx, promises));
|
||||
JS::Rooted<JSObject*> result(cx, JS::GetWaitForAllPromise(cx, promises));
|
||||
if (!result) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
aRv.NoteJSContextException(cx);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -111,26 +111,23 @@ public:
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
static already_AddRefed<Promise>
|
||||
Resolve(nsIGlobalObject* aGlobal, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv);
|
||||
|
||||
// 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.
|
||||
// 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.
|
||||
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(JSContext* aCx, const nsTArray<RefPtr<Promise>>& aPromiseList,
|
||||
ErrorResult& aRv);
|
||||
All(const GlobalObject& aGlobal,
|
||||
const nsTArray<RefPtr<Promise>>& aPromiseList, ErrorResult& aRv);
|
||||
|
||||
void
|
||||
Then(JSContext* aCx,
|
||||
|
@ -346,7 +346,17 @@ FontFaceSet::Load(JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
return Promise::All(aCx, promises, aRv);
|
||||
nsIGlobalObject* globalObject = GetParentObject();
|
||||
if (!globalObject) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> jsGlobal(aCx, globalObject->GetGlobalJSObject());
|
||||
GlobalObject global(aCx, jsGlobal);
|
||||
|
||||
RefPtr<Promise> result = Promise::All(global, promises, aRv);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user