net: Add "origin" and "same-origin" referrer policies, replacing "origin-only".

This commit is contained in:
Aravind Gollakota 2016-06-30 19:02:12 -07:00
parent d62de85094
commit eeccb75fc1
8 changed files with 37 additions and 25 deletions

View file

@ -1626,10 +1626,10 @@ fn assert_referer_header_not_included(origin_info: &LoadOrigin, request_url: &st
}
#[test]
fn test_referer_set_to_origin_with_originonly_policy() {
fn test_referer_set_to_origin_with_origin_policy() {
let request_url = "http://mozilla.com";
let referrer_url = "http://username:password@someurl.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::OriginOnly);
let referrer_policy = Some(ReferrerPolicy::Origin);
let expected_referrer = "http://someurl.com/";
let origin_info = LoadOriginInfo {
@ -1640,6 +1640,35 @@ fn test_referer_set_to_origin_with_originonly_policy() {
assert_referer_header_matches(&origin_info, request_url, expected_referrer);
}
#[test]
fn test_referer_set_to_ref_url_with_sameorigin_policy_same_orig() {
let request_url = "http://mozilla.com";
let referrer_url = "http://username:password@mozilla.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::SameOrigin);
let expected_referrer = "http://mozilla.com/some/path";
let origin_info = LoadOriginInfo {
referrer_url: referrer_url,
referrer_policy: referrer_policy
};
assert_referer_header_matches(&origin_info, request_url, expected_referrer);
}
#[test]
fn test_no_referer_set_with_sameorigin_policy_cross_orig() {
let request_url = "http://mozilla.com";
let referrer_url = "http://username:password@someurl.com/some/path#fragment";
let referrer_policy = Some(ReferrerPolicy::SameOrigin);
let origin_info = LoadOriginInfo {
referrer_url: referrer_url,
referrer_policy: referrer_policy
};
assert_referer_header_not_included(&origin_info, request_url);
}
#[test]
fn test_referer_set_to_stripped_url_with_unsafeurl_policy() {
let request_url = "http://mozilla.com";

View file

@ -1,5 +0,0 @@
[cross-origin.keep-origin-redirect.http.html]
type: testharness
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via xhr-request using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is cross-origin.]
expected: FAIL

View file

@ -1,5 +0,0 @@
[cross-origin.no-redirect.http.html]
type: testharness
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via xhr-request using the meta-referrer\n delivery method with no-redirect and when\n the target request is cross-origin.]
expected: FAIL

View file

@ -1,5 +0,0 @@
[cross-origin.swap-origin-redirect.http.html]
type: testharness
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via xhr-request using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is cross-origin.]
expected: FAIL

View file

@ -1,5 +0,0 @@
[same-origin-insecure.swap-origin-redirect.http.html]
type: testharness
[The referrer URL is omitted when a\n document served over http requires an http\n sub-resource via xhr-request using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is same-origin.]
expected: FAIL