aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/webdriver_handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r--components/script/webdriver_handlers.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index 6618bac4241..7e7fe95122b 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -182,9 +182,9 @@ pub fn handle_get_active_element(documents: &Documents,
pub fn handle_get_cookies(documents: &Documents,
pipeline: PipelineId,
- reply: IpcSender<Vec<Serde<Cookie>>>) {
+ reply: IpcSender<Vec<Serde<Cookie<'static>>>>) {
// TODO: Return an error if the pipeline doesn't exist?
- let cookies: Vec<Serde<Cookie>> = match documents.find_document(pipeline) {
+ let cookies = match documents.find_document(pipeline) {
None => Vec::new(),
Some(document) => {
let url = document.url();
@@ -202,9 +202,9 @@ pub fn handle_get_cookies(documents: &Documents,
pub fn handle_get_cookie(documents: &Documents,
pipeline: PipelineId,
name: String,
- reply: IpcSender<Vec<Serde<Cookie>>>) {
+ reply: IpcSender<Vec<Serde<Cookie<'static>>>>) {
// TODO: Return an error if the pipeline doesn't exist?
- let cookies: Vec<Serde<Cookie>> = match documents.find_document(pipeline) {
+ let cookies = match documents.find_document(pipeline) {
None => Vec::new(),
Some(document) => {
let url = document.url();
@@ -215,13 +215,13 @@ pub fn handle_get_cookie(documents: &Documents,
receiver.recv().unwrap()
},
};
- reply.send(cookies.into_iter().filter(|c| c.name == &*name).collect()).unwrap();
+ reply.send(cookies.into_iter().filter(|c| c.name() == &*name).collect()).unwrap();
}
// https://w3c.github.io/webdriver/webdriver-spec.html#add-cookie
pub fn handle_add_cookie(documents: &Documents,
pipeline: PipelineId,
- cookie: Cookie,
+ cookie: Cookie<'static>,
reply: IpcSender<Result<(), WebDriverCookieError>>) {
// TODO: Return a different error if the pipeline doesn't exist?
let document = match documents.find_document(pipeline) {
@@ -229,22 +229,24 @@ pub fn handle_add_cookie(documents: &Documents,
None => return reply.send(Err(WebDriverCookieError::UnableToSetCookie)).unwrap(),
};
let url = document.url();
- let method = if cookie.httponly {
+ let method = if cookie.http_only() {
HTTP
} else {
NonHTTP
};
- reply.send(match (document.is_cookie_averse(), cookie.domain.clone()) {
+
+ let domain = cookie.domain().map(ToOwned::to_owned);
+ reply.send(match (document.is_cookie_averse(), domain) {
(true, _) => Err(WebDriverCookieError::InvalidDomain),
- (false, Some(ref domain)) if url.host_str().map(|x| { x == &**domain }).unwrap_or(false) => {
+ (false, Some(ref domain)) if url.host_str().map(|x| { x == domain }).unwrap_or(false) => {
let _ = document.window().upcast::<GlobalScope>().resource_threads().send(
- SetCookieForUrl(url, cookie, method)
+ SetCookieForUrl(url, Serde(cookie), method)
);
Ok(())
},
(false, None) => {
let _ = document.window().upcast::<GlobalScope>().resource_threads().send(
- SetCookieForUrl(url, cookie, method)
+ SetCookieForUrl(url, Serde(cookie), method)
);
Ok(())
},