bug 313220: Push the sandbox's context onto the context stack so that functions that need to use the current fp can find it. r=brendan sr=shaver a=asa

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@184077 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mrbkap%gmail.com
2005-11-03 03:14:00 +00:00
parent d0c913b8c9
commit bfa46ac41b

View File

@@ -2409,6 +2409,21 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source)
JS_SetGlobalObject(sandcx, sandbox);
XPCPerThreadData *data = XPCPerThreadData::GetData();
XPCJSContextStack *stack;
PRBool popContext = PR_FALSE;
if (data && (stack = data->GetJSContextStack())) {
if (NS_FAILED(stack->Push(sandcx))) {
JS_ReportError(cx,
"Unable to initialize XPConnect with the sandbox context");
JSPRINCIPALS_DROP(cx, jsPrincipals);
JS_DestroyContextNoGC(sandcx);
return NS_ERROR_FAILURE;
}
popContext = PR_TRUE;
}
// Capture uncaught exceptions reported as errors on sandcx and
// re-throw them on cx.
JS_SetContextPrivate(sandcx, cx);
@@ -2454,6 +2469,10 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source)
cc->SetReturnValueWasSet(PR_TRUE);
}
if (popContext) {
stack->Pop(nsnull);
}
JS_DestroyContextNoGC(sandcx);
JSPRINCIPALS_DROP(cx, jsPrincipals);
return rv;