Bug 965413 part 9. Support use of a LoadInfo for javascript: URLs. r=smaug

This commit is contained in:
Boris Zbarsky 2014-07-10 02:56:37 -04:00
Родитель 744cc503d7
Коммит 321102201e
1 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -48,6 +48,7 @@
#include "nsIContentSecurityPolicy.h"
#include "nsSandboxFlags.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsILoadInfo.h"
using mozilla::dom::AutoEntryScript;
@ -153,10 +154,16 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
aChannel->GetOwner(getter_AddRefs(owner));
nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(owner);
if (!principal) {
// No execution without a principal!
NS_ASSERTION(!owner, "Non-principal owner?");
NS_WARNING("No principal to execute JS with");
return NS_ERROR_DOM_RETVAL_UNDEFINED;
nsCOMPtr<nsILoadInfo> loadInfo;
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
if (loadInfo && loadInfo->GetForceInheritPrincipal()) {
principal = loadInfo->LoadingPrincipal();
} else {
// No execution without a principal!
NS_ASSERTION(!owner, "Non-principal owner?");
NS_WARNING("No principal to execute JS with");
return NS_ERROR_DOM_RETVAL_UNDEFINED;
}
}
nsresult rv;