Merge backout.

This commit is contained in:
Blake Kaplan 2011-07-14 15:22:10 -07:00
commit 32014abfe0

View File

@ -143,7 +143,7 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *target_ob
/* 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 = principal->GetJSPrincipals(cx, &jsPrincipals);
rv = mSystemPrincipal->GetJSPrincipals(cx, &jsPrincipals);
if (NS_FAILED(rv) || !jsPrincipals) {
return ReportError(cx, LOAD_ERROR_NOPRINCIPALS);
}
@ -302,24 +302,13 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * aURL
// Remember an object out of the calling compartment so that we
// can properly wrap the result later.
nsCOMPtr<nsIPrincipal> principal = mSystemPrincipal;
JSObject *result_obj = target_obj;
target_obj = JS_FindCompilationScope(cx, target_obj);
if (!target_obj) return NS_ERROR_FAILURE;
if (target_obj != result_obj)
{
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
if (!secman)
return NS_ERROR_FAILURE;
rv = secman->GetObjectPrincipal(cx, target_obj, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
#ifdef DEBUG_rginda
if (target_obj != result_obj)
fprintf (stderr, "Final global: %p\n", target_obj);
#endif
}
JSAutoEnterCompartment ac;
if (!ac.enter(cx, target_obj))