Bug 981218 - Remove the JSAutoCompartment from cx pushing. r=bobowen
authorBobby Holley <bobbyholley@gmail.com>
Thu, 21 Aug 2014 17:13:50 -0700
changeset 201099 32f80f97a32116a1d7d17f6a2a5be534ab41e310
parent 201098 543af9cd7448d28c386c353d917fc3b889472d94
child 201100 18ffee30e06a9c90ce52123749f59b25bbddd7c7
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbobowen
bugs981218
milestone34.0a1
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.
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
--- 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
 };