mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Bug 1257725 part 3. Get rid of ThreadsafeAutoJSContext usage in Promise code. r=bholley
This commit is contained in:
parent
4a64ef833e
commit
7d81d282f7
@ -79,10 +79,14 @@ protected:
|
||||
Run() override
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(PromiseReactionJob);
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> wrapper(cx, mPromise->GetWrapper());
|
||||
MOZ_ASSERT(wrapper); // It was preserved!
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
|
||||
MOZ_ASSERT(mPromise->GetWrapper()); // It was preserved!
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(mPromise->GetWrapper())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::Rooted<JS::Value> value(cx, mValue);
|
||||
if (!MaybeWrapValue(cx, &value)) {
|
||||
@ -205,12 +209,16 @@ protected:
|
||||
Run() override
|
||||
{
|
||||
NS_ASSERT_OWNINGTHREAD(PromiseResolveThenableJob);
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> wrapper(cx, mPromise->GetWrapper());
|
||||
MOZ_ASSERT(wrapper); // It was preserved!
|
||||
|
||||
MOZ_ASSERT(mPromise->GetWrapper()); // It was preserved!
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
// If we ever change which compartment we're working in here, make sure to
|
||||
// fix the fast-path for resolved-with-a-Promise in ResolveInternal.
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
if (!jsapi.Init(mPromise->GetWrapper())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::Rooted<JSObject*> resolveFunc(cx,
|
||||
mPromise->CreateThenableFunction(cx, mPromise, PromiseCallback::Resolve));
|
||||
|
@ -422,11 +422,14 @@ private:
|
||||
|
||||
template <typename T>
|
||||
void MaybeSomething(T& aArgument, MaybeFunc aFunc) {
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JSObject* wrapper = PromiseObj();
|
||||
MOZ_ASSERT(wrapper); // We preserved it!
|
||||
MOZ_ASSERT(PromiseObj()); // It was preserved!
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
if (!jsapi.Init(mGlobal)) {
|
||||
return;
|
||||
}
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JS::Rooted<JS::Value> val(cx);
|
||||
if (!ToJSValue(cx, aArgument, &val)) {
|
||||
HandleException(cx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user