Bug 737780: fix compartments in nsFrameScriptExecutor::LoadFrameScriptInternal, r=luke, a=akeybl
authorDavid Mandelin <dmandelin@mozilla.com>
Mon, 02 Apr 2012 19:09:34 -0700
changeset 92080 d77279ec6accc3fba7517a3d06756d415270a330
parent 92079 a656a751c0556dc3c5c9ae4bb9d0525a4dadd821
child 92081 6456a42e0c9779feed4e209455242925d0e5bd8a
push idunknown
push userunknown
push dateunknown
reviewersluke, akeybl
bugs737780
milestone13.0a2
Bug 737780: fix compartments in nsFrameScriptExecutor::LoadFrameScriptInternal, r=luke, a=akeybl
content/base/src/nsFrameMessageManager.cpp
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -806,17 +806,18 @@ nsFrameScriptExecutor::LoadFrameScriptIn
   if (!dataString.IsEmpty()) {
     nsContentUtils::ThreadJSContextStack()->Push(mCx);
     {
       // Need to scope JSAutoRequest to happen after Push but before Pop,
       // at least for now. See bug 584673.
       JSAutoRequest ar(mCx);
       JSObject* global = nsnull;
       mGlobal->GetJSObject(&global);
-      if (global) {
+      JSAutoEnterCompartment ac;
+      if (global && ac.enter(mCx, global)) {
         uint32 oldopts = JS_GetOptions(mCx);
         JS_SetOptions(mCx, oldopts | JSOPTION_NO_SCRIPT_RVAL);
 
         JSScript* script =
           JS_CompileUCScriptForPrincipals(mCx, nsnull,
                                           nsJSPrincipals::get(mPrincipal),
                                           static_cast<const jschar*>(dataString.get()),
                                           dataString.Length(),