Bug 604341 - Ensure that we're in the right compartment when we create plugin objects' wrapper JS objects. r=jst a=blocking beta 7
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 25 Oct 2010 12:18:20 -0700
changeset 56592 cf8e99750fb658158372447834d1b5aa29df5a56
parent 56591 9a1a2c464ac29ea7614739655604e0d6ea79f431
child 56593 4e4f70452d86f53d05515fc7bb1d84fe4fcdc7a5
push id16602
push userrsayre@mozilla.com
push dateWed, 27 Oct 2010 01:10:03 +0000
treeherdermozilla-central@7b83033bb6f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst, blocking
bugs604341
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 604341 - Ensure that we're in the right compartment when we create plugin objects' wrapper JS objects. r=jst a=blocking beta 7
dom/base/nsDOMClassInfo.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -9750,16 +9750,24 @@ nsHTMLPluginObjElementSH::GetPluginJSObj
                                             JSObject **plugin_obj,
                                             JSObject **plugin_proto)
 {
   *plugin_obj = nsnull;
   *plugin_proto = nsnull;
 
   JSAutoRequest ar(cx);
 
+  // NB: We need an AutoEnterCompartment because we can be called from
+  // nsObjectFrame when the plugin loads after the JS object for our content
+  // node has been created.
+  JSAutoEnterCompartment ac;
+  if (!ac.enter(cx, obj)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
   if (plugin_inst) {
     plugin_inst->GetJSObject(cx, plugin_obj);
     if (*plugin_obj) {
       *plugin_proto = ::JS_GetPrototype(cx, *plugin_obj);
     }
   }
 
   return NS_OK;