Backed out changeset 82d62650cfe4 (bug 1287827) for breaking tests

This commit is contained in:
Mark Banner 2016-07-29 18:12:19 +01:00
Родитель 37538ca14d
Коммит 9b96b9599c
2 изменённых файлов: 43 добавлений и 0 удалений

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

@ -2619,6 +2619,33 @@ nsDocument::SendToConsole(nsCOMArray<nsISecurityConsoleMessage>& aMessages)
} }
} }
bool
nsDocument::IsLoopDocument(nsIChannel *aChannel)
{
nsCOMPtr<nsIURI> chanURI;
nsresult rv = aChannel->GetOriginalURI(getter_AddRefs(chanURI));
NS_ENSURE_SUCCESS(rv, false);
bool isAbout = false;
bool isLoop = false;
rv = chanURI->SchemeIs("about", &isAbout);
NS_ENSURE_SUCCESS(rv, false);
if (isAbout) {
nsCOMPtr<nsIURI> loopURI;
rv = NS_NewURI(getter_AddRefs(loopURI), "about:loopconversation");
NS_ENSURE_SUCCESS(rv, false);
rv = chanURI->EqualsExceptRef(loopURI, &isLoop);
NS_ENSURE_SUCCESS(rv, false);
if (!isLoop) {
rv = NS_NewURI(getter_AddRefs(loopURI), "about:looppanel");
NS_ENSURE_SUCCESS(rv, false);
rv = chanURI->EqualsExceptRef(loopURI, &isLoop);
NS_ENSURE_SUCCESS(rv, false);
}
}
return isLoop;
}
void void
nsDocument::ApplySettingsFromCSP(bool aSpeculative) nsDocument::ApplySettingsFromCSP(bool aSpeculative)
{ {
@ -2743,6 +2770,9 @@ nsDocument::InitCSP(nsIChannel* aChannel)
principal->GetAddonId(addonId); principal->GetAddonId(addonId);
bool applyAddonCSP = !addonId.IsEmpty(); bool applyAddonCSP = !addonId.IsEmpty();
// Check if this is part of the Loop/Hello service
bool applyLoopCSP = IsLoopDocument(aChannel);
// Check if this is a signed content to apply default CSP. // Check if this is a signed content to apply default CSP.
bool applySignedContentCSP = false; bool applySignedContentCSP = false;
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
@ -2754,6 +2784,7 @@ nsDocument::InitCSP(nsIChannel* aChannel)
if (!applyAppDefaultCSP && if (!applyAppDefaultCSP &&
!applyAppManifestCSP && !applyAppManifestCSP &&
!applyAddonCSP && !applyAddonCSP &&
!applyLoopCSP &&
!applySignedContentCSP && !applySignedContentCSP &&
cspHeaderValue.IsEmpty() && cspHeaderValue.IsEmpty() &&
cspROHeaderValue.IsEmpty()) { cspROHeaderValue.IsEmpty()) {
@ -2837,6 +2868,17 @@ nsDocument::InitCSP(nsIChannel* aChannel)
csp->AppendPolicy(signedContentCSP, false, false); csp->AppendPolicy(signedContentCSP, false, false);
} }
// ----- if the doc is part of Loop, apply the loop CSP
if (applyLoopCSP) {
nsAdoptingString loopCSP;
loopCSP = Preferences::GetString("loop.CSP");
NS_ASSERTION(loopCSP, "Missing loop.CSP preference");
// If the pref has been removed, we continue without setting a CSP
if (loopCSP) {
csp->AppendPolicy(loopCSP, false, false);
}
}
// ----- if there's a full-strength CSP header, apply it. // ----- if there's a full-strength CSP header, apply it.
if (!cspHeaderValue.IsEmpty()) { if (!cspHeaderValue.IsEmpty()) {
rv = CSP_AppendCSPFromHeader(csp, cspHeaderValue, false); rv = CSP_AppendCSPFromHeader(csp, cspHeaderValue, false);

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

@ -1659,6 +1659,7 @@ private:
void DoUnblockOnload(); void DoUnblockOnload();
nsresult CheckFrameOptions(); nsresult CheckFrameOptions();
bool IsLoopDocument(nsIChannel* aChannel);
nsresult InitCSP(nsIChannel* aChannel); nsresult InitCSP(nsIChannel* aChannel);
/** /**