Bug 1223838 - Fix wrong policy associated with empty string. r=fkiefer,hsivonen
MozReview-Commit-ID: 7kFH39cegmH
This commit is contained in:
@@ -952,7 +952,8 @@ nsHtml5TreeOpExecutor::PreloadImage(const nsAString& aURL,
|
||||
// if enabled in preferences, use the referrer attribute from the image, if provided
|
||||
bool referrerAttributeEnabled = Preferences::GetBool("network.http.enablePerElementReferrer", true);
|
||||
if (referrerAttributeEnabled) {
|
||||
mozilla::net::ReferrerPolicy imageReferrerPolicy = mozilla::net::ReferrerPolicyFromString(aImageReferrerPolicy);
|
||||
mozilla::net::ReferrerPolicy imageReferrerPolicy =
|
||||
mozilla::net::AttributeReferrerPolicyFromString(aImageReferrerPolicy);
|
||||
if (imageReferrerPolicy != mozilla::net::RP_Unset) {
|
||||
referrerPolicy = imageReferrerPolicy;
|
||||
}
|
||||
@@ -1011,8 +1012,21 @@ nsHtml5TreeOpExecutor::SetSpeculationBase(const nsAString& aURL)
|
||||
void
|
||||
nsHtml5TreeOpExecutor::SetSpeculationReferrerPolicy(const nsAString& aReferrerPolicy)
|
||||
{
|
||||
// Specs says:
|
||||
// - Let value be the result of stripping leading and trailing whitespace from
|
||||
// the value of element's content attribute.
|
||||
// - If value is not the empty string, then:
|
||||
if (aReferrerPolicy.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReferrerPolicy policy = mozilla::net::ReferrerPolicyFromString(aReferrerPolicy);
|
||||
return SetSpeculationReferrerPolicy(policy);
|
||||
// Specs says:
|
||||
// - If policy is not the empty string, then set element's node document's
|
||||
// referrer policy to policy
|
||||
if (policy != mozilla::net::RP_Unset) {
|
||||
SetSpeculationReferrerPolicy(policy);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user