Backout out bug 672026 for causing mobile startup crashes

This commit is contained in:
Luke Wagner 2011-07-21 16:39:10 -07:00
parent 073a9a3ba9
commit 8d479a53ec
2 changed files with 2 additions and 41 deletions

View File

@ -3324,41 +3324,6 @@ nsScriptSecurityManager::Observe(nsISupports* aObject, const char* aTopic,
return rv;
}
///////////////////////////////////
// Default ObjectPrincipalFinder //
///////////////////////////////////
// The default JSSecurityCallbacks::findObjectPrincipals is necessary since
// scripts run (and ask for object principals) during startup before
// nsJSRuntime::Init() has been called (which resets findObjectPrincipals).
// Defined NS_EXPORT for linkage with debug-only assert in xpcshell
NS_EXPORT JSPrincipals *
NS_DefaultObjectPrincipalFinder(JSContext *cx, JSObject *obj)
{
nsScriptSecurityManager *ssm = nsScriptSecurityManager::GetScriptSecurityManager();
if (!ssm) {
return nsnull;
}
nsCOMPtr<nsIPrincipal> principal;
nsresult rv = ssm->GetObjectPrincipal(cx, obj, getter_AddRefs(principal));
if (NS_FAILED(rv) || !principal) {
return nsnull;
}
JSPrincipals *jsPrincipals = nsnull;
principal->GetJSPrincipals(cx, &jsPrincipals);
// nsIPrincipal::GetJSPrincipals() returns a strong reference to the
// JS principals, but the caller of this function expects a weak
// reference. So we need to release here.
JSPRINCIPALS_DROP(cx, jsPrincipals);
return jsPrincipals;
}
/////////////////////////////////////////////
// Constructor, Destructor, Initialization //
/////////////////////////////////////////////
@ -3431,7 +3396,7 @@ nsresult nsScriptSecurityManager::Init()
static JSSecurityCallbacks securityCallbacks = {
CheckObjectAccess,
NULL,
NS_DefaultObjectPrincipalFinder,
NULL,
ContentSecurityPolicyPermitsJSAction
};

View File

@ -1750,10 +1750,6 @@ FindObjectPrincipals(JSContext *cx, JSObject *obj)
return gJSPrincipals;
}
// defined in nsScriptSecurityManager.cpp
NS_IMPORT JSPrincipals *
NS_DefaultObjectPrincipalFinder(JSContext *cx, JSObject *obj);
int
main(int argc, char **argv, char **envp)
{
@ -1907,7 +1903,7 @@ main(int argc, char **argv, char **envp)
JSSecurityCallbacks *cb = JS_GetRuntimeSecurityCallbacks(rt);
NS_ASSERTION(cb, "We are assuming that nsScriptSecurityManager::Init() has been run");
NS_ASSERTION(cb->findObjectPrincipals == NS_DefaultObjectPrincipalFinder, "Your pigeon is in my hole!");
NS_ASSERTION(!cb->findObjectPrincipals, "Your pigeon is in my hole!");
cb->findObjectPrincipals = FindObjectPrincipals;
#ifdef TEST_TranslateThis