diff options
author | Russell Cousineau <miller.time.baby@gmail.com> | 2019-03-24 23:04:17 -0700 |
---|---|---|
committer | Russell Cousineau <miller.time.baby@gmail.com> | 2019-04-19 16:50:38 -0700 |
commit | 2440e0f98ade12cf595fe7c791a1065b29b53d74 (patch) | |
tree | ea5b333151d9580ff8c690994570272f3785d305 /components/script/dom/location.rs | |
parent | f9c58ccd401253b16916d173df621b1abc27f103 (diff) | |
download | servo-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/location.rs')
-rw-r--r-- | components/script/dom/location.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index aab7213a8f1..d6df671f451 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -13,6 +13,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::urlhelper::UrlHelper; use crate::dom::window::Window; use dom_struct::dom_struct; +use net_traits::request::Referrer; use servo_url::{MutableOrigin, ServoUrl}; #[dom_struct] @@ -43,8 +44,9 @@ impl Location { fn set_url_component(&self, value: USVString, setter: fn(&mut ServoUrl, USVString)) { let mut url = self.window.get_url(); + let referrer = Referrer::ReferrerUrl(url.clone()); setter(&mut url, value); - self.window.load_url(url, false, false, None); + self.window.load_url(url, false, false, referrer, None); } fn check_same_origin_domain(&self) -> ErrorResult { @@ -62,7 +64,9 @@ impl Location { // https://html.spec.whatwg.org/multipage/#dom-location-reload pub fn reload_without_origin_check(&self) { - self.window.load_url(self.get_url(), true, true, None); + let url = self.get_url(); + let referrer = Referrer::ReferrerUrl(url.clone()); + self.window.load_url(url, true, true, referrer, None); } #[allow(dead_code)] @@ -79,7 +83,8 @@ impl LocationMethods for Location { // _entry settings object_. let base_url = self.window.get_url(); if let Ok(url) = base_url.join(&url.0) { - self.window.load_url(url, false, false, None); + let referrer = Referrer::ReferrerUrl(base_url.clone()); + self.window.load_url(url, false, false, referrer, None); Ok(()) } else { Err(Error::Syntax) @@ -89,7 +94,9 @@ impl LocationMethods for Location { // https://html.spec.whatwg.org/multipage/#dom-location-reload fn Reload(&self) -> ErrorResult { self.check_same_origin_domain()?; - self.window.load_url(self.get_url(), true, true, None); + let url = self.get_url(); + let referrer = Referrer::ReferrerUrl(url.clone()); + self.window.load_url(url, true, true, referrer, None); Ok(()) } @@ -100,7 +107,8 @@ impl LocationMethods for Location { // _entry settings object_. let base_url = self.window.get_url(); if let Ok(url) = base_url.join(&url.0) { - self.window.load_url(url, true, false, None); + let referrer = Referrer::ReferrerUrl(base_url.clone()); + self.window.load_url(url, true, false, referrer, None); Ok(()) } else { Err(Error::Syntax) @@ -164,11 +172,13 @@ impl LocationMethods for Location { // https://html.spec.whatwg.org/multipage/#dom-location-href fn SetHref(&self, value: USVString) -> ErrorResult { // Note: no call to self.check_same_origin_domain() - let url = match self.window.get_url().join(&value.0) { + let current_url = self.window.get_url(); + let url = match current_url.join(&value.0) { Ok(url) => url, Err(e) => return Err(Error::Type(format!("Couldn't parse URL: {}", e))), }; - self.window.load_url(url, false, false, None); + let referrer = Referrer::ReferrerUrl(current_url.clone()); + self.window.load_url(url, false, false, referrer, None); Ok(()) } |