Bug 1004766. Make sure to enter the compartment of our new global before working with it when wrapping global objects. r=nsm
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 03 May 2014 01:08:07 -0400
changeset 181817 a4d2747c511a32bbad28f37affcf72754d76ccad
parent 181816 bb50d61e7777360430155b246dc89b4c8da2902b
child 181818 4c874962ee0205a28cf3f94c4462950039aa5570
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersnsm
bugs1004766
milestone32.0a1
Bug 1004766. Make sure to enter the compartment of our new global before working with it when wrapping global objects. r=nsm
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2961,16 +2961,19 @@ class CGWrapGlobalMethod(CGAbstractMetho
               JS::Rooted<JSObject*> obj(aCx);
               obj = CreateGlobal<${nativeType}, GetProtoObject>(aCx,
                                                      aObject,
                                                      aCache,
                                                      Class.ToJSClass(),
                                                      aOptions,
                                                      aPrincipal);
 
+              // obj is a new global, so has a new compartment.  Enter it
+              // before doing anything with it.
+              JSAutoCompartment ac(aCx, obj);
               $*{unforgeable}
 
               $*{slots}
 
               // XXXkhuey can't do this yet until workers can lazy resolve.
               // JS_FireOnNewGlobalObject(aCx, obj);
 
               return obj;