зеркало из https://github.com/mozilla/pjs.git
Fix missing cx param problem (223041, r=caillon, sr=dbaron).
This commit is contained in:
Родитель
aacf02e777
Коммит
4be366b3cf
|
@ -43,11 +43,13 @@
|
|||
#include "nsISerializable.idl"
|
||||
|
||||
%{C++
|
||||
struct JSContext;
|
||||
struct JSPrincipals;
|
||||
%}
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
[ptr] native JSContext(JSContext);
|
||||
[ptr] native JSPrincipals(JSPrincipals);
|
||||
|
||||
[uuid(ff9313d0-25e1-11d2-8160-006008119d7a)]
|
||||
|
@ -90,7 +92,7 @@ interface nsIPrincipal : nsISerializable
|
|||
* Returns the JS equivalent of the principal.
|
||||
* @see JSPrincipals.h
|
||||
*/
|
||||
readonly attribute JSPrincipals jsPrincipals;
|
||||
JSPrincipals getJSPrincipals(in JSContext cx);
|
||||
|
||||
/**
|
||||
* The domain security policy of the principal.
|
||||
|
|
|
@ -141,7 +141,7 @@ nsTranscodeJSPrincipals(JSXDRState *xdr, JSPrincipals **jsprinp)
|
|||
nsMemory::Free(olddata);
|
||||
::JS_XDRMemSetData(xdr, data, size);
|
||||
|
||||
prin->GetJsPrincipals(jsprinp);
|
||||
prin->GetJSPrincipals(xdr->cx, jsprinp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,16 +141,12 @@ nsPrincipal::~nsPrincipal(void)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrincipal::GetJsPrincipals(JSPrincipals **jsprin)
|
||||
nsPrincipal::GetJSPrincipals(JSContext *cx, JSPrincipals **jsprin)
|
||||
{
|
||||
NS_PRECONDITION(mJSPrincipals.nsIPrincipalPtr, "mJSPrincipals is uninitalized!");
|
||||
|
||||
JSPRINCIPALS_HOLD(cx, &mJSPrincipals);
|
||||
*jsprin = &mJSPrincipals;
|
||||
|
||||
// JSPRINCIPALS_HOLD does not use its first argument.
|
||||
// Just use a dummy cx to save the codesize.
|
||||
JSPRINCIPALS_HOLD(nsnull, *jsprin);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,12 +228,12 @@ nsSystemPrincipal::SetSecurityPolicy(void* aSecurityPolicy)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSystemPrincipal::GetJsPrincipals(JSPrincipals **jsprin)
|
||||
nsSystemPrincipal::GetJSPrincipals(JSContext *cx, JSPrincipals **jsprin)
|
||||
{
|
||||
NS_PRECONDITION(mJSPrincipals.nsIPrincipalPtr, "mJSPrincipals is uninitalized!");
|
||||
|
||||
JSPRINCIPALS_HOLD(cx, &mJSPrincipals);
|
||||
*jsprin = &mJSPrincipals;
|
||||
JSPRINCIPALS_HOLD(nsnull, *jsprin);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -628,7 +628,7 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
|
|||
JSPrincipals *jsprin;
|
||||
nsCOMPtr<nsIPrincipal> principal = aPrincipal;
|
||||
if (aPrincipal) {
|
||||
aPrincipal->GetJsPrincipals(&jsprin);
|
||||
aPrincipal->GetJSPrincipals(mContext, &jsprin);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIScriptGlobalObject> global;
|
||||
|
@ -641,7 +641,7 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
|
|||
rv = objPrincipal->GetPrincipal(getter_AddRefs(principal));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
principal->GetJsPrincipals(&jsprin);
|
||||
principal->GetJSPrincipals(mContext, &jsprin);
|
||||
}
|
||||
// From here on, we must JSPRINCIPALS_DROP(jsprin) before returning...
|
||||
|
||||
|
@ -806,7 +806,7 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
JSPrincipals *jsprin;
|
||||
nsCOMPtr<nsIPrincipal> principal = aPrincipal;
|
||||
if (aPrincipal) {
|
||||
aPrincipal->GetJsPrincipals(&jsprin);
|
||||
aPrincipal->GetJSPrincipals(mContext, &jsprin);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIScriptGlobalObject> global;
|
||||
|
@ -819,7 +819,7 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
rv = objPrincipal->GetPrincipal(getter_AddRefs(principal));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
principal->GetJsPrincipals(&jsprin);
|
||||
principal->GetJSPrincipals(mContext, &jsprin);
|
||||
}
|
||||
// From here on, we must JSPRINCIPALS_DROP(jsprin) before returning...
|
||||
|
||||
|
@ -919,7 +919,7 @@ nsJSContext::CompileScript(const PRUnichar* aText,
|
|||
aScopeObject = ::JS_GetGlobalObject(mContext);
|
||||
|
||||
JSPrincipals *jsprin;
|
||||
aPrincipal->GetJsPrincipals(&jsprin);
|
||||
aPrincipal->GetJSPrincipals(mContext, &jsprin);
|
||||
// From here on, we must JSPRINCIPALS_DROP(jsprin) before returning...
|
||||
|
||||
PRBool ok = PR_FALSE;
|
||||
|
@ -1093,7 +1093,7 @@ nsJSContext::CompileEventHandler(void *aTarget, nsIAtom *aName,
|
|||
getter_AddRefs(prin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
prin->GetJsPrincipals(&jsprin);
|
||||
prin->GetJSPrincipals(mContext, &jsprin);
|
||||
NS_ENSURE_TRUE(jsprin, NS_ERROR_NOT_AVAILABLE);
|
||||
}
|
||||
|
||||
|
@ -1146,7 +1146,7 @@ nsJSContext::CompileFunction(void* aTarget,
|
|||
nsCOMPtr<nsIPrincipal> prin;
|
||||
if (NS_FAILED(globalData->GetPrincipal(getter_AddRefs(prin))))
|
||||
return NS_ERROR_FAILURE;
|
||||
prin->GetJsPrincipals(&jsprin);
|
||||
prin->GetJSPrincipals(mContext, &jsprin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ MozAxAutoPushJSContext::MozAxAutoPushJSContext(JSContext *cx,
|
|||
if (NS_SUCCEEDED(mPushResult))
|
||||
{
|
||||
JSPrincipals* jsprinc;
|
||||
principal->GetJsPrincipals(&jsprinc);
|
||||
principal->GetJSPrincipals(cx, &jsprinc);
|
||||
|
||||
mFrame.script = JS_CompileScriptForPrincipals(cx, JS_GetGlobalObject(cx),
|
||||
jsprinc, "", 0, "", 1);
|
||||
|
|
|
@ -210,7 +210,7 @@ AutoPushJSContext::AutoPushJSContext(nsISupports* aSecuritySupports,
|
|||
if (!hasScript)
|
||||
{
|
||||
JSPrincipals* jsprinc;
|
||||
principal->GetJsPrincipals(&jsprinc);
|
||||
principal->GetJSPrincipals(cx, &jsprinc);
|
||||
|
||||
mFrame.script = JS_CompileScriptForPrincipals(cx, JS_GetGlobalObject(cx),
|
||||
jsprinc, "", 0, "", 1);
|
||||
|
|
|
@ -269,7 +269,7 @@ EvalInSandbox(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
NS_FAILED(secman->GetCodebasePrincipal(iURL,
|
||||
getter_AddRefs(principal))) ||
|
||||
!principal ||
|
||||
NS_FAILED(principal->GetJsPrincipals(&jsPrincipals)) ||
|
||||
NS_FAILED(principal->GetJSPrincipals(cx, &jsPrincipals)) ||
|
||||
!jsPrincipals) {
|
||||
JS_ReportError(cx, "Can't get principals for evalInSandbox");
|
||||
return JS_FALSE;
|
||||
|
@ -997,7 +997,7 @@ mozJSComponentLoader::GlobalForLocation(const char *aLocation,
|
|||
nsCOMPtr<nsIScriptObjectPrincipal> backstagePass =
|
||||
new BackstagePass(mSystemPrincipal);
|
||||
|
||||
rv = mSystemPrincipal->GetJsPrincipals(&jsPrincipals);
|
||||
rv = mSystemPrincipal->GetJSPrincipals(cx, &jsPrincipals);
|
||||
if (NS_FAILED(rv) || !jsPrincipals)
|
||||
return nsnull;
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * /*url*/
|
|||
/* we can't hold onto jsPrincipals as a module var because the
|
||||
* JSPRINCIPALS_DROP macro takes a JSContext, which we won't have in the
|
||||
* destructor */
|
||||
rv = mSystemPrincipal->GetJsPrincipals(&jsPrincipals);
|
||||
rv = mSystemPrincipal->GetJSPrincipals(cx, &jsPrincipals);
|
||||
if (NS_FAILED(rv) || !jsPrincipals) {
|
||||
delete[] buf;
|
||||
return rv;
|
||||
|
|
|
@ -352,7 +352,7 @@ get_JSPrincipals_from_java_caller_impl(JNIEnv *pJNIEnv, JSContext *pJSContext, v
|
|||
rv = ssm->GetCodebasePrincipal(codebaseURI, getter_AddRefs(principal));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
JSPrincipals* jsprincipals;
|
||||
principal->GetJsPrincipals(&jsprincipals);
|
||||
principal->GetJSPrincipals(pJSContext, &jsprincipals);
|
||||
return jsprincipals;
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ get_JSPrincipals_from_java_caller_impl(JNIEnv *pJNIEnv, JSContext *pJSContext, v
|
|||
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(credentials);
|
||||
if (principal) {
|
||||
JSPrincipals* jsprincipals;
|
||||
principal->GetJsPrincipals(&jsprincipals);
|
||||
principal->GetJSPrincipals(pJSContext, &jsprincipals);
|
||||
return jsprincipals;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1787,13 +1787,14 @@ nsCryptoRunnable::Run()
|
|||
{
|
||||
nsNSSShutDownPreventionLock locker;
|
||||
JSPrincipals *principals;
|
||||
JSContext *cx = m_args->m_cx;
|
||||
|
||||
nsresult rv = m_args->m_principals->GetJsPrincipals(&principals);
|
||||
nsresult rv = m_args->m_principals->GetJSPrincipals(cx, &principals);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
jsval retval;
|
||||
if (JS_EvaluateScriptForPrincipals(m_args->m_cx, m_args->m_scope, principals,
|
||||
if (JS_EvaluateScriptForPrincipals(cx, m_args->m_scope, principals,
|
||||
m_args->m_jsCallback,
|
||||
strlen(m_args->m_jsCallback),
|
||||
nsnull, 0,
|
||||
|
|
Загрузка…
Ссылка в новой задаче