Use origin when manipulating cookies.

This commit is contained in:
Josh Matthews 2016-04-13 10:39:16 +02:00 committed by Ms2ger
parent fa42b452a0
commit 90454c279d

View file

@ -2519,10 +2519,11 @@ impl DocumentMethods for Document {
return Ok(DOMString::new());
}
let url = self.url();
if !is_scheme_host_port_tuple(&url) {
if !self.origin.is_scheme_host_port_tuple() {
return Err(Error::Security);
}
let url = self.url();
let (tx, rx) = ipc::channel().unwrap();
let _ = self.window.resource_thread().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
let cookies = rx.recv().unwrap();
@ -2535,10 +2536,11 @@ impl DocumentMethods for Document {
return Ok(());
}
let url = self.url();
if !is_scheme_host_port_tuple(url) {
if !self.origin.is_scheme_host_port_tuple() {
return Err(Error::Security);
}
let url = self.url();
let _ = self.window
.resource_thread()
.send(SetCookiesForUrl((*url).clone(), String::from(cookie), NonHTTP));
@ -2742,10 +2744,6 @@ impl DocumentMethods for Document {
}
}
fn is_scheme_host_port_tuple(url: &Url) -> bool {
url.host().is_some() && url.port_or_default().is_some()
}
fn update_with_current_time_ms(marker: &Cell<u64>) {
if marker.get() == Default::default() {
let time = time::get_time();