Set right compartment in ipc test shell (600022, r=jst).

This commit is contained in:
Andreas Gal
2010-09-30 00:14:37 -07:00
parent 91dbe03ebd
commit 494c149a04
2 changed files with 30 additions and 0 deletions

View File

@@ -609,6 +609,12 @@ ProcessFile(JSContext *cx,
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
if (!ac.enter(cx, obj)) {
NS_ERROR("Failed to enter compartment!");
return false;
}
JSScript* script =
JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
env->GetPrincipal());
@@ -630,6 +636,12 @@ ProcessFile(JSContext *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
* generates an error (before running out of source) or that compiles
@@ -1172,6 +1184,12 @@ XPCShellEnvironment::Init()
{
JSAutoRequest ar(cx);
JSAutoEnterCompartment ac;
if (!ac.enter(cx, globalObj)) {
NS_ERROR("Failed to enter compartment!");
return false;
}
if (!JS_DefineFunctions(cx, globalObj, gGlobalFunctions)) {
NS_ERROR("JS_DefineFunctions failed!");
return false;
@@ -1204,6 +1222,12 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
JSObject* global = GetGlobalObject();
JSAutoEnterCompartment ac;
if (!ac.enter(cx, global)) {
NS_ERROR("Failed to enter compartment!");
return false;
}
JSScript* script =
JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
aString.get(), aString.Length(),