mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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"
This commit is contained in:
parent
f9c58ccd40
commit
2440e0f98a
21 changed files with 94 additions and 58 deletions
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue