diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 543e4277f23b..92fd507837cb 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -346,7 +346,7 @@ pub struct SubpageId(pub u32); /// [Policies](https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states) /// for providing a referrer header for a request -#[derive(HeapSizeOf, Clone, Deserialize, Serialize)] +#[derive(HeapSizeOf, Clone, Deserialize, Serialize, Debug, Copy)] pub enum ReferrerPolicy { NoReferrer, NoRefWhenDowngrade, diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 7dd5fc3c193e..f710e2bc9355 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -592,7 +592,9 @@ pub fn modify_request_headers(headers: &mut Headers, user_agent: &str, cookie_jar: &Arc>, auth_cache: &Arc>, - load_data: &LoadData) { + load_data: &LoadData, + referrer_url: &mut Option) { + // Ensure that the host header is set from the original url let host = Host { hostname: url.host_str().unwrap().to_owned(), @@ -613,10 +615,12 @@ pub fn modify_request_headers(headers: &mut Headers, set_default_accept(headers); set_default_accept_encoding(headers); - if let Some(referer_val) = determine_request_referrer(headers, - load_data.referrer_policy.clone(), - load_data.referrer_url.clone(), - url.clone()) { + *referrer_url = determine_request_referrer(headers, + load_data.referrer_policy.clone(), + referrer_url.clone(), + url.clone()); + + if let Some(referer_val) = referrer_url.clone() { headers.set(Referer(referer_val.into_string())); } @@ -804,6 +808,8 @@ pub fn load(load_data: &LoadData, let mut doc_url = load_data.url.clone(); let mut redirected_to = HashSet::new(); let mut method = load_data.method.clone(); + // URL of referrer - to be updated with redirects + let mut referrer_url = load_data.referrer_url.clone(); let mut new_auth_header: Option> = None; @@ -874,7 +880,7 @@ pub fn load(load_data: &LoadData, modify_request_headers(&mut request_headers, &doc_url, &user_agent, &http_state.cookie_jar, - &http_state.auth_cache, &load_data); + &http_state.auth_cache, &load_data, &mut referrer_url); //if there is a new auth header then set the request headers with it if let Some(ref auth_header) = new_auth_header { diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index dcd85c3af72a..1f6380517699 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -140,7 +140,7 @@ impl LoadData { credentials_flag: true, context: context, referrer_policy: load_origin.referrer_policy(), - referrer_url: load_origin.referrer_url(), + referrer_url: load_origin.referrer_url().clone(), source: load_origin.request_source() } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index d204bd0d8c61..c959077675ec 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -240,7 +240,7 @@ pub struct Document { /// The document's origin. origin: Origin, /// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states - referrer_policy: Option, + referrer_policy: Cell>, } #[derive(JSTraceable, HeapSizeOf)] @@ -1710,7 +1710,7 @@ impl Document { touchpad_pressure_phase: Cell::new(TouchpadPressurePhase::BeforeClick), origin: origin, //TODO - setting this for now so no Referer header set - referrer_policy: Some(ReferrerPolicy::NoReferrer), + referrer_policy: Cell::new(Some(ReferrerPolicy::NoReferrer)), } } @@ -1840,9 +1840,13 @@ impl Document { } } - //TODO - for now, returns no-referrer for all until reading in the value + pub fn set_referrer_policy(&self, policy: Option) { + self.referrer_policy.set(policy); + } + + //TODO - default still at no-referrer pub fn get_referrer_policy(&self) -> Option { - return self.referrer_policy.clone(); + return self.referrer_policy.get(); } } @@ -2801,6 +2805,12 @@ impl DocumentMethods for Document { // https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers document_and_element_event_handlers!(); + + // https://html.spec.whatwg.org/multipage/#dom-document-referrer + fn Referrer(&self) -> DOMString { + //TODO - unimplemented, for ref pol tests + DOMString::new() + } } fn update_with_current_time_ms(marker: &Cell) { @@ -2811,6 +2821,20 @@ fn update_with_current_time_ms(marker: &Cell) { } } +/// https://w3c.github.io/webappsec-referrer-policy/#determine-policy-for-token +pub fn determine_policy_for_token(token: &str) -> Option { + let lower = token.to_lowercase(); + return match lower.as_ref() { + "never" | "no-referrer" => Some(ReferrerPolicy::NoReferrer), + "default" | "no-referrer-when-downgrade" => Some(ReferrerPolicy::NoRefWhenDowngrade), + "origin" => Some(ReferrerPolicy::OriginOnly), + "origin-when-cross-origin" => Some(ReferrerPolicy::OriginWhenCrossOrigin), + "always" | "unsafe-url" => Some(ReferrerPolicy::UnsafeUrl), + "" => Some(ReferrerPolicy::NoReferrer), + _ => None, + } +} + pub struct DocumentProgressHandler { addr: Trusted } diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 8cec0aa66599..86fe601bbe00 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -146,8 +146,9 @@ impl HTMLIFrameElement { pub fn process_the_iframe_attributes(&self) { let url = self.get_url(); - // TODO - loaddata here should have referrer info (not None, None) - self.navigate_or_reload_child_browsing_context(Some(LoadData::new(url, None, None))); + let document = document_from_node(self); + self.navigate_or_reload_child_browsing_context( + Some(LoadData::new(url, document.get_referrer_policy(), Some(document.url().clone())))); } #[allow(unsafe_code)] diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index bc3dfdb5b57d..2ee684d7a213 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -4,12 +4,13 @@ use dom::attr::AttrValue; use dom::bindings::cell::DOMRefCell; +use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding; use dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; use dom::bindings::inheritance::Castable; use dom::bindings::js::{Root, RootedReference}; use dom::bindings::str::DOMString; -use dom::document::Document; +use dom::document::{Document, determine_policy_for_token}; use dom::element::Element; use dom::htmlelement::HTMLElement; use dom::node::{Node, document_from_node}; @@ -59,6 +60,10 @@ impl HTMLMetaElement { if name == "viewport" { self.apply_viewport(); } + + if name == "referrer" { + self.apply_referrer(); + } } } @@ -85,6 +90,28 @@ impl HTMLMetaElement { } } } + + /// https://html.spec.whatwg.org/multipage/#meta-referrer + fn apply_referrer(&self) { + /*todo - I think this chould only run if document's policy hasnt yet + been set. unclear - see: + https://html.spec.whatwg.org/multipage/#meta-referrer + https://w3c.github.io/webappsec-referrer-policy/#set-referrer-policy + */ + let doc = document_from_node(self); + if let Some(head) = doc.GetHead() { + if head.upcast::().is_parent_of(self.upcast::()) { + let element = self.upcast::(); + if let Some(content) = element.get_attribute(&ns!(), &atom!("content")).r() { + let content = content.value(); + let content_val = content.trim(); + if !content_val.is_empty() { + doc.set_referrer_policy(determine_policy_for_token(content_val)); + } + } + } + } + } } impl HTMLMetaElementMethods for HTMLMetaElement { diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index b73d563bac75..dc3754b63790 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -82,7 +82,7 @@ partial /*sealed*/ interface Document { [/*PutForwards=href, */Unforgeable] readonly attribute Location? location; readonly attribute DOMString domain; - // readonly attribute DOMString referrer; + readonly attribute DOMString referrer; [Throws] attribute DOMString cookie; readonly attribute DOMString lastModified; diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 27fe4a783f08..560376696d20 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -148,10 +148,14 @@ pub struct XMLHttpRequest { fetch_time: Cell, generation_id: Cell, response_status: Cell>, + referrer_url: Option, + referrer_policy: Option, } impl XMLHttpRequest { fn new_inherited(global: GlobalRef) -> XMLHttpRequest { + //TODO - will this panic (outside of the scope of the ref policy tests)? + let current_doc = global.as_window().Document(); XMLHttpRequest { eventtarget: XMLHttpRequestEventTarget::new_inherited(), ready_state: Cell::new(XMLHttpRequestState::Unsent), @@ -183,6 +187,8 @@ impl XMLHttpRequest { fetch_time: Cell::new(0), generation_id: Cell::new(GenerationId(0)), response_status: Cell::new(Ok(())), + referrer_url: Some(current_doc.url().clone()), + referrer_policy: current_doc.get_referrer_policy(), } } pub fn new(global: GlobalRef) -> Root { @@ -297,10 +303,10 @@ impl XMLHttpRequest { impl LoadOrigin for XMLHttpRequest { fn referrer_url(&self) -> Option { - None + return self.referrer_url.clone(); } fn referrer_policy(&self) -> Option { - None + return self.referrer_policy; } fn request_source(&self) -> RequestSource { if self.sync.get() { @@ -592,11 +598,12 @@ impl XMLHttpRequestMethods for XMLHttpRequest { // Step 5 let global = self.global(); - //TODO - set referrer_policy/referrer_url in load_data + let mut load_data = LoadData::new(LoadContext::Browsing, self.request_url.borrow().clone().unwrap(), self); + if load_data.url.origin().ne(&global.r().get_url().origin()) { load_data.credentials_flag = self.WithCredentials(); } diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 65078c5b7710..8d0d01f848ac 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -54,6 +54,7 @@ os.path.join(".", "tests", "wpt", "harness"), os.path.join(".", "tests", "wpt", "update"), os.path.join(".", "tests", "wpt", "web-platform-tests"), + os.path.join(".", "tests", "wpt", "mozilla", "tests", "mozilla", "referrer-policy"), os.path.join(".", "tests", "wpt", "sync"), os.path.join(".", "tests", "wpt", "sync_css"), os.path.join(".", "python", "mach"), diff --git a/tests/wpt/include.ini b/tests/wpt/include.ini index 5b6d21b42789..714a23de9e46 100644 --- a/tests/wpt/include.ini +++ b/tests/wpt/include.ini @@ -57,3 +57,5 @@ skip: true skip: false [cssom-view] skip: false +[referrer-policy] + skip: false diff --git a/tests/wpt/metadata/referrer-policy/generic/subresource-test/__dir__.ini b/tests/wpt/metadata/referrer-policy/generic/subresource-test/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/generic/subresource-test/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/attr-referrer/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/attr-referrer/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/attr-referrer/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/http-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/http-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/http-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/attr-referrer/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/attr-referrer/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/attr-referrer/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/http-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/http-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/http-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/cross-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/no-referrer/meta-referrer/same-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/attr-referrer/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/attr-referrer/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/attr-referrer/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/http-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/http-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/http-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/cross-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-only/meta-referrer/same-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/attr-referrer/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/attr-referrer/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/attr-referrer/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/http-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/http-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/http-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/attr-referrer/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/attr-referrer/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/attr-referrer/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/http-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/http-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/http-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-csp/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-csp/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-csp/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/fetch-request/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/img-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/img-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/img-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/script-tag/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/script-tag/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/script-tag/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-https/__dir__.ini b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-https/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unsafe-url/meta-referrer/same-origin/http-https/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/metadata/referrer-policy/unset-referrer-policy/__dir__.ini b/tests/wpt/metadata/referrer-policy/unset-referrer-policy/__dir__.ini new file mode 100644 index 000000000000..163ca23a12f6 --- /dev/null +++ b/tests/wpt/metadata/referrer-policy/unset-referrer-policy/__dir__.ini @@ -0,0 +1 @@ +disabled: for now diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index fe297365b136..784c0ba74518 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6670,6 +6670,186 @@ "url": "/_mozilla/mozilla/range_deleteContents.html" } ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], "mozilla/response-data-brotli.htm": [ { "path": "mozilla/response-data-brotli.htm", diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/OWNERS b/tests/wpt/mozilla/tests/mozilla/referrer-policy/OWNERS new file mode 100644 index 000000000000..db2d613c2261 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/OWNERS @@ -0,0 +1 @@ +@kristijanburnik diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md b/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md new file mode 100644 index 000000000000..fc84ce8d1cba --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md @@ -0,0 +1,245 @@ +# Referrer-Policy Web Platform Tests + +The Referrer-Policy tests are designed for testing browser implementations and conformance to the [W3 Referrer-Policy Specification](http://w3c.github.io/webappsec/specs/referrer-policy/). + +## Project structure + +The project contains tools, templates and a seed (```spec.src.json```) for generating tests. The main assertion logic resides in JS files in the root of the ```./generic/``` directory. + +This is the overview of the project structure: + +``` +. +└── generic + ├── subresource - documents being served as sub-resources (python scripts) + ├── subresource-test - sanity checking tests for resource invocation + ├── template - the test files template used for generating the tests + └── tools - for generating and maintaining the test suite +└── (genereated_tests_for_a_specification_1) +└── (genereated_tests_for_a_specification_2) +└── ... +└── (genereated_tests_for_a_specification_N) +``` + +## The spec JSON + +The ```spec.src.json``` defines all the test scenarios for the referrer policy. + +Invoking ```./generic/tools/generate.py``` will parse the spec JSON and determine which tests to generate (or skip) while using templates. + + +The spec can be validated by running ```./generic/tools/spec_validator.py```. This is specially important when you're making changes to ```spec.src.json```. Make sure it's a valid JSON (no comments or trailing commas). The validator should be informative and very specific on any issues. + +For details about the spec JSON, see **Overview of the spec JSON** below. + + +## Generating and running the tests + +The repository already contains generated tests, so if you're making changes, +see the **Removing all generated tests** section below, on how to remove them before you start generating tests which include your changes. + +Start from the command line: + +```bash + +# Chdir into the tests directory. +cd ~/web-platform-tests/referrer-policy + +# Generate the test resources. +./generic/tools/generate.py + +# Add all generated tests to the repo. +git add * && git commit -m "Add generated tests" + +# Regenerate the manifest. +../manifest + +``` + +Navigate to [http://web-platform.test:8000/tools/runner/index.html](http://web-platform.test:8000/tools/runner/index.html). + +Run tests under path: ```/referrer-policy```. + +Click start. + + +## Options for generating tests + +The generator script ```./generic/tools/generate.py``` has two targets: ```release``` and ```debug```. + +* Using **release** for the target will produce tests using a template for optimizing size and performance. The release template is intended for the official web-platform-tests and possibly other test suites. No sanity checking is done in release mode. Use this option whenever you're checking into web-platform-tests. + +* When generating for ```debug```, the produced tests will contain more verbosity and sanity checks. Use this target to identify problems with the test suite when making changes locally. Make sure you don't check in tests generated with the debug target. + +Note that **release** is the default target when invoking ```generate.py```. + + +## Removing all generated tests + +```bash +# Chdir into the tests directory. +cd ~/web-platform-tests/referrer-policy + +# Remove all generated tests. +./generic/tools/clean.py + +# Remove all generated tests to the repo. +git add * && git commit -m "Remove generated tests" + +# Regenerate the manifest. +../manifest +``` + +**Important:** +The ```./generic/tools/clean.py``` utility will only work if there is a valid ```spec.src.json``` and previously generated directories match the specification requirement names. So make sure you run ```clean.py``` before you alter the specification section of the spec JSON. + + +## Updating the tests + +The main test logic lives in ```./generic/referrer-policy-test-case.js``` with helper functions defined in ```./generic/common.js``` so you should probably start there. + +For updating the test suite you will most likely do **a subset** of the following: + +* Add a new sub-resource python script to ```./generic/subresource/```, + and update the reference to it in ```spec.src.json```. + +* Add a sanity check test for a sub-resource to ```./generic/subresource-test/```. + +* Implement new or update existing assertions in ```./generic/referrer-policy-test-case.js```. + +* Exclude or add some tests by updating ```spec.src.json``` test expansions. + +* Update the template files living in ```./generic/template/```. + +* Implement a new delivery method via HTTP headers or as part of the test template in ```./generic/tools/generate.py``` + +* Update the spec schema by editing ```spec.src.json``` while updating the + ```./generic/tools/spec_validator.py``` and ```./generic/tools/generate.py``` + and making sure both still work after the change (by running them). + +* Regenerate the tests and MANIFEST.json + + +## Updating the spec and regenerating + +When updating the ```spec.src.json```, e.g. by adding a test expansion pattern to the ```excluded_tests``` section or when removing an expansion in the ```specification``` section, make sure to remove all previously generated files which would still get picked up by ```MANIFEST.json``` in the web-platform-tests root. As long as you don't change the specification requirements' names or remove them, you can easily regenerate the tests via command line: + +```bash + +# Chdir into the tests directory. +cd ~/web-platform-tests/referrer-policy + +# Regenerate the test resources. +./generic/tools/regenerate + +# Add all the tests to the repo. +git add * && git commit -m "Update generated tests" + +# Regenerate the manifest. +../manifest + + +``` + + +## Overview of the spec JSON + +**Main sections:** + +* **specification** + + Top level requirements with description fields and a ```test_expansion``` rule. + This is closely mimicking the [Referrer Policy specification](http://w3c.github.io/webappsec/specs/referrer-policy/) structure. + +* **excluded_tests** + + List of ```test_expansion``` patterns expanding into selections which get skipped when generating the tests (aka. blacklisting/suppressing) + +* **referrer_policy_schema** + + The schema to validate fields which define the ```referrer_policy``` elsewhere in the JSON. + A value for a referrer_policy can only be one specified in the referrer_policy_schema. + +* **test_expansion_schema** + + The schema used to check if a ```test_expansion``` is valid. + Each test expansion can only contain fields defined by this schema. + +* **subresource_path** + + A 1:1 mapping of a **subresource type** to the URL path of the sub-resource. + When adding a new sub-resource, a path to an existing file for it also must be specified. + + +### Test Expansion Patterns + +Each field in a test expansion can be in one of the following formats: + +* Single match: ```"value"``` + +* Match any of: ```["value1", "value2", ...]``` + +* Match all: ```"*"``` + +#### Example: test expansion in a requirement specification + +The following example shows how to restrict the expansion of ```referrer_url``` to ```origin``` and allow rest of the arrangement to expand (permute) to all possible values. The name field will be the prefix of a generated HTML file name for the test. + +```json + { + "name": "origin-only", + "title": "Referrer Policy is set to 'origin-only'", + "description": "Check that all sub-resources in all cases get only the origin portion of the referrer URL.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin", + "referrer_policy": "origin", + "test_expansion": [ + { + "name": "generic", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": "*", + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "origin" + } + ] + } +``` + +**NOTE:** An expansion is always constructive (inclusive), there isn't a negation operator for explicit exclusion. Be aware that using an empty list ```[]``` matches (expands into) exactly nothing. Tests which are to be excluded should be defined in the ```excluded_tests``` section instead. + +A single test expansion pattern, be it a requirement or a suppressed pattern, gets expanded into a list of **selections** as follows: + +* Expand each field's pattern (single, any of, or all) to list of allowed values (defined by the ```test_expansion_schema```) + +* Permute - Recursively enumerate all **selections** accross all fields + +Be aware that if there is more than one pattern expanding into a same selection (which also shares the same ```name``` field), the pattern appearing later in the spec JSON will overwrite a previously generated selection. To make sure this is not undetected when generating, set the value of the ```expansion``` field to ```default``` for an expansion appearing earlier and ```override``` for the one appearing later. + +A **selection** is a single **test instance** (scenario) with explicit values, for example: + +```javascript +var scenario = { + "referrer_policy": "origin-when-crossorigin", + "delivery_method": "meta-referrer", + "redirection": "no-redirect", + "origin": "cross-origin", + "source_protocol": "http", + "target_protocol": "http", + "subresource": "iframe-tag", + "subresource_path": "/_mozilla/mozilla/referrer-policy/generic/subresource/document.py", + "referrer_url": "origin" +}; +``` + +Essentially, this is what gets generated and defines a single test. The scenario is then evaluated by the ```ReferrerPolicyTestCase``` in JS. For the rest of the arranging part, see the ```./generic/template/``` directory and examine ```./generic/tools/generate.py``` to see how the values for the templates are produced. + + +Taking the spec JSON, the generator follows this algorithm: + +* Expand all ```excluded_tests``` to create a blacklist of selections + +* For each specification requirement: Expand the ```test_expansion``` pattern into selections and check each against the blacklist, if not marked as suppresed, generate the test resources for the selection + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js new file mode 100644 index 000000000000..0f76773d1c56 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js @@ -0,0 +1,225 @@ +// NOTE: This method only strips the fragment and is not in accordance to the +// recommended draft specification: +// https://w3c.github.io/webappsec/specs/referrer-policy/#null +// TODO(kristijanburnik): Implement this helper as defined by spec once added +// scenarios for URLs containing username/password/etc. +function stripUrlForUseAsReferrer(url) { + return url.replace(/#.*$/, ""); +} + +function parseUrlQueryString(queryString) { + var queries = queryString.replace(/^\?/, "").split("&"); + var params = {}; + + for (var i in queries) { + var kvp = queries[i].split("="); + params[kvp[0]] = kvp[1]; + } + + return params; +}; + +function appendIframeToBody(url, attributes) { + var iframe = document.createElement("iframe"); + iframe.src = url; + // Extend element with attributes. (E.g. "referrer_policy" or "rel") + if (attributes) { + for (var attr in attributes) { + iframe[attr] = attributes[attr]; + } + } + document.body.appendChild(iframe); + + return iframe; +} + +function loadImage(src, callback, attributes) { + var image = new Image(); + image.crossOrigin = "Anonymous"; + image.onload = function() { + callback(image); + } + image.src = src; + // Extend element with attributes. (E.g. "referrer_policy" or "rel") + if (attributes) { + for (var attr in attributes) { + image[attr] = attributes[attr]; + } + } + document.body.appendChild(image) +} + +function decodeImageData(rgba) { + var rgb = new Uint8ClampedArray(rgba.length); + + // RGBA -> RGB. + var rgb_length = 0; + for (var i = 0; i < rgba.length; ++i) { + // Skip alpha component. + if (i % 4 == 3) + continue; + + // Zero is the string terminator. + if (rgba[i] == 0) + break; + + rgb[rgb_length++] = rgba[i]; + } + + // Remove trailing nulls from data. + rgb = rgb.subarray(0, rgb_length); + var string_data = (new TextDecoder("ascii")).decode(rgb); + + return JSON.parse(string_data); +} + +function decodeImage(url, callback, referrer_policy) { + loadImage(url, function(img) { + var canvas = document.createElement("canvas"); + var context = canvas.getContext('2d'); + context.drawImage(img, 0, 0); + var imgData = context.getImageData(0, 0, img.clientWidth, img.clientHeight); + callback(decodeImageData(imgData.data)) + }, referrer_policy); +} + +function normalizePort(targetPort) { + var defaultPorts = [80, 443]; + var isDefaultPortForProtocol = (defaultPorts.indexOf(targetPort) >= 0); + + return (targetPort == "" || isDefaultPortForProtocol) ? + "" : ":" + targetPort; +} + +function wrapResult(url, server_data) { + return { + location: url, + referrer: server_data.headers.referer, + headers: server_data.headers + } +} + +function queryIframe(url, callback, referrer_policy) { + var x = document.createElement('script'); + x.src = '/common/utils.js'; + x.onerror = function() { console.log('whoops') }; + x.onload = function() { doQuery() }; + document.getElementsByTagName("head")[0].appendChild(x); + + function doQuery() { + var id = token(); + var iframe = appendIframeToBody(url + "&id=" + id, referrer_policy); + iframe.addEventListener("load", function listener() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/_mozilla/mozilla/referrer-policy/generic/subresource/stash.py?id=' + id, true); + xhr.onreadystatechange = function(e) { + if (this.readyState == 4 && this.status == 200) { + var server_data = JSON.parse(this.responseText); + callback(server_data, url); + } + }; + xhr.send(); + iframe.removeEventListener("load", listener); + }); + } +} + +function queryImage(url, callback, referrer_policy) { + decodeImage(url, function(server_data) { + callback(wrapResult(url, server_data), url); + }, referrer_policy) +} + +function queryXhr(url, callback) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.onreadystatechange = function(e) { + if (this.readyState == 4 && this.status == 200) { + var server_data = JSON.parse(this.responseText); + callback(wrapResult(url, server_data), url); + } + }; + xhr.send(); +} + +function queryWorker(url, callback) { + var worker = new Worker(url); + worker.onmessage = function(event) { + var server_data = event.data; + callback(wrapResult(url, server_data), url); + }; +} + +function queryFetch(url, callback) { + fetch(url).then(function(response) { + response.json().then(function(server_data) { + callback(wrapResult(url, server_data), url); + }); + } + ); +} + +function queryNavigable(element, url, callback, attributes) { + var navigable = element + navigable.href = url; + navigable.target = "helper-iframe"; + + var helperIframe = document.createElement("iframe") + helperIframe.name = "helper-iframe" + document.body.appendChild(helperIframe) + + // Extend element with attributes. (E.g. "referrer_policy" or "rel") + if (attributes) { + for (var attr in attributes) { + navigable[attr] = attributes[attr]; + } + } + + var listener = function(event) { + if (event.source != helperIframe.contentWindow) + return; + + callback(event.data, url); + window.removeEventListener("message", listener); + } + window.addEventListener("message", listener); + + navigable.click(); +} + +function queryLink(url, callback, referrer_policy) { + var a = document.createElement("a"); + a.innerHTML = "Link to subresource"; + document.body.appendChild(a); + queryNavigable(a, url, callback, referrer_policy) +} + +function queryAreaLink(url, callback, referrer_policy) { + var area = document.createElement("area"); + // TODO(kristijanburnik): Append to map and add image. + document.body.appendChild(area); + queryNavigable(area, url, callback, referrer_policy) +} + +function queryScript(url, callback) { + var script = document.createElement("script"); + script.src = url; + + var listener = function(event) { + var server_data = event.data; + callback(wrapResult(url, server_data), url); + window.removeEventListener("message", listener); + } + window.addEventListener("message", listener); + + document.body.appendChild(script); +} + + // SanityChecker does nothing in release mode. +function SanityChecker() {} +SanityChecker.prototype.checkScenario = function() {}; +SanityChecker.prototype.checkSubresourceResult = function() {}; + +// TODO(kristijanburnik): document.origin is supported since Chrome 41, +// other browsers still don't support it. Remove once they do. +document.origin = document.origin || (location.protocol + "//" + location.host); diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js new file mode 100644 index 000000000000..8e011be374f3 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js @@ -0,0 +1,126 @@ +function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) { + // Pass and skip rest of the test if browser does not support fetch. + if (scenario.subresource == "fetch-request" && !window.fetch) { + // TODO(kristijanburnik): This should be refactored. + return { + start: function() { + test(function() { assert_true(true); }, + "[ReferrerPolicyTestCase] Skipping test: Fetch is not supported."); + } + }; + } + + // This check is A NOOP in release. + sanityChecker.checkScenario(scenario); + + var subresourceInvoker = { + "a-tag": queryLink, + "area-tag": queryAreaLink, + "fetch-request": queryFetch, + "iframe-tag": queryIframe, + "img-tag": queryImage, + "script-tag": queryScript, + "worker-request": queryWorker, + "xhr-request": queryXhr + }; + + var referrerUrlResolver = { + "omitted": function() { + return undefined; + }, + "origin": function() { + return document.origin + "/"; + }, + "stripped-referrer": function() { + return stripUrlForUseAsReferrer(location.toString()); + } + }; + + var t = { + _scenario: scenario, + _testDescription: testDescription, + _subresourceUrl: null, + _expectedReferrerUrl: null, + _constructSubresourceUrl: function() { + // TODO(kristijanburnik): We should assert that these two domains are + // different. E.g. If someone runs the tets over www, this would fail. + var domainForOrigin = { + "cross-origin":"{{domains[www1]}}", + "same-origin": location.hostname + }; + + // Values obtained and replaced by the wptserve pipeline: + // http://wptserve.readthedocs.org/en/latest/pipes.html#built-in-pipes + var portForProtocol = { + "http": parseInt("{{ports[http][0]}}"), + "https": parseInt("{{ports[https][0]}}") + } + + var targetPort = portForProtocol[t._scenario.target_protocol]; + + t._subresourceUrl = t._scenario.target_protocol + "://" + + domainForOrigin[t._scenario.origin] + + normalizePort(targetPort) + + t._scenario["subresource_path"] + + "?redirection=" + t._scenario["redirection"] + + "&cache_destroyer=" + (new Date()).getTime(); + }, + + _constructExpectedReferrerUrl: function() { + t._expectedReferrerUrl = referrerUrlResolver[t._scenario.referrer_url](); + }, + + _invokeSubresource: function(callback) { + var invoker = subresourceInvoker[t._scenario.subresource]; + + // Depending on the delivery method, extend the subresource element with + // these attributes. + var elementAttributesForDeliveryMethod = { + "attr-referrer": {referrerpolicy: t._scenario.referrer_policy}, + "rel-noreferrer": {rel: "noreferrer"} + }; + + var delivery_method = t._scenario.delivery_method; + + if (delivery_method in elementAttributesForDeliveryMethod) { + invoker(t._subresourceUrl, + callback, + elementAttributesForDeliveryMethod[delivery_method]); + } else { + invoker(t._subresourceUrl, callback); + } + + }, + + start: function() { + t._constructSubresourceUrl(); + t._constructExpectedReferrerUrl(); + + var test = async_test(t._testDescription); + + t._invokeSubresource(function(result) { + // Check if the result is in valid format. NOOP in release. + sanityChecker.checkSubresourceResult( + test, t._scenario, t._subresourceUrl, result); + + // Check the reported URL. + test.step(function() { + // TODO - can uncomment when Document::Referrer is implemented + // assert_equals(result.referrer, + // t._expectedReferrerUrl, + // "Reported Referrer URL is '" + + // t._scenario.referrer_url + "'."); + assert_equals(result.headers.referer, + t._expectedReferrerUrl, + "Reported Referrer URL from HTTP header is '" + + t._expectedReferrerUrl + "'"); + }, "Reported Referrer URL is as expected: " + t._scenario.referrer_url); + + test.done(); + }) + + } + } + + return t; +} diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/sanity-checker.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/sanity-checker.js new file mode 100644 index 000000000000..e0714885ffcc --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/sanity-checker.js @@ -0,0 +1,52 @@ +// The SanityChecker is used in debug mode to identify problems with the +// structure of the testsuite. In release mode it is mocked out to do nothing. + +function SanityChecker() {} + +SanityChecker.prototype.checkScenario = function(scenario) { + // Check if scenario is valid. + // TODO(kristijanburnik): Move to a sanity-checks.js for debug mode only. + test(function() { + + // We extend the exsiting test_expansion_schema not to kill performance by + // copying. + var expectedFields = SPEC_JSON["test_expansion_schema"]; + expectedFields["referrer_policy"] = SPEC_JSON["referrer_policy_schema"]; + + assert_own_property(scenario, "subresource_path", + "Scenario has the path to the subresource."); + + for (var field in expectedFields) { + assert_own_property(scenario, field, + "The scenario contains field " + field) + assert_in_array(scenario[field], expectedFields[field], + "Scenario's " + field + " is one of: " + + expectedFields[field].join(", ")) + "." + } + + // Check if the protocol is matched. + assert_equals(scenario["source_protocol"] + ":", location.protocol, + "Protocol of the test page should match the scenario.") + + }, "[ReferrerPolicyTestCase] The test scenario is valid."); +} + +SanityChecker.prototype.checkSubresourceResult = function(test, + scenario, + subresourceUrl, + result) { + test.step(function() { + assert_equals(Object.keys(result).length, 3); + assert_own_property(result, "location"); + assert_own_property(result, "referrer"); + assert_own_property(result, "headers"); + + // Skip location check for scripts. + if (scenario.subresource == "script-tag") + return; + + // Sanity check: location of sub-resource matches reported location. + assert_equals(result.location, subresourceUrl, + "Subresource reported location."); + }, "Running a valid test scenario."); +}; diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/__init__.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py new file mode 100644 index 000000000000..b2d6c4dfabea --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py @@ -0,0 +1,12 @@ +import os, json, sys +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + +import subresource + +def generate_payload(server_data): + return subresource.get_template("document.html.template") % server_data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload) diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/image.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/image.py new file mode 100644 index 000000000000..7d7a7a17be69 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/image.py @@ -0,0 +1,100 @@ +import os, sys, array, json, math, cStringIO +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import subresource + +class Image: + """This class partially implements the interface of the PIL.Image.Image. + One day in the future WPT might support the PIL module or another imaging + library, so this hacky BMP implementation will no longer be required. + """ + def __init__(self, width, height): + self.width = width + self.height = height + self.img = bytearray([0 for i in range(3 * width * height)]) + + @staticmethod + def new(mode, size, color=0): + return Image(size[0], size[1]) + + def _int_to_bytes(self, number): + packed_bytes = [0, 0, 0, 0] + for i in range(4): + packed_bytes[i] = number & 0xFF + number >>= 8 + + return packed_bytes + + def putdata(self, color_data): + for y in range(self.height): + for x in range(self.width): + i = x + y * self.width + if i > len(color_data) - 1: + return + + self.img[i * 3: i * 3 + 3] = color_data[i][::-1] + + def save(self, f, type): + assert type == "BMP" + # 54 bytes of preambule + image color data. + filesize = 54 + 3 * self.width * self.height; + # 14 bytes of header. + bmpfileheader = bytearray(['B', 'M'] + self._int_to_bytes(filesize) + + [0, 0, 0, 0, 54, 0, 0, 0]) + # 40 bytes of info. + bmpinfoheader = bytearray([40, 0, 0, 0] + + self._int_to_bytes(self.width) + + self._int_to_bytes(self.height) + + [1, 0, 24] + (25 * [0])) + + padlength = (4 - (self.width * 3) % 4) % 4 + bmppad = bytearray([0, 0, 0]); + padding = bmppad[0 : padlength] + + f.write(bmpfileheader) + f.write(bmpinfoheader) + + for i in range(self.height): + offset = self.width * (self.height - i - 1) * 3 + f.write(self.img[offset : offset + 3 * self.width]) + f.write(padding) + +def encode_string_as_bmp_image(string_data): + data_bytes = array.array("B", string_data) + num_bytes = len(data_bytes) + + # Convert data bytes to color data (RGB). + color_data = [] + num_components = 3 + rgb = [0] * num_components + i = 0 + for byte in data_bytes: + component_index = i % num_components + rgb[component_index] = byte + if component_index == (num_components - 1) or i == (num_bytes - 1): + color_data.append(tuple(rgb)) + rgb = [0] * num_components + i += 1 + + # Render image. + num_pixels = len(color_data) + sqrt = int(math.ceil(math.sqrt(num_pixels))) + img = Image.new("RGB", (sqrt, sqrt), "black") + img.putdata(color_data) + + # Flush image to string. + f = cStringIO.StringIO() + img.save(f, "BMP") + f.seek(0) + + return f.read() + +def generate_payload(server_data): + data = ('{"headers": %(headers)s}') % server_data + return encode_string_as_bmp_image(data) + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + content_type = "image/bmp", + access_control_allow_origin = "*") diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/script.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/script.py new file mode 100644 index 000000000000..efa1a955d466 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/script.py @@ -0,0 +1,13 @@ +import os, sys, json +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import subresource + +def generate_payload(server_data): + return subresource.get_template("script.js.template") % server_data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + content_type = "application/javascript") + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/stash.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/stash.py new file mode 100644 index 000000000000..0fecca158bbb --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/stash.py @@ -0,0 +1,6 @@ +def main(request, response): + print request.GET['id'] + if request.method == 'POST': + request.server.stash.put(request.GET["id"], request.body) + return '' + return request.server.stash.take(request.GET["id"]) diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/subresource.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/subresource.py new file mode 100644 index 000000000000..ca688deebea3 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/subresource.py @@ -0,0 +1,95 @@ +import os, sys, json, urlparse, urllib + +def get_template(template_basename): + script_directory = os.path.dirname(os.path.abspath(__file__)) + template_directory = os.path.abspath(os.path.join(script_directory, + "..", + "template")) + template_filename = os.path.join(template_directory, template_basename); + + with open(template_filename) as f: + return f.read() + +# TODO(kristijanburnik): subdomain_prefix is a hardcoded value aligned with +# referrer-policy-test-case.js. The prefix should be configured in one place. +def get_swapped_origin_netloc(netloc, subdomain_prefix = "www1."): + if netloc.startswith(subdomain_prefix): + return netloc[len(subdomain_prefix):] + else: + return subdomain_prefix + netloc + +def create_redirect_url(request, cross_origin = False): + parsed = urlparse.urlsplit(request.url) + destination_netloc = parsed.netloc + if cross_origin: + destination_netloc = get_swapped_origin_netloc(parsed.netloc) + + query = filter(lambda x: x.startswith('id='), parsed.query.split('&')) + destination_url = urlparse.urlunsplit(urlparse.SplitResult( + scheme = parsed.scheme, + netloc = destination_netloc, + path = parsed.path, + query = query[0] if query else None, + fragment = None)) + + return destination_url + + +def redirect(url, response): + response.add_required_headers = False + response.writer.write_status(301) + response.writer.write_header("access-control-allow-origin", "*") + response.writer.write_header("location", url) + response.writer.end_headers() + response.writer.write("") + + +def preprocess_redirection(request, response): + if "redirection" not in request.GET: + return False + + redirection = request.GET["redirection"] + + if redirection == "no-redirect": + return False + elif redirection == "keep-origin-redirect": + redirect_url = create_redirect_url(request, cross_origin = False) + elif redirection == "swap-origin-redirect": + redirect_url = create_redirect_url(request, cross_origin = True) + else: + raise ValueError("Invalid redirection type '%s'" % redirection) + + redirect(redirect_url, response) + return True + + +def __noop(request, response): + return "" + + +def respond(request, + response, + status_code = 200, + content_type = "text/html", + payload_generator = __noop, + cache_control = "no-cache; must-revalidate", + access_control_allow_origin = "*"): + if preprocess_redirection(request, response): + return + + response.add_required_headers = False + response.writer.write_status(status_code) + + if access_control_allow_origin != None: + response.writer.write_header("access-control-allow-origin", + access_control_allow_origin) + response.writer.write_header("content-type", content_type) + response.writer.write_header("cache-control", cache_control) + response.writer.end_headers() + + server_data = {"headers": json.dumps(request.headers, indent = 4)} + + payload = payload_generator(server_data) + response.writer.write(payload) + + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/worker.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/worker.py new file mode 100644 index 000000000000..895bc0d84d12 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/worker.py @@ -0,0 +1,12 @@ +import os, sys, json +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import subresource + +def generate_payload(server_data): + return subresource.get_template("worker.js.template") % server_data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + content_type = "application/javascript") diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/xhr.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/xhr.py new file mode 100755 index 000000000000..45f38159c2ec --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/xhr.py @@ -0,0 +1,15 @@ +import os, sys, json +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import subresource + +def generate_payload(server_data): + data = ('{"headers": %(headers)s}') % server_data + return data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + access_control_allow_origin = "*", + content_type = "application/json") + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/disclaimer.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/disclaimer.template new file mode 100644 index 000000000000..66c43ed6f213 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/disclaimer.template @@ -0,0 +1 @@ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/document.html.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/document.html.template new file mode 100644 index 000000000000..ad4f4690109b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/document.html.template @@ -0,0 +1,31 @@ + + + + This page reports back it's request details to the parent frame + + + + + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/script.js.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/script.js.template new file mode 100644 index 000000000000..e2edf21819df --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/script.js.template @@ -0,0 +1,3 @@ +postMessage({ + "headers": %(headers)s +}, "*"); diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/spec_json.js.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/spec_json.js.template new file mode 100644 index 000000000000..e4cbd0342596 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/spec_json.js.template @@ -0,0 +1 @@ +var SPEC_JSON = %(spec_json)s; diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.debug.html.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.debug.html.template new file mode 100644 index 000000000000..a92e460e9344 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.debug.html.template @@ -0,0 +1,70 @@ + +%(generated_disclaimer)s + + + Referrer-Policy: %(spec_title)s%(meta_delivery_method)s + + + + + + + + + + + + + + +

