aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/location.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/location.rs')
-rw-r--r--components/script/dom/location.rs24
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(())
}