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

This commit is contained in:
mrbkap%gmail.com 2005-11-02 22:07:15 +00:00
Родитель b4be330175
Коммит 0fb8082300
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -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;