diff --git a/js/jetpack/JetpackChild.cpp b/js/jetpack/JetpackChild.cpp index ffc6a7b6e09e..32218a7134d3 100644 --- a/js/jetpack/JetpackChild.cpp +++ b/js/jetpack/JetpackChild.cpp @@ -111,7 +111,7 @@ JetpackChild::Init(base::ProcessHandle aParentProcessHandle, JSAutoRequest request(mCx); JS_SetContextPrivate(mCx, this); JSObject* implGlobal = - JS_NewGlobalObject(mCx, const_cast(&sGlobalClass)); + JS_NewCompartmentAndGlobalObject(mCx, const_cast(&sGlobalClass), NULL); if (!implGlobal || !JS_InitStandardClasses(mCx, implGlobal) || !JS_DefineFunctions(mCx, implGlobal, @@ -396,10 +396,14 @@ JetpackChild::CreateSandbox(JSContext* cx, uintN argc, jsval* vp) return JS_FALSE; } - JSObject* obj = JS_NewGlobalObject(cx, const_cast(&sGlobalClass)); + JSObject* obj = JS_NewCompartmentAndGlobalObject(cx, const_cast(&sGlobalClass), NULL); if (!obj) return JS_FALSE; + JSAutoCrossCompartmentCall ac; + if (!ac.enter(cx, obj)) + return JS_FALSE; + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); return JS_InitStandardClasses(cx, obj); } @@ -427,6 +431,10 @@ JetpackChild::EvalInSandbox(JSContext* cx, uintN argc, jsval* vp) if (!str) return JS_FALSE; + JSAutoCrossCompartmentCall ac; + if (!ac.enter(cx, obj)) + return JS_FALSE; + js::AutoValueRooter ignored(cx); return JS_EvaluateUCScript(cx, obj, JS_GetStringChars(str), JS_GetStringLength(str), "", 1, ignored.jsval_addr());