зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
b4be330175
Коммит
0fb8082300
|
@ -2409,6 +2409,21 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source)
|
||||||
|
|
||||||
JS_SetGlobalObject(sandcx, sandbox);
|
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
|
// Capture uncaught exceptions reported as errors on sandcx and
|
||||||
// re-throw them on cx.
|
// re-throw them on cx.
|
||||||
JS_SetContextPrivate(sandcx, cx);
|
JS_SetContextPrivate(sandcx, cx);
|
||||||
|
@ -2454,6 +2469,10 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source)
|
||||||
cc->SetReturnValueWasSet(PR_TRUE);
|
cc->SetReturnValueWasSet(PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (popContext) {
|
||||||
|
stack->Pop(nsnull);
|
||||||
|
}
|
||||||
|
|
||||||
JS_DestroyContextNoGC(sandcx);
|
JS_DestroyContextNoGC(sandcx);
|
||||||
JSPRINCIPALS_DROP(cx, jsPrincipals);
|
JSPRINCIPALS_DROP(cx, jsPrincipals);
|
||||||
return rv;
|
return rv;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче