mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 979481 - Make the SafeJSContext default to a null compartment, and have AutoSafeJSContext enter the compartment instead. r=bz
This commit is contained in:
parent
b999e7ea65
commit
655ad8ddf4
@ -412,6 +412,8 @@ js::AssertSameCompartment(JSObject *objA, JSObject *objB)
|
||||
JS_FRIEND_API(JSObject *)
|
||||
js::DefaultObjectForContextOrNull(JSContext *cx)
|
||||
{
|
||||
if (cx->options().noDefaultCompartmentObject())
|
||||
return nullptr;
|
||||
return cx->maybeDefaultCompartmentObject();
|
||||
}
|
||||
|
||||
|
@ -175,6 +175,7 @@ XPCJSContextStack::InitSafeJSContext()
|
||||
if (!mSafeJSContext)
|
||||
MOZ_CRASH();
|
||||
JSAutoRequest req(mSafeJSContext);
|
||||
ContextOptionsRef(mSafeJSContext).setNoDefaultCompartmentObject(true);
|
||||
|
||||
JS_SetErrorReporter(mSafeJSContext, xpc::SystemErrorReporter);
|
||||
|
||||
@ -187,10 +188,6 @@ XPCJSContextStack::InitSafeJSContext()
|
||||
MOZ_CRASH();
|
||||
JS_AddNamedObjectRoot(mSafeJSContext, &mSafeJSContextGlobal, "SafeJSContext global");
|
||||
|
||||
// Make sure the context is associated with a proper compartment
|
||||
// and not the default compartment.
|
||||
js::SetDefaultObjectForContext(mSafeJSContext, mSafeJSContextGlobal);
|
||||
|
||||
// Note: make sure to set the private before calling
|
||||
// InitClasses
|
||||
nsRefPtr<SandboxPrivate> sp = new SandboxPrivate(principal, mSafeJSContextGlobal);
|
||||
|
@ -228,6 +228,7 @@ ThreadsafeAutoJSContext::operator JSContext*() const
|
||||
|
||||
AutoSafeJSContext::AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
|
||||
: AutoJSContext(true MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT)
|
||||
, mAc(mCx, XPCJSRuntime::Get()->GetJSContextStack()->GetSafeJSContextGlobal())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ public:
|
||||
protected:
|
||||
AutoJSContext(bool aSafe MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
|
||||
|
||||
private:
|
||||
// We need this Init() method because we can't use delegating constructor for
|
||||
// the moment. It is a C++11 feature and we do not require C++11 to be
|
||||
// supported to be able to compile Gecko.
|
||||
@ -134,6 +133,8 @@ private:
|
||||
class MOZ_STACK_CLASS AutoSafeJSContext : public AutoJSContext {
|
||||
public:
|
||||
AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
|
||||
private:
|
||||
JSAutoCompartment mAc;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user