diff --git a/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/js/src/xpconnect/loader/mozJSComponentLoader.cpp index 60d4d0fb7fb..119ce84796a 100644 --- a/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -1363,9 +1363,20 @@ mozJSComponentLoader::Import(const nsACString & registryLocation) targetObject = JS_GetGlobalForObject(cx, targetObject); } + JSAutoEnterCompartment ac; + if (!ac.enter(cx, targetObject)) { + NS_ERROR("can't enter compartment"); + return NS_ERROR_FAILURE; + } + JSObject *globalObj = nsnull; rv = ImportInto(registryLocation, targetObject, cc, &globalObj); + if (!JS_WrapObject(cx, &globalObj)) { + NS_ERROR("can't wrap return value"); + return NS_ERROR_FAILURE; + } + jsval *retval = nsnull; cc->GetRetValPtr(&retval); if (retval) diff --git a/js/src/xpconnect/src/xpcwrappednativejsops.cpp b/js/src/xpconnect/src/xpcwrappednativejsops.cpp index f96cf34e4b0..3a0d49c89f0 100644 --- a/js/src/xpconnect/src/xpcwrappednativejsops.cpp +++ b/js/src/xpconnect/src/xpcwrappednativejsops.cpp @@ -186,6 +186,10 @@ GetDoubleWrappedJSObject(XPCCallContext& ccx, XPCWrappedNative* wrapper) jsid id = ccx.GetRuntime()-> GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT); + JSAutoEnterCompartment ac; + if(!ac.enter(ccx, mainObj)) + return NULL; + jsval val; if(JS_GetPropertyById(ccx, mainObj, id, &val) && !JSVAL_IS_PRIMITIVE(val)) @@ -258,7 +262,7 @@ XPC_WN_DoubleWrappedGetter(JSContext *cx, uintN argc, jsval *vp) } } *vp = OBJECT_TO_JSVAL(realObject); - return JS_TRUE; + return JS_WrapValue(cx, vp); } /***************************************************************************/