From 2440e0f98ade12cf595fe7c791a1065b29b53d74 Mon Sep 17 00:00:00 2001 From: Russell Cousineau Date: Sun, 24 Mar 2019 23:04:17 -0700 Subject: set referrer in window.load_url - this conforms to follow-hyperlinks spec step 13 - this conforms to window-open spec step 14.3 - replace uses of `referrer_url` with `referrer` - in Request class, change "no-referrer" to "" - set websocket fetch referrer to "no-referrer" --- components/script/dom/htmlanchorelement.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'components/script/dom/htmlanchorelement.rs') diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 982b08f3924..9f64a93c0ca 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -27,6 +27,7 @@ use crate::dom::urlhelper::UrlHelper; use crate::dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; +use net_traits::request::Referrer; use num_traits::ToPrimitive; use servo_url::ServoUrl; use std::default::Default; @@ -639,7 +640,7 @@ pub fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option) { // will have been done as part of Step 7 above // in choose_browsing_context/create_auxiliary_browsing_context. - // Step 10, 11, 12, 13. TODO: if parsing the URL failed, navigate to error page. + // Step 10, 11. TODO: if parsing the URL failed, navigate to error page. let attribute = subject.get_attribute(&ns!(), &local_name!("href")).unwrap(); let mut href = attribute.Value(); // Step 11: append a hyperlink suffix. @@ -657,8 +658,16 @@ pub fn follow_hyperlink(subject: &Element, hyperlink_suffix: Option) { .get_attribute_by_name(DOMString::from_string(String::from("referrerpolicy"))) .and_then(|attribute: DomRoot| (determine_policy_for_token(&attribute.Value()))); - // Step 13, 14. + // Step 13 + let referrer = match subject.get_attribute(&ns!(), &local_name!("rel")) { + Some(ref link_types) if link_types.Value().contains("noreferrer") => { + Referrer::NoReferrer + }, + _ => Referrer::Client, + }; + + // Step 14 debug!("following hyperlink to {}", url); - target_window.load_url(url, replace, false, referrer_policy); + target_window.load_url(url, replace, false, referrer, referrer_policy); }; } -- cgit v1.2.3