Bug 1105556 - test fixes. r=sicking, ckerschb

This commit is contained in:
Tanvi Vyas 2016-04-13 16:30:33 -07:00
parent 297217ffc0
commit 9209781614
3 changed files with 10 additions and 2 deletions

View File

@ -309,7 +309,7 @@ LoadInfo::CloneForNewRequest() const
NS_IMETHODIMP
LoadInfo::GetLoadingPrincipal(nsIPrincipal** aLoadingPrincipal)
{
NS_ADDREF(*aLoadingPrincipal = mLoadingPrincipal);
NS_IF_ADDREF(*aLoadingPrincipal = mLoadingPrincipal);
return NS_OK;
}

View File

@ -1295,6 +1295,8 @@ NS_HasBeenCrossOrigin(nsIChannel* aChannel, bool aReport)
{
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
MOZ_RELEASE_ASSERT(loadInfo, "Origin tracking only works for channels created with a loadinfo");
MOZ_ASSERT(loadInfo->GetExternalContentPolicyType() != nsIContentPolicy::TYPE_DOCUMENT,
"calling NS_HasBeenCrossOrigin on a top level load");
// Always treat tainted channels as cross-origin.
if (loadInfo->GetTainting() != LoadTainting::Basic) {
@ -2256,9 +2258,11 @@ NS_ShouldSecureUpgrade(nsIURI* aURI,
// Please note that cross origin top level navigations are not subject
// to upgrade-insecure-requests, see:
// http://www.w3.org/TR/upgrade-insecure-requests/#examples
// Compare the principal we are navigating to (aChannelResultPrincipal)
// with the referring/triggering Principal.
bool crossOriginNavigation =
(aLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_DOCUMENT) &&
(!aChannelResultPrincipal->Equals(aLoadInfo->LoadingPrincipal()));
(!aChannelResultPrincipal->Equals(aLoadInfo->TriggeringPrincipal()));
if (aLoadInfo->GetUpgradeInsecureRequests() && !crossOriginNavigation) {
// let's log a message to the console that we are upgrading a request

View File

@ -1345,6 +1345,10 @@ nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel,
"how did we end up here?");
nsCOMPtr<nsIPrincipal> principal = originalLoadInfo->LoadingPrincipal();
MOZ_ASSERT(principal &&
originalLoadInfo->GetExternalContentPolicyType() !=
nsIContentPolicy::TYPE_DOCUMENT,
"Should not do CORS loads for top-level loads, so a loadingPrincipal should always exist.");
bool withCredentials = originalLoadInfo->GetCookiePolicy() ==
nsILoadInfo::SEC_COOKIES_INCLUDE;