mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Add webdriver deletecookies function
This commit is contained in:
parent
04c93c511b
commit
64961cc9c1
8 changed files with 60 additions and 1 deletions
|
@ -143,6 +143,10 @@ impl Cookie {
|
|||
self.last_access = now();
|
||||
}
|
||||
|
||||
pub fn set_expiry_time_negative(&mut self) {
|
||||
self.expiry_time = Some(Serde(now() - Duration::seconds(1)));
|
||||
}
|
||||
|
||||
// http://tools.ietf.org/html/rfc6265#section-5.1.4
|
||||
pub fn default_path(request_path: &str) -> &str {
|
||||
// Step 2
|
||||
|
|
|
@ -83,6 +83,13 @@ impl CookieStorage {
|
|||
Ok(None)
|
||||
}
|
||||
}
|
||||
pub fn clear_storage(&mut self, url: &ServoUrl) {
|
||||
let domain = reg_host(url.host_str().unwrap_or(""));
|
||||
let cookies = self.cookies_map.entry(domain).or_insert(vec![]);
|
||||
for cookie in cookies.iter_mut() {
|
||||
cookie.set_expiry_time_negative();
|
||||
}
|
||||
}
|
||||
|
||||
// http://tools.ietf.org/html/rfc6265#section-5.3
|
||||
pub fn push(&mut self, mut cookie: Cookie, url: &ServoUrl, source: CookieSource) {
|
||||
|
|
|
@ -236,6 +236,14 @@ impl ResourceChannelManager {
|
|||
http_state,
|
||||
),
|
||||
},
|
||||
CoreResourceMsg::DeleteCookies(request) => {
|
||||
http_state
|
||||
.cookie_jar
|
||||
.write()
|
||||
.unwrap()
|
||||
.clear_storage(&request);
|
||||
return true;
|
||||
},
|
||||
CoreResourceMsg::FetchRedirect(req_init, res_init, sender, cancel_chan) => self
|
||||
.resource_manager
|
||||
.fetch(req_init, Some(res_init), sender, http_state, cancel_chan),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue