зеркало из https://github.com/mozilla/pjs.git
Bug 600032 - TM: set right compartment for Jetpack r=gregor
This commit is contained in:
Родитель
f6d77b2ef3
Коммит
6f74059342
|
@ -137,9 +137,15 @@ JetpackChild::Init(base::ProcessHandle aParentProcessHandle,
|
|||
JS_SetContextPrivate(mCx, this);
|
||||
JSObject* implGlobal =
|
||||
JS_NewCompartmentAndGlobalObject(mCx, const_cast<JSClass*>(&sGlobalClass), NULL);
|
||||
if (!implGlobal)
|
||||
return false;
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(mCx, implGlobal))
|
||||
return false;
|
||||
|
||||
jsval ctypes;
|
||||
if (!implGlobal ||
|
||||
!JS_InitStandardClasses(mCx, implGlobal) ||
|
||||
if (!JS_InitStandardClasses(mCx, implGlobal) ||
|
||||
#ifdef BUILD_CTYPES
|
||||
!JS_InitCTypesClass(mCx, implGlobal) ||
|
||||
!JS_GetProperty(mCx, implGlobal, "ctypes", &ctypes) ||
|
||||
|
@ -173,6 +179,12 @@ JetpackChild::RecvSendMessage(const nsString& messageName,
|
|||
const nsTArray<Variant>& data)
|
||||
{
|
||||
JSAutoRequest request(mCx);
|
||||
|
||||
JSObject *global = JS_GetGlobalObject(mCx);
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(mCx, global))
|
||||
return false;
|
||||
|
||||
return JetpackActorCommon::RecvMessage(mCx, messageName, data, NULL);
|
||||
}
|
||||
|
||||
|
@ -181,9 +193,14 @@ JetpackChild::RecvEvalScript(const nsString& code)
|
|||
{
|
||||
JSAutoRequest request(mCx);
|
||||
|
||||
js::AutoValueRooter ignored(mCx);
|
||||
(void) JS_EvaluateUCScript(mCx, JS_GetGlobalObject(mCx), code.get(),
|
||||
code.Length(), "", 1, ignored.jsval_addr());
|
||||
JSObject *global = JS_GetGlobalObject(mCx);
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(mCx, global))
|
||||
return false;
|
||||
|
||||
jsval ignored;
|
||||
(void) JS_EvaluateUCScript(mCx, global, code.get(),
|
||||
code.Length(), "", 1, &ignored);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,10 @@ JetpackParent::SendMessage(const nsAString& aMessageName)
|
|||
|
||||
JSAutoRequest request(cx);
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, JS_GetGlobalObject(cx)))
|
||||
return false;
|
||||
|
||||
for (PRUint32 i = 1; i < argc; ++i)
|
||||
if (!jsval_to_Variant(cx, argv[i], data.AppendElement()))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -162,6 +166,11 @@ JetpackParent::RecvSendMessage(const nsString& messageName,
|
|||
{
|
||||
AutoCXPusher cxp(mContext);
|
||||
JSAutoRequest request(mContext);
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(mContext, JS_GetGlobalObject(mContext)))
|
||||
return false;
|
||||
|
||||
return JetpackActorCommon::RecvMessage(mContext, messageName, data, NULL);
|
||||
}
|
||||
|
||||
|
@ -172,6 +181,11 @@ JetpackParent::AnswerCallMessage(const nsString& messageName,
|
|||
{
|
||||
AutoCXPusher cxp(mContext);
|
||||
JSAutoRequest request(mContext);
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(mContext, JS_GetGlobalObject(mContext)))
|
||||
return false;
|
||||
|
||||
return JetpackActorCommon::RecvMessage(mContext, messageName, data, results);
|
||||
}
|
||||
|
||||
|
@ -188,6 +202,10 @@ JetpackParent::CreateHandle(nsIVariant** aResult)
|
|||
|
||||
JSAutoRequest request(mContext);
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(mContext, JS_GetGlobalObject(mContext)))
|
||||
return false;
|
||||
|
||||
JSObject* hobj = handle->ToJSObject(mContext);
|
||||
if (!hobj)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче