Set right compartment in ipc test shell (600022, r=jst).
This commit is contained in:
@@ -122,6 +122,12 @@ TestShellCommandParent::RunCallback(const nsString& aResponse)
|
|||||||
JSObject* global = JS_GetGlobalObject(mCx);
|
JSObject* global = JS_GetGlobalObject(mCx);
|
||||||
NS_ENSURE_TRUE(global, JS_FALSE);
|
NS_ENSURE_TRUE(global, JS_FALSE);
|
||||||
|
|
||||||
|
JSAutoEnterCompartment ac;
|
||||||
|
if (!ac.enter(cx, global)) {
|
||||||
|
NS_ERROR("Failed to enter compartment!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
JSString* str = JS_NewUCStringCopyN(mCx, aResponse.get(), aResponse.Length());
|
JSString* str = JS_NewUCStringCopyN(mCx, aResponse.get(), aResponse.Length());
|
||||||
NS_ENSURE_TRUE(str, JS_FALSE);
|
NS_ENSURE_TRUE(str, JS_FALSE);
|
||||||
|
|
||||||
|
|||||||
@@ -609,6 +609,12 @@ ProcessFile(JSContext *cx,
|
|||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
|
JSAutoEnterCompartment ac;
|
||||||
|
if (!ac.enter(cx, obj)) {
|
||||||
|
NS_ERROR("Failed to enter compartment!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
JSScript* script =
|
JSScript* script =
|
||||||
JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
|
JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
|
||||||
env->GetPrincipal());
|
env->GetPrincipal());
|
||||||
@@ -630,6 +636,12 @@ ProcessFile(JSContext *cx,
|
|||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
|
JSAutoEnterCompartment ac;
|
||||||
|
if (!ac.enter(cx, obj)) {
|
||||||
|
NS_ERROR("Failed to enter compartment!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accumulate lines until we get a 'compilable unit' - one that either
|
* Accumulate lines until we get a 'compilable unit' - one that either
|
||||||
* generates an error (before running out of source) or that compiles
|
* generates an error (before running out of source) or that compiles
|
||||||
@@ -1172,6 +1184,12 @@ XPCShellEnvironment::Init()
|
|||||||
{
|
{
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
|
JSAutoEnterCompartment ac;
|
||||||
|
if (!ac.enter(cx, globalObj)) {
|
||||||
|
NS_ERROR("Failed to enter compartment!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!JS_DefineFunctions(cx, globalObj, gGlobalFunctions)) {
|
if (!JS_DefineFunctions(cx, globalObj, gGlobalFunctions)) {
|
||||||
NS_ERROR("JS_DefineFunctions failed!");
|
NS_ERROR("JS_DefineFunctions failed!");
|
||||||
return false;
|
return false;
|
||||||
@@ -1204,6 +1222,12 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
|
|||||||
|
|
||||||
JSObject* global = GetGlobalObject();
|
JSObject* global = GetGlobalObject();
|
||||||
|
|
||||||
|
JSAutoEnterCompartment ac;
|
||||||
|
if (!ac.enter(cx, global)) {
|
||||||
|
NS_ERROR("Failed to enter compartment!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
JSScript* script =
|
JSScript* script =
|
||||||
JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
|
JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
|
||||||
aString.get(), aString.Length(),
|
aString.get(), aString.Length(),
|
||||||
|
|||||||
Reference in New Issue
Block a user