From 5f14988ea29e4370374720a4fe676b3af855cba7 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Mon, 10 Mar 2014 12:31:32 +0100 Subject: [PATCH] Backed out changeset 670fb9adcd29 (bug 979481) --- js/src/jsfriendapi.cpp | 2 -- js/xpconnect/src/XPCJSContextStack.cpp | 5 ++++- js/xpconnect/src/nsCxPusher.cpp | 1 - js/xpconnect/src/nsCxPusher.h | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 6b8674b269f9..39cff8d39745 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -416,8 +416,6 @@ js::AssertSameCompartment(JSObject *objA, JSObject *objB) JS_FRIEND_API(JSObject *) js::DefaultObjectForContextOrNull(JSContext *cx) { - if (cx->options().noDefaultCompartmentObject()) - return nullptr; return cx->maybeDefaultCompartmentObject(); } diff --git a/js/xpconnect/src/XPCJSContextStack.cpp b/js/xpconnect/src/XPCJSContextStack.cpp index 25a204016cf6..88e2f9a4c7e3 100644 --- a/js/xpconnect/src/XPCJSContextStack.cpp +++ b/js/xpconnect/src/XPCJSContextStack.cpp @@ -175,7 +175,6 @@ XPCJSContextStack::InitSafeJSContext() if (!mSafeJSContext) MOZ_CRASH(); JSAutoRequest req(mSafeJSContext); - ContextOptionsRef(mSafeJSContext).setNoDefaultCompartmentObject(true); JS_SetErrorReporter(mSafeJSContext, xpc::SystemErrorReporter); @@ -188,6 +187,10 @@ 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 sp = new SandboxPrivate(principal, mSafeJSContextGlobal); diff --git a/js/xpconnect/src/nsCxPusher.cpp b/js/xpconnect/src/nsCxPusher.cpp index 202115104b17..153889931417 100644 --- a/js/xpconnect/src/nsCxPusher.cpp +++ b/js/xpconnect/src/nsCxPusher.cpp @@ -228,7 +228,6 @@ 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()) { } diff --git a/js/xpconnect/src/nsCxPusher.h b/js/xpconnect/src/nsCxPusher.h index d12fed24ccee..a01e12e2f630 100644 --- a/js/xpconnect/src/nsCxPusher.h +++ b/js/xpconnect/src/nsCxPusher.h @@ -100,6 +100,7 @@ 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. @@ -133,8 +134,6 @@ private: class MOZ_STACK_CLASS AutoSafeJSContext : public AutoJSContext { public: AutoSafeJSContext(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM); -private: - JSAutoCompartment mAc; }; /**