diff --git a/js/src/xpconnect/src/xpccomponents.cpp b/js/src/xpconnect/src/xpccomponents.cpp index 9c623f715dbf..6328d27bf1dc 100644 --- a/js/src/xpconnect/src/xpccomponents.cpp +++ b/js/src/xpconnect/src/xpccomponents.cpp @@ -2250,10 +2250,13 @@ nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative *wrappe if (!tempcx) return ThrowAndFail(NS_ERROR_OUT_OF_MEMORY, cx, _retval); + AutoJSRequestWithNoCallContext req(tempcx); JSObject *sandbox = JS_NewObject(tempcx, &SandboxClass, nsnull, nsnull); if (!sandbox) return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval); + JS_SetGlobalObject(tempcx, sandbox); + // Make sure to set up principals on the sandbox before initing classes nsIScriptObjectPrincipal *sop = nsnull; if (JSVAL_IS_STRING(argv[0])) { @@ -2415,6 +2418,7 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString &source) JSPRINCIPALS_DROP(cx, jsPrincipals); return NS_ERROR_OUT_OF_MEMORY; } + AutoJSRequestWithNoCallContext req(sandcx); JS_SetGlobalObject(sandcx, sandbox);