%(spec_title)s

+

%(spec_description)s

+ +

+ +

+ +

See specification + details for this test.

+ +

Scenario outline

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Delivery method%(delivery_method)s
Redirection%(redirection)s
Origin transition%(origin)s
Protocol transitionfrom %(source_protocol)s to %(target_protocol)s
Subresource type%(subresource)s

Expected resultReferrer URL should be %(referrer_url)s
+ + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.js.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.js.template new file mode 100644 index 000000000000..4b01d4d113a8 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.js.template @@ -0,0 +1,15 @@ +ReferrerPolicyTestCase( + { + "referrer_policy": %(referrer_policy_json)s, + "delivery_method": "%(delivery_method)s", + "redirection": "%(redirection)s", + "origin": "%(origin)s", + "source_protocol": "%(source_protocol)s", + "target_protocol": "%(target_protocol)s", + "subresource": "%(subresource)s", + "subresource_path": "%(subresource_path)s", + "referrer_url": "%(referrer_url)s" + }, + document.querySelector("meta[name=assert]").content, + new SanityChecker() +).start(); diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.release.html.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.release.html.template new file mode 100644 index 000000000000..b2523fb045dc --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test.release.html.template @@ -0,0 +1,20 @@ + +%(generated_disclaimer)s + + + Referrer-Policy: %(spec_title)s + %(meta_delivery_method)s + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test_description.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test_description.template new file mode 100644 index 000000000000..fbc80bb25af6 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/test_description.template @@ -0,0 +1,5 @@ +The referrer URL is %(referrer_url)s when a +document served over %(source_protocol)s requires an %(target_protocol)s +sub-resource via %(subresource)s using the %(delivery_method)s +delivery method with %(redirection)s and when +the target request is %(origin)s. diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/worker.js.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/worker.js.template new file mode 100644 index 000000000000..817dd8c87ac8 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/worker.js.template @@ -0,0 +1,3 @@ +postMessage({ + "headers": %(headers)s +}); diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/__init__.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/clean.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/clean.py new file mode 100755 index 000000000000..715e1d6ae4b5 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/clean.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import os, json +from common_paths import * +import spec_validator + +def rmtree(top): + top = os.path.abspath(top) + assert top != os.path.expanduser("~") + assert len(top) > len(os.path.expanduser("~")) + assert "web-platform-tests" in top + assert "referrer-policy" in top + + for root, dirs, files in os.walk(top, topdown=False): + for name in files: + os.remove(os.path.join(root, name)) + for name in dirs: + os.rmdir(os.path.join(root, name)) + + os.rmdir(top) + +def main(): + spec_json = load_spec_json(); + spec_validator.assert_valid_spec_json(spec_json) + + for spec in spec_json['specification']: + generated_dir = os.path.join(spec_directory, spec["name"]) + if (os.path.isdir(generated_dir)): + rmtree(generated_dir) + + if (os.path.isfile(generated_spec_json_filename)): + os.remove(generated_spec_json_filename) + +if __name__ == '__main__': + main() diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/common_paths.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/common_paths.py new file mode 100644 index 000000000000..4626223c4c56 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/common_paths.py @@ -0,0 +1,52 @@ +import os, sys, json, re + +script_directory = os.path.dirname(os.path.abspath(__file__)) +generic_directory = os.path.abspath(os.path.join(script_directory, '..')) + +template_directory = os.path.abspath(os.path.join(script_directory, + '..', + 'template')) +spec_directory = os.path.abspath(os.path.join(script_directory, '..', '..')) +test_root_directory = os.path.abspath(os.path.join(script_directory, + '..', '..', '..')) + +spec_filename = os.path.join(spec_directory, "spec.src.json") +generated_spec_json_filename = os.path.join(spec_directory, "spec_json.js") + +selection_pattern = '%(delivery_method)s/' + \ + '%(origin)s/' + \ + '%(source_protocol)s-%(target_protocol)s/' + \ + '%(subresource)s/' + +test_file_path_pattern = '%(spec_name)s/' + selection_pattern + \ + '%(name)s.%(redirection)s.%(source_protocol)s.html' + + +def get_template(basename): + with open(os.path.join(template_directory, basename)) as f: + return f.read() + + +def read_nth_line(fp, line_number): + fp.seek(0) + for i, line in enumerate(fp): + if (i + 1) == line_number: + return line + + +def load_spec_json(): + re_error_location = re.compile('line ([0-9]+) column ([0-9]+)') + with open(spec_filename) as f: + try: + spec_json = json.load(f) + except ValueError, ex: + print ex.message + match = re_error_location.search(ex.message) + if match: + line_number, column = int(match.group(1)), int(match.group(2)) + print read_nth_line(f, line_number).rstrip() + print " " * (column - 1) + "^" + + sys.exit(1) + + return spec_json diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py new file mode 100755 index 000000000000..cc5af2a75c6e --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/generate.py @@ -0,0 +1,176 @@ +#!/usr/bin/env python + +import os, sys, json +from common_paths import * +import spec_validator +import argparse + + +def expand_test_expansion_pattern(spec_test_expansion, test_expansion_schema): + expansion = {} + for artifact in spec_test_expansion: + artifact_value = spec_test_expansion[artifact] + if artifact_value == '*': + expansion[artifact] = test_expansion_schema[artifact] + elif isinstance(artifact_value, list): + expansion[artifact] = artifact_value + else: + expansion[artifact] = [artifact_value] + + return expansion + + +def permute_expansion(expansion, selection = {}, artifact_index = 0): + artifact_order = ['delivery_method', 'redirection', 'origin', + 'source_protocol', 'target_protocol', 'subresource', + 'referrer_url', 'name'] + + if artifact_index >= len(artifact_order): + yield selection + return + + artifact_key = artifact_order[artifact_index] + + for artifact_value in expansion[artifact_key]: + selection[artifact_key] = artifact_value + for next_selection in permute_expansion(expansion, + selection, + artifact_index + 1): + yield next_selection + + +def generate_selection(selection, spec, subresource_path, + test_html_template_basename): + selection['spec_name'] = spec['name'] + selection['spec_title'] = spec['title'] + selection['spec_description'] = spec['description'] + selection['spec_specification_url'] = spec['specification_url'] + selection['subresource_path'] = subresource_path + # Oddball: it can be None, so in JS it's null. + selection['referrer_policy_json'] = json.dumps(spec['referrer_policy']) + + test_filename = test_file_path_pattern % selection + test_directory = os.path.dirname(test_filename) + full_path = os.path.join(spec_directory, test_directory) + + test_html_template = get_template(test_html_template_basename) + test_js_template = get_template("test.js.template") + disclaimer_template = get_template('disclaimer.template') + test_description_template = get_template("test_description.template") + + html_template_filename = os.path.join(template_directory, + test_html_template_basename) + generated_disclaimer = disclaimer_template \ + % {'generating_script_filename': os.path.relpath(__file__, + test_root_directory), + 'html_template_filename': os.path.relpath(html_template_filename, + test_root_directory)} + + # Adjust the template for the test invoking JS. Indent it to look nice. + selection['generated_disclaimer'] = generated_disclaimer.rstrip() + test_description_template = \ + test_description_template.rstrip().replace("\n", "\n" + " " * 33) + selection['test_description'] = test_description_template % selection + + # Adjust the template for the test invoking JS. Indent it to look nice. + indent = "\n" + " " * 6; + test_js_template = indent + test_js_template.replace("\n", indent); + selection['test_js'] = test_js_template % selection + + # Directory for the test files. + try: + os.makedirs(full_path) + except: + pass + + selection['meta_delivery_method'] = '' + + if spec['referrer_policy'] != None: + if selection['delivery_method'] == 'meta-referrer': + selection['meta_delivery_method'] = \ + '' % spec + elif selection['delivery_method'] == 'meta-csp': + selection['meta_delivery_method'] = \ + '' % spec + elif selection['delivery_method'] == 'http-csp': + selection['meta_delivery_method'] = \ + "" + test_headers_filename = test_filename + ".headers" + with open(test_headers_filename, "w") as f: + f.write('Content-Security-Policy: ' + \ + 'referrer %(referrer_policy)s\n' % spec) + # TODO(kristijanburnik): Limit to WPT origins. + f.write('Access-Control-Allow-Origin: *\n') + elif selection['delivery_method'] == 'attr-referrer': + # attr-referrer is supported by the JS test wrapper. + pass + elif selection['delivery_method'] == 'rel-noreferrer': + # rel=noreferrer is supported by the JS test wrapper. + pass + else: + raise ValueError('Not implemented delivery_method: ' \ + + selection['delivery_method']) + + # Obey the lint and pretty format. + if len(selection['meta_delivery_method']) > 0: + selection['meta_delivery_method'] = "\n " + \ + selection['meta_delivery_method'] + + with open(test_filename, 'w') as f: + f.write(test_html_template % selection) + + +def generate_test_source_files(spec_json, target): + test_expansion_schema = spec_json['test_expansion_schema'] + specification = spec_json['specification'] + + spec_json_js_template = get_template('spec_json.js.template') + with open(generated_spec_json_filename, 'w') as f: + f.write(spec_json_js_template + % {'spec_json': json.dumps(spec_json)}) + + # Choose a debug/release template depending on the target. + html_template = "test.%s.html.template" % target + + # Create list of excluded tests. + exclusion_dict = {} + for excluded_pattern in spec_json['excluded_tests']: + excluded_expansion = \ + expand_test_expansion_pattern(excluded_pattern, + test_expansion_schema) + for excluded_selection in permute_expansion(excluded_expansion): + excluded_selection_path = selection_pattern % excluded_selection + exclusion_dict[excluded_selection_path] = True + + for spec in specification: + for spec_test_expansion in spec['test_expansion']: + expansion = expand_test_expansion_pattern(spec_test_expansion, + test_expansion_schema) + for selection in permute_expansion(expansion): + selection_path = selection_pattern % selection + if not selection_path in exclusion_dict: + subresource_path = \ + spec_json["subresource_path"][selection["subresource"]] + generate_selection(selection, + spec, + subresource_path, + html_template) + else: + print 'Excluding selection:', selection_path + + +def main(target): + spec_json = load_spec_json(); + spec_validator.assert_valid_spec_json(spec_json) + generate_test_source_files(spec_json, target) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Test suite generator utility') + parser.add_argument('-t', '--target', type = str, + choices = ("release", "debug"), default = "release", + help = 'Sets the appropriate template for generating tests') + # TODO(kristijanburnik): Add option for the spec_json file. + args = parser.parse_args() + main(args.target) diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/regenerate b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/regenerate new file mode 100755 index 000000000000..e6bd63519b33 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/regenerate @@ -0,0 +1,3 @@ +#!/bin/bash +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +python $DIR/clean.py && python $DIR/generate.py diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/spec_validator.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/spec_validator.py new file mode 100755 index 000000000000..8641bbc1f165 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/tools/spec_validator.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python + +import json, sys +from common_paths import * + +def assert_non_empty_string(obj, field): + assert field in obj, 'Missing field "%s"' % field + assert isinstance(obj[field], basestring), \ + 'Field "%s" must be a string' % field + assert len(obj[field]) > 0, 'Field "%s" must not be empty' % field + +def assert_non_empty_list(obj, field): + assert isinstance(obj[field], list), \ + '%s must be a list' % field + assert len(obj[field]) > 0, \ + '%s list must not be empty' % field + +def assert_non_empty_dict(obj, field): + assert isinstance(obj[field], dict), \ + '%s must be a dict' % field + assert len(obj[field]) > 0, \ + '%s dict must not be empty' % field + +def assert_contains(obj, field): + assert field in obj, 'Must contain field "%s"' % field + +def assert_value_from(obj, field, items): + assert obj[field] in items, \ + 'Field "%s" must be from: %s' % (field, str(items)) + +def assert_atom_or_list_items_from(obj, field, items): + if isinstance(obj[field], basestring) or isinstance(obj[field], int): + assert_value_from(obj, field, items) + return + + assert_non_empty_list(obj, field) + for allowed_value in obj[field]: + assert allowed_value != '*', "Wildcard is not supported for lists!" + assert allowed_value in items, \ + 'Field "%s" must be from: %s' % (field, str(items)) + +def assert_contains_only_fields(obj, expected_fields): + for expected_field in expected_fields: + assert_contains(obj, expected_field) + + for actual_field in obj: + assert actual_field in expected_fields, \ + 'Unexpected field "%s".' % actual_field + +def assert_value_unique_in(value, used_values): + assert value not in used_values, 'Duplicate value "%s"!' % str(value) + used_values[value] = True + + +def validate(spec_json, details): + """ Validates the json specification for generating tests. """ + + details['object'] = spec_json + assert_contains_only_fields(spec_json, ["specification", + "referrer_policy_schema", + "test_expansion_schema", + "subresource_path", + "excluded_tests"]) + assert_non_empty_list(spec_json, "specification") + assert_non_empty_list(spec_json, "referrer_policy_schema") + assert_non_empty_dict(spec_json, "test_expansion_schema") + assert_non_empty_list(spec_json, "excluded_tests") + + specification = spec_json['specification'] + referrer_policy_schema = spec_json['referrer_policy_schema'] + test_expansion_schema = spec_json['test_expansion_schema'] + excluded_tests = spec_json['excluded_tests'] + subresource_path = spec_json['subresource_path'] + + valid_test_expansion_fields = ['name'] + test_expansion_schema.keys() + + # Validate each single spec. + for spec in specification: + details['object'] = spec + + # Validate required fields for a single spec. + assert_contains_only_fields(spec, ['name', + 'title', + 'description', + 'referrer_policy', + 'specification_url', + 'test_expansion']) + assert_non_empty_string(spec, 'name') + assert_non_empty_string(spec, 'title') + assert_non_empty_string(spec, 'description') + assert_non_empty_string(spec, 'specification_url') + assert_value_from(spec, 'referrer_policy', referrer_policy_schema) + assert_non_empty_list(spec, 'test_expansion') + + # Validate spec's test expansion. + used_spec_names = {} + + for spec_exp in spec['test_expansion']: + details['object'] = spec_exp + assert_non_empty_string(spec_exp, 'name') + # The name is unique in same expansion group. + assert_value_unique_in((spec_exp['expansion'], spec_exp['name']), + used_spec_names) + assert_contains_only_fields(spec_exp, valid_test_expansion_fields) + + for artifact in test_expansion_schema: + details['test_expansion_field'] = artifact + assert_atom_or_list_items_from( + spec_exp, artifact, ['*'] + test_expansion_schema[artifact]) + del details['test_expansion_field'] + + # Validate the test_expansion schema members. + details['object'] = test_expansion_schema + assert_contains_only_fields(test_expansion_schema, ['expansion', + 'delivery_method', + 'redirection', + 'origin', + 'source_protocol', + 'target_protocol', + 'subresource', + 'referrer_url']) + # Validate excluded tests. + details['object'] = excluded_tests + for excluded_test_expansion in excluded_tests: + assert_contains_only_fields(excluded_test_expansion, + valid_test_expansion_fields) + details['object'] = excluded_test_expansion + for artifact in test_expansion_schema: + details['test_expansion_field'] = artifact + assert_atom_or_list_items_from( + excluded_test_expansion, + artifact, + ['*'] + test_expansion_schema[artifact]) + del details['test_expansion_field'] + + # Validate subresource paths. + details['object'] = subresource_path + assert_contains_only_fields(subresource_path, + test_expansion_schema['subresource']); + + for subresource in subresource_path: + local_rel_path = "." + subresource_path[subresource] + full_path = os.path.join(test_root_directory, local_rel_path) + assert os.path.isfile(full_path), "%s is not an existing file" % path + + del details['object'] + + +def assert_valid_spec_json(spec_json): + error_details = {} + try: + validate(spec_json, error_details) + except AssertionError, err: + print 'ERROR:', err.message + print json.dumps(error_details, indent=4) + sys.exit(1) + + +def main(): + spec_json = load_spec_json(); + assert_valid_spec_json(spec_json) + print "Spec JSON is valid." + + +if __name__ == '__main__': + main() diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html new file mode 100644 index 000000000000..179c03344857 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html new file mode 100644 index 000000000000..e7717ff743f6 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html new file mode 100644 index 000000000000..cde5bbbe45ef --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html new file mode 100644 index 000000000000..5e82dd6660fb --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html new file mode 100644 index 000000000000..6b020ac40a35 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html new file mode 100644 index 000000000000..3302a80fb1cb --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer-when-downgrade' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html new file mode 100644 index 000000000000..5999254dd292 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html new file mode 100644 index 000000000000..9761d2f3d370 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html new file mode 100644 index 000000000000..62dddfb6b28f --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html new file mode 100644 index 000000000000..02d4381010b6 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html new file mode 100644 index 000000000000..c6170f39f49e --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html new file mode 100644 index 000000000000..e1bddd53a975 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'no-referrer' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html new file mode 100644 index 000000000000..1142fc37e8c2 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-only' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html new file mode 100644 index 000000000000..a32f7c82ef88 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-only' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html new file mode 100644 index 000000000000..610fa2bd4123 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-only' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html new file mode 100644 index 000000000000..b6c78c6322d2 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-only' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html new file mode 100644 index 000000000000..8242004ef445 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-only' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html new file mode 100644 index 000000000000..b6f068579151 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-only' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html new file mode 100644 index 000000000000..93a16a5420a5 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html new file mode 100644 index 000000000000..a6868525db4a --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html new file mode 100644 index 000000000000..17aad800932c --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html new file mode 100644 index 000000000000..13b55072baab --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html new file mode 100644 index 000000000000..b6e97f388ed3 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html new file mode 100644 index 000000000000..3d4f71d11b61 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json b/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json new file mode 100644 index 000000000000..1c793c3364bd --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec.src.json @@ -0,0 +1,400 @@ +{ + "specification": [ + { + "name": "unset-referrer-policy", + "title": "Referrer Policy is not explicitly defined", + "description": "Check that sub-resource gets the referrer URL when no explicit Referrer Policy is set.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-states", + "referrer_policy": null, + "test_expansion": [ + { + "name": "generic", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "stripped-referrer" + } + ] + }, + { + "name": "no-referrer", + "title": "Referrer Policy is set to 'no-referrer'", + "description": "Check that sub-resource never gets the referrer URL.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-no-referrer", + "referrer_policy": "no-referrer", + "test_expansion": [ + { + "name": "generic", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "omitted" + } + ] + }, + { + "name": "no-referrer-when-downgrade", + "title": "Referrer Policy is set to 'no-referrer-when-downgrade'", + "description": "Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-no-referrer-when-downgrade", + "referrer_policy": "no-referrer-when-downgrade", + "test_expansion": [ + { + "name": "insecure-protocol", + "expansion": "default", + "source_protocol": "http", + "target_protocol": "http", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "stripped-referrer" + }, + { + "name": "upgrade-protocol", + "expansion": "default", + "source_protocol": "http", + "target_protocol": "https", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "stripped-referrer" + }, + { + "name": "downgrade-protocol", + "expansion": "default", + "source_protocol": "https", + "target_protocol": "http", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "origin" + }, + { + "name": "secure-protocol", + "expansion": "default", + "source_protocol": "https", + "target_protocol": "https", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "stripped-referrer" + } + ] + }, + { + "name": "origin-only", + "title": "Referrer Policy is set to 'origin-only'", + "description": "Check that all subresources in all casses get only the origin portion of the referrer URL.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin", + "referrer_policy": "origin", + "test_expansion": [ + { + "name": "generic", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "origin" + } + ] + }, + { + "name": "origin-when-cross-origin", + "title": "Referrer Policy is set to 'origin-when-crossorigin'", + "description": "Check that cross-origin subresources get the origin portion of the referrer URL and same-origin get the stripped referrer URL.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin-when-cross-origin", + "referrer_policy": "origin-when-crossorigin", + "test_expansion": [ + { + "name": "same-origin-insecure", + "expansion": "default", + "source_protocol": "http", + "target_protocol": "http", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "same-origin", + "subresource": "*", + "referrer_url": "stripped-referrer" + }, + { + "name": "same-origin-secure-default", + "expansion": "default", + "source_protocol": "https", + "target_protocol": "https", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "same-origin", + "subresource": "*", + "referrer_url": "stripped-referrer" + }, + { + "name": "same-origin-upgrade", + "expansion": "default", + "source_protocol": "http", + "target_protocol": "https", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "same-origin", + "subresource": "*", + "referrer_url": "origin" + }, + { + "name": "same-origin-downgrade", + "expansion": "default", + "source_protocol": "http", + "target_protocol": "https", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "same-origin", + "subresource": "*", + "referrer_url": "origin" + }, + { + "name": "same-origin-insecure", + "expansion": "override", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "swap-origin-redirect", + "origin": "same-origin", + "subresource": "*", + "referrer_url": "origin" + }, + { + "name": "cross-origin", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "cross-origin", + "subresource": "*", + "referrer_url": "origin" + } + ] + }, + { + "name": "unsafe-url", + "title": "Referrer Policy is set to 'unsafe-url'", + "description": "Check that all sub-resources get the stripped referrer URL.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-unsafe-url", + "referrer_policy": "unsafe-url", + "test_expansion": [ + { + "name": "generic", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "stripped-referrer" + } + ] + } + ], + + "excluded_tests":[ + { + "name": "cross-origin-workers", + "expansion": "*", + "source_protocol": "*", + "target_protocol": "*", + "redirection": "*", + "delivery_method": "*", + "origin": "cross-origin", + "subresource": "worker-request", + "referrer_url": "*" + }, + { + "name": "upgraded-protocol-workers", + "expansion": "*", + "source_protocol": "http", + "target_protocol": "https", + "delivery_method": "*", + "redirection": "*", + "origin": "*", + "subresource": "worker-request", + "referrer_url": "*" + }, + { + "name": "mixed-content-insecure-subresources", + "expansion": "*", + "source_protocol": "https", + "target_protocol": "http", + "delivery_method": "*", + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "*" + }, + { + "name": "elements-not-supporting-attr-referrer", + "expansion": "*", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["attr-referrer"], + "redirection": "*", + "origin": "*", + "subresource": [ + "script-tag", + "xhr-request", + "worker-request", + "fetch-request" + ], + "referrer_url": "*" + }, + { + "name": "elements-not-supporting-rel-noreferrer", + "expansion": "*", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": ["rel-noreferrer"], + "redirection": "*", + "origin": "*", + "subresource": [ + "iframe-tag", + "img-tag", + "script-tag", + "xhr-request", + "worker-request", + "fetch-request", + "area-tag" + ], + "referrer_url": "*" + }, + { + "name": "area-tag", + "expansion": "*", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": "*", + "redirection": "*", + "origin": "*", + "subresource": "area-tag", + "referrer_url": "*" + }, + { + "name": "worker-requests-with-swap-origin-redirect", + "expansion": "*", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": "*", + "redirection": "swap-origin-redirect", + "origin": "*", + "subresource": ["worker-request"], + "referrer_url": "*" + }, + { + "name": "overhead-for-redirection", + "expansion": "*", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": "*", + "redirection": ["keep-origin-redirect", "swap-origin-redirect"], + "origin": "*", + "subresource": ["a-tag", "area-tag"], + "referrer_url": "*" + }, + { + "name": "source-https-unsupported-by-web-platform-tests-runners", + "expansion": "*", + "source_protocol": "https", + "target_protocol": "*", + "delivery_method": "*", + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "*" + } + ], + + "referrer_policy_schema": [ + null, + "no-referrer", + "no-referrer-when-downgrade", + "origin", + "origin-when-crossorigin", + "unsafe-url" + ], + + "test_expansion_schema": { + "expansion": [ + "default", + "override" + ], + + "delivery_method": [ + "http-csp", + "meta-referrer", + "meta-csp", + "attr-referrer", + "rel-noreferrer" + ], + + "origin": [ + "same-origin", + "cross-origin" + ], + + "source_protocol": [ + "http", + "https" + ], + + "target_protocol": [ + "http", + "https" + ], + + "redirection": [ + "no-redirect", + "keep-origin-redirect", + "swap-origin-redirect" + ], + + "subresource": [ + "iframe-tag", + "img-tag", + "script-tag", + "a-tag", + "area-tag", + "xhr-request", + "worker-request", + "fetch-request" + ], + + "referrer_url": [ + "omitted", + "origin", + "stripped-referrer" + ] + }, + + "subresource_path": { + "a-tag": "/referrer-policy/generic/subresource/document.py", + "area-tag": "/referrer-policy/generic/subresource/document.py", + "fetch-request": "/referrer-policy/generic/subresource/xhr.py", + "iframe-tag": "/referrer-policy/generic/subresource/document.py", + "img-tag": "/referrer-policy/generic/subresource/image.py", + "script-tag": "/referrer-policy/generic/subresource/script.py", + "worker-request": "/referrer-policy/generic/subresource/worker.py", + "xhr-request": "/referrer-policy/generic/subresource/xhr.py" + } +} diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec_json.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec_json.js new file mode 100644 index 000000000000..399c6bcf8dda --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/spec_json.js @@ -0,0 +1 @@ +var SPEC_JSON = {"subresource_path": {"img-tag": "/referrer-policy/generic/subresource/image.py", "fetch-request": "/referrer-policy/generic/subresource/xhr.py", "a-tag": "/referrer-policy/generic/subresource/document.py", "area-tag": "/referrer-policy/generic/subresource/document.py", "iframe-tag": "/referrer-policy/generic/subresource/document.py", "xhr-request": "/referrer-policy/generic/subresource/xhr.py", "worker-request": "/referrer-policy/generic/subresource/worker.py", "script-tag": "/referrer-policy/generic/subresource/script.py"}, "test_expansion_schema": {"origin": ["same-origin", "cross-origin"], "subresource": ["iframe-tag", "img-tag", "script-tag", "a-tag", "area-tag", "xhr-request", "worker-request", "fetch-request"], "target_protocol": ["http", "https"], "expansion": ["default", "override"], "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer", "rel-noreferrer"], "redirection": ["no-redirect", "keep-origin-redirect", "swap-origin-redirect"], "referrer_url": ["omitted", "origin", "stripped-referrer"], "source_protocol": ["http", "https"]}, "specification": [{"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-states", "referrer_policy": null, "title": "Referrer Policy is not explicitly defined", "test_expansion": [{"origin": "*", "name": "generic", "target_protocol": "*", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "*", "subresource": "*"}], "name": "unset-referrer-policy", "description": "Check that sub-resource gets the referrer URL when no explicit Referrer Policy is set."}, {"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-no-referrer", "referrer_policy": "no-referrer", "title": "Referrer Policy is set to 'no-referrer'", "test_expansion": [{"origin": "*", "name": "generic", "target_protocol": "*", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "omitted", "source_protocol": "*", "subresource": "*"}], "name": "no-referrer", "description": "Check that sub-resource never gets the referrer URL."}, {"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-no-referrer-when-downgrade", "referrer_policy": "no-referrer-when-downgrade", "title": "Referrer Policy is set to 'no-referrer-when-downgrade'", "test_expansion": [{"origin": "*", "name": "insecure-protocol", "target_protocol": "http", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "http", "subresource": "*"}, {"origin": "*", "name": "upgrade-protocol", "target_protocol": "https", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "http", "subresource": "*"}, {"origin": "*", "name": "downgrade-protocol", "target_protocol": "http", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "origin", "source_protocol": "https", "subresource": "*"}, {"origin": "*", "name": "secure-protocol", "target_protocol": "https", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "https", "subresource": "*"}], "name": "no-referrer-when-downgrade", "description": "Check that non a priori insecure subresource gets the full Referrer URL. A priori insecure subresource gets no referrer information."}, {"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin", "referrer_policy": "origin", "title": "Referrer Policy is set to 'origin-only'", "test_expansion": [{"origin": "*", "name": "generic", "target_protocol": "*", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "origin", "source_protocol": "*", "subresource": "*"}], "name": "origin-only", "description": "Check that all subresources in all casses get only the origin portion of the referrer URL."}, {"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin-when-cross-origin", "referrer_policy": "origin-when-crossorigin", "title": "Referrer Policy is set to 'origin-when-crossorigin'", "test_expansion": [{"origin": "same-origin", "name": "same-origin-insecure", "target_protocol": "http", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "http", "subresource": "*"}, {"origin": "same-origin", "name": "same-origin-secure-default", "target_protocol": "https", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "https", "subresource": "*"}, {"origin": "same-origin", "name": "same-origin-upgrade", "target_protocol": "https", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "origin", "source_protocol": "http", "subresource": "*"}, {"origin": "same-origin", "name": "same-origin-downgrade", "target_protocol": "https", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "origin", "source_protocol": "http", "subresource": "*"}, {"origin": "same-origin", "name": "same-origin-insecure", "target_protocol": "*", "expansion": "override", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "swap-origin-redirect", "referrer_url": "origin", "source_protocol": "*", "subresource": "*"}, {"origin": "cross-origin", "name": "cross-origin", "target_protocol": "*", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "origin", "source_protocol": "*", "subresource": "*"}], "name": "origin-when-cross-origin", "description": "Check that cross-origin subresources get the origin portion of the referrer URL and same-origin get the stripped referrer URL."}, {"specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-unsafe-url", "referrer_policy": "unsafe-url", "title": "Referrer Policy is set to 'unsafe-url'", "test_expansion": [{"origin": "*", "name": "generic", "target_protocol": "*", "expansion": "default", "delivery_method": ["http-csp", "meta-referrer", "meta-csp", "attr-referrer"], "redirection": "*", "referrer_url": "stripped-referrer", "source_protocol": "*", "subresource": "*"}], "name": "unsafe-url", "description": "Check that all sub-resources get the stripped referrer URL."}], "referrer_policy_schema": [null, "no-referrer", "no-referrer-when-downgrade", "origin", "origin-when-crossorigin", "unsafe-url"], "excluded_tests": [{"origin": "cross-origin", "name": "cross-origin-workers", "target_protocol": "*", "expansion": "*", "delivery_method": "*", "redirection": "*", "referrer_url": "*", "source_protocol": "*", "subresource": "worker-request"}, {"origin": "*", "name": "upgraded-protocol-workers", "target_protocol": "https", "expansion": "*", "delivery_method": "*", "redirection": "*", "referrer_url": "*", "source_protocol": "http", "subresource": "worker-request"}, {"origin": "*", "name": "mixed-content-insecure-subresources", "target_protocol": "http", "expansion": "*", "delivery_method": "*", "redirection": "*", "referrer_url": "*", "source_protocol": "https", "subresource": "*"}, {"origin": "*", "name": "elements-not-supporting-attr-referrer", "target_protocol": "*", "expansion": "*", "delivery_method": ["attr-referrer"], "redirection": "*", "referrer_url": "*", "source_protocol": "*", "subresource": ["script-tag", "xhr-request", "worker-request", "fetch-request"]}, {"origin": "*", "name": "elements-not-supporting-rel-noreferrer", "target_protocol": "*", "expansion": "*", "delivery_method": ["rel-noreferrer"], "redirection": "*", "referrer_url": "*", "source_protocol": "*", "subresource": ["iframe-tag", "img-tag", "script-tag", "xhr-request", "worker-request", "fetch-request", "area-tag"]}, {"origin": "*", "name": "area-tag", "target_protocol": "*", "expansion": "*", "delivery_method": "*", "redirection": "*", "referrer_url": "*", "source_protocol": "*", "subresource": "area-tag"}, {"origin": "*", "name": "worker-requests-with-swap-origin-redirect", "target_protocol": "*", "expansion": "*", "delivery_method": "*", "redirection": "swap-origin-redirect", "referrer_url": "*", "source_protocol": "*", "subresource": ["worker-request"]}, {"origin": "*", "name": "overhead-for-redirection", "target_protocol": "*", "expansion": "*", "delivery_method": "*", "redirection": ["keep-origin-redirect", "swap-origin-redirect"], "referrer_url": "*", "source_protocol": "*", "subresource": ["a-tag", "area-tag"]}, {"origin": "*", "name": "source-https-unsupported-by-web-platform-tests-runners", "target_protocol": "*", "expansion": "*", "delivery_method": "*", "redirection": "*", "referrer_url": "*", "source_protocol": "https", "subresource": "*"}]}; diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html new file mode 100644 index 000000000000..840d1f2f5b7b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'unsafe-url' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html new file mode 100644 index 000000000000..3eefc3abae5c --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'unsafe-url' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html new file mode 100644 index 000000000000..64fea87e85d9 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'unsafe-url' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html new file mode 100644 index 000000000000..505f87e74335 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'unsafe-url' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html new file mode 100644 index 000000000000..91002e6f637f --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'unsafe-url' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html new file mode 100644 index 000000000000..7f3d996275dd --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html @@ -0,0 +1,41 @@ + + + + + Referrer-Policy: Referrer Policy is set to 'unsafe-url' + + + + + + + + + + + + + +
+ + diff --git a/tests/wpt/web-platform-tests/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html b/tests/wpt/web-platform-tests/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html index 908f92437777..55daf521fb4e 100644 --- a/tests/wpt/web-platform-tests/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html +++ b/tests/wpt/web-platform-tests/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html @@ -2,9 +2,9 @@ - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - + - Referrer-Policy: Referrer Policy is set to 'origin-when-crossorigin' + Referrer-Policy: Referrer Policy is set to 'origin-when-cross-origin' - +