mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Webdriver delete cookie (#36306)
1. Implement `WebDriverCommand::DeleteCookie` 2. Remove unnecessary clone for `WebDriverCommand::GetNamedCookie` Fixes: #36287 --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
parent
e1de46c691
commit
4bad7c0a5d
7 changed files with 65 additions and 4 deletions
|
@ -94,6 +94,7 @@ 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_default();
|
||||
|
@ -102,6 +103,16 @@ impl CookieStorage {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn delete_cookie_with_name(&mut self, url: &ServoUrl, name: String) {
|
||||
let domain = reg_host(url.host_str().unwrap_or(""));
|
||||
let cookies = self.cookies_map.entry(domain).or_default();
|
||||
for cookie in cookies.iter_mut() {
|
||||
if cookie.cookie.name() == name {
|
||||
cookie.set_expiry_time_in_past();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// http://tools.ietf.org/html/rfc6265#section-5.3
|
||||
pub fn push(&mut self, mut cookie: ServoCookie, url: &ServoUrl, source: CookieSource) {
|
||||
// https://www.ietf.org/id/draft-ietf-httpbis-cookie-alone-01.txt Step 1
|
||||
|
|
|
@ -379,6 +379,14 @@ impl ResourceChannelManager {
|
|||
.clear_storage(&request);
|
||||
return true;
|
||||
},
|
||||
CoreResourceMsg::DeleteCookie(request, name) => {
|
||||
http_state
|
||||
.cookie_jar
|
||||
.write()
|
||||
.unwrap()
|
||||
.delete_cookie_with_name(&request, name);
|
||||
return true;
|
||||
},
|
||||
CoreResourceMsg::FetchRedirect(request_builder, res_init, sender) => {
|
||||
let cancellation_listener =
|
||||
self.get_or_create_cancellation_listener(request_builder.id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue