aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlanchorelement.rs
diff options
context:
space:
mode:
authorRussell Cousineau <miller.time.baby@gmail.com>2019-03-24 23:04:17 -0700
committerRussell Cousineau <miller.time.baby@gmail.com>2019-04-19 16:50:38 -0700
commit2440e0f98ade12cf595fe7c791a1065b29b53d74 (patch)
treeea5b333151d9580ff8c690994570272f3785d305 /components/script/dom/htmlanchorelement.rs
parentf9c58ccd401253b16916d173df621b1abc27f103 (diff)
downloadservo-2440e0f98ade12cf595fe7c791a1065b29b53d74.tar.gz
servo-2440e0f98ade12cf595fe7c791a1065b29b53d74.zip
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"
Diffstat (limited to 'components/script/dom/htmlanchorelement.rs')
-rw-r--r--components/script/dom/htmlanchorelement.rs15
1 files changed, 12 insertions, 3 deletions
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<String>) {
// 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<String>) {
.get_attribute_by_name(DOMString::from_string(String::from("referrerpolicy")))
.and_then(|attribute: DomRoot<Attr>| (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);
};
}