Skip to content
Permalink
Browse files

msg: Rename `ReferrerPolicy::NoRefWhenDowngrade` `NoReferrerWhenDowng…

…rade`

This is more consistent with the other variants.
  • Loading branch information...
aravind-pg committed Jul 15, 2016
1 parent e7ae1e8 commit bfda32ea0076d29788b39634e95ca7517315dceb
@@ -332,7 +332,7 @@ pub enum FrameType {
#[derive(Clone, Copy, Debug, Deserialize, HeapSizeOf, Serialize)]
pub enum ReferrerPolicy {
NoReferrer,
NoRefWhenDowngrade,
NoReferrerWhenDowngrade,
Origin,
SameOrigin,
OriginWhenCrossOrigin,
@@ -155,7 +155,7 @@ fn main_fetch(request: Rc<Request>, cache: &mut CORSCache, cors_flag: bool,

// Step 7
if request.referrer_policy.get().is_none() {
request.referrer_policy.set(Some(ReferrerPolicy::NoRefWhenDowngrade));
request.referrer_policy.set(Some(ReferrerPolicy::NoReferrerWhenDowngrade));
}

// Step 8
@@ -425,7 +425,7 @@ fn set_default_accept_language(headers: &mut Headers) {
}

/// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-state-no-referrer-when-downgrade
fn no_ref_when_downgrade_header(referrer_url: Url, url: Url) -> Option<Url> {
fn no_referrer_when_downgrade_header(referrer_url: Url, url: Url) -> Option<Url> {
if referrer_url.scheme() == "https" && url.scheme() != "https" {
return None;
}
@@ -462,7 +462,8 @@ pub fn determine_request_referrer(headers: &mut Headers,
Some(ReferrerPolicy::SameOrigin) => if cross_origin { None } else { strip_url(ref_url, false) },
Some(ReferrerPolicy::UnsafeUrl) => strip_url(ref_url, false),
Some(ReferrerPolicy::OriginWhenCrossOrigin) => strip_url(ref_url, cross_origin),
Some(ReferrerPolicy::NoRefWhenDowngrade) | None => no_ref_when_downgrade_header(ref_url, url),
Some(ReferrerPolicy::NoReferrerWhenDowngrade) | None =>
no_referrer_when_downgrade_header(ref_url, url),
};
}
return None;
@@ -2863,7 +2863,7 @@ pub fn determine_policy_for_token(token: &str) -> Option<ReferrerPolicy> {
let lower = token.to_lowercase();
return match lower.as_ref() {
"never" | "no-referrer" => Some(ReferrerPolicy::NoReferrer),
"default" | "no-referrer-when-downgrade" => Some(ReferrerPolicy::NoRefWhenDowngrade),
"default" | "no-referrer-when-downgrade" => Some(ReferrerPolicy::NoReferrerWhenDowngrade),
"origin" => Some(ReferrerPolicy::Origin),
"same-origin" => Some(ReferrerPolicy::SameOrigin),
"origin-when-cross-origin" => Some(ReferrerPolicy::OriginWhenCrossOrigin),
@@ -1721,7 +1721,7 @@ impl ScriptThread {
ReferrerPolicyHeader::NoReferrer =>
ReferrerPolicy::NoReferrer,
ReferrerPolicyHeader::NoReferrerWhenDowngrade =>
ReferrerPolicy::NoRefWhenDowngrade,
ReferrerPolicy::NoReferrerWhenDowngrade,
ReferrerPolicyHeader::SameOrigin =>
ReferrerPolicy::SameOrigin,
ReferrerPolicyHeader::Origin =>
@@ -1732,7 +1732,7 @@ fn test_http_to_https_considered_cross_origin_for_referer_header_logic() {
fn test_referer_set_to_ref_url_with_noreferrerwhendowngrade_policy_https_to_https() {
let request_url = "https://mozilla.com";
let referrer_url = "https://username:password@mozilla.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::NoRefWhenDowngrade);
let referrer_policy = Some(ReferrerPolicy::NoReferrerWhenDowngrade);
let expected_referrer = "https://mozilla.com/some/path";

let origin_info = LoadOriginInfo {
@@ -1747,7 +1747,7 @@ fn test_referer_set_to_ref_url_with_noreferrerwhendowngrade_policy_https_to_http
fn test_no_referer_set_with_noreferrerwhendowngrade_policy_https_to_http() {
let request_url = "http://mozilla.com";
let referrer_url = "https://username:password@mozilla.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::NoRefWhenDowngrade);
let referrer_policy = Some(ReferrerPolicy::NoReferrerWhenDowngrade);

let origin_info = LoadOriginInfo {
referrer_url: referrer_url,
@@ -1761,7 +1761,7 @@ fn test_no_referer_set_with_noreferrerwhendowngrade_policy_https_to_http() {
fn test_referer_set_to_ref_url_with_noreferrerwhendowngrade_policy_http_to_https() {
let request_url = "https://mozilla.com";
let referrer_url = "http://username:password@mozilla.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::NoRefWhenDowngrade);
let referrer_policy = Some(ReferrerPolicy::NoReferrerWhenDowngrade);
let expected_referrer = "http://mozilla.com/some/path";

let origin_info = LoadOriginInfo {
@@ -1776,7 +1776,7 @@ fn test_referer_set_to_ref_url_with_noreferrerwhendowngrade_policy_http_to_https
fn test_referer_set_to_ref_url_with_noreferrerwhendowngrade_policy_http_to_http() {
let request_url = "http://mozilla.com";
let referrer_url = "http://username:password@mozilla.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::NoRefWhenDowngrade);
let referrer_policy = Some(ReferrerPolicy::NoReferrerWhenDowngrade);
let expected_referrer = "http://mozilla.com/some/path";

let origin_info = LoadOriginInfo {

0 comments on commit bfda32e

Please sign in to comment.
You can’t perform that action at this time.