Bug 1461292 part 2 - Rename JSAutoNullableCompartment to JSAutoNullableRealm. r=bz

This commit is contained in:
Jan de Mooij 2018-05-16 10:53:45 +02:00
parent 80e44e8003
commit 9cfbaa7e06
4 changed files with 14 additions and 15 deletions

View File

@ -357,7 +357,7 @@ AutoJSAPI::InitInternal(nsIGlobalObject* aGlobalObject, JSObject* aGlobal,
if (aGlobal) {
JS::ExposeObjectToActiveJS(aGlobal);
}
mAutoNullableCompartment.emplace(mCx, aGlobal);
mAutoNullableRealm.emplace(mCx, aGlobal);
ScriptSettingsStack::Push(this);
@ -556,11 +556,10 @@ AutoJSAPI::ReportException()
return;
}
// AutoJSAPI uses a JSAutoNullableCompartment, and may be in a null
// compartment when the destructor is called. However, the JS engine
// requires us to be in a realm when we fetch the pending exception.
// In this case, we enter the privileged junk scope and don't dispatch any
// error events.
// AutoJSAPI uses a JSAutoNullableRealm, and may be in a null realm
// when the destructor is called. However, the JS engine requires us
// to be in a realm when we fetch the pending exception. In this case,
// we enter the privileged junk scope and don't dispatch any error events.
JS::Rooted<JSObject*> errorGlobal(cx(), JS::CurrentGlobalOrNull(cx()));
if (!errorGlobal) {
if (mIsMainThread) {

View File

@ -294,7 +294,7 @@ protected:
AutoJSAPI(nsIGlobalObject* aGlobalObject, bool aIsMainThread, Type aType);
mozilla::Maybe<JSAutoRequest> mAutoRequest;
mozilla::Maybe<JSAutoNullableCompartment> mAutoNullableCompartment;
mozilla::Maybe<JSAutoNullableRealm> mAutoNullableRealm;
JSContext *mCx;
// Whether we're mainthread or not; set when we're initialized.

View File

@ -718,9 +718,9 @@ JSAutoRealm::~JSAutoRealm()
cx_->leaveCompartment(oldCompartment_);
}
JSAutoNullableCompartment::JSAutoNullableCompartment(JSContext* cx,
JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
JSAutoNullableRealm::JSAutoNullableRealm(JSContext* cx,
JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
{
@ -732,7 +732,7 @@ JSAutoNullableCompartment::JSAutoNullableCompartment(JSContext* cx,
cx_->enterNullCompartment();
}
JSAutoNullableCompartment::~JSAutoNullableCompartment()
JSAutoNullableRealm::~JSAutoNullableRealm()
{
cx_->leaveCompartment(oldCompartment_);
}

View File

@ -1298,14 +1298,14 @@ class MOZ_RAII JS_PUBLIC_API(JSAutoRealm)
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class MOZ_RAII JS_PUBLIC_API(JSAutoNullableCompartment)
class MOZ_RAII JS_PUBLIC_API(JSAutoNullableRealm)
{
JSContext* cx_;
JSCompartment* oldCompartment_;
public:
explicit JSAutoNullableCompartment(JSContext* cx, JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~JSAutoNullableCompartment();
explicit JSAutoNullableRealm(JSContext* cx, JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~JSAutoNullableRealm();
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};