Bug 981218 - Remove the JSAutoCompartment from cx pushing. r=bobowen
By this point, AutoJSAPI takes care of entering the correct compartment, so this
no longer serves a purpose.
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -403,29 +403,22 @@ danger::AutoCxPusher::AutoCxPusher(JSCon
mPushedContext = cx;
mCompartmentDepthOnEntry = cx ? js::GetEnterCompartmentDepth(cx) : 0;
#endif
// Enter a request and a compartment for the duration that the cx is on the
// stack if non-null.
if (cx) {
mAutoRequest.emplace(cx);
-
- // DOM JSContexts don't store their default compartment object on the cx.
- JSObject *compartmentObject = mScx ? mScx->GetWindowProxy()
- : js::DefaultObjectForContextOrNull(cx);
- if (compartmentObject)
- mAutoCompartment.emplace(cx, compartmentObject);
}
}
danger::AutoCxPusher::~AutoCxPusher()
{
- // Leave the compartment and request before popping.
- mAutoCompartment.reset();
+ // Leave the request before popping.
mAutoRequest.reset();
// When we push a context, we may save the frame chain and pretend like we
// haven't entered any compartment. This gets restored on Pop(), but we can
// run into trouble if a Push/Pop are interleaved with a
// JSAutoEnterCompartment. Make sure the compartment depth right before we
// pop is the same as it was right after we pushed.
MOZ_ASSERT_IF(mPushedContext, mCompartmentDepthOnEntry ==
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -41,17 +41,16 @@ public:
nsIScriptContext* GetScriptContext() { return mScx; }
// Returns true if this AutoCxPusher performed the push that is currently at
// the top of the cx stack.
bool IsStackTop() const;
private:
mozilla::Maybe<JSAutoRequest> mAutoRequest;
- mozilla::Maybe<JSAutoCompartment> mAutoCompartment;
nsCOMPtr<nsIScriptContext> mScx;
uint32_t mStackDepthAfterPush;
#ifdef DEBUG
JSContext* mPushedContext;
unsigned mCompartmentDepthOnEntry;
#endif
};