Bug 600580 - TM: set right compartment in _newJSDContext r=gwagner
authorAndreas Gal<gal@uci.edu>
Wed, 29 Sep 2010 23:32:22 -0700
changeset 54849 5d6dda5e62daa114c2fc5038859122084e204615
parent 54848 861b91b0a9eb38fb364a7e6174b0e9e6cef131f8
child 54851 ba8acd80e51bb90e3d7100f4fbf6ca7fd0ec11b3
push idunknown
push userunknown
push dateunknown
reviewersgwagner
bugs600580
milestone2.0b7pre
Bug 600580 - TM: set right compartment in _newJSDContext r=gwagner
js/jsd/jsd_high.c
--- a/js/jsd/jsd_high.c
+++ b/js/jsd/jsd_high.c
@@ -134,28 +134,31 @@ static JSDContext*
         goto label_newJSDContext_failure;
 
     jsdc->dumbContext = JS_NewContext(jsdc->jsrt, 256);
     if( ! jsdc->dumbContext )
         goto label_newJSDContext_failure;
 
     JS_BeginRequest(jsdc->dumbContext);
 
-    if( scopeobj )
-        call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, scopeobj);
-    jsdc->glob = JS_NewGlobalObject(jsdc->dumbContext, &global_class);
-    if( call )
-        JS_LeaveCrossCompartmentCall(call);
+    jsdc->glob = JS_NewCompartmentAndGlobalObject(jsdc->dumbContext, &global_class, NULL);
 
     if( ! jsdc->glob )
         goto label_newJSDContext_failure;
 
+    call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, jsdc->glob);
+    if( ! call )
+        goto label_newJSDContext_failure;
+
     if( ! JS_InitStandardClasses(jsdc->dumbContext, jsdc->glob) )
         goto label_newJSDContext_failure;
 
+    if( call )
+        JS_LeaveCrossCompartmentCall(call);
+
     JS_EndRequest(jsdc->dumbContext);
 
     jsdc->data = NULL;
     jsdc->inited = JS_TRUE;
 
     JSD_LOCK();
     JS_INSERT_LINK(&jsdc->links, &_jsd_context_list);
     JSD_UNLOCK();