New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added WebDriver DeleteCookies Function #23006
Changes from all commits
File filter...
Jump to…
Add webdriver deletecookies function
- Loading branch information
| @@ -34,7 +34,7 @@ use js::rust::HandleValue; | ||
| use msg::constellation_msg::BrowsingContextId; | ||
| use msg::constellation_msg::PipelineId; | ||
| use net_traits::CookieSource::{NonHTTP, HTTP}; | ||
| use net_traits::CoreResourceMsg::{GetCookiesDataForUrl, SetCookieForUrl}; | ||
| use net_traits::CoreResourceMsg::{DeleteCookies, GetCookiesDataForUrl, SetCookieForUrl}; | ||
| use net_traits::IpcSend; | ||
| use script_traits::webdriver_msg::WebDriverCookieError; | ||
| use script_traits::webdriver_msg::{ | ||
| @@ -356,6 +356,27 @@ pub fn handle_add_cookie( | ||
| .unwrap(); | ||
| } | ||
|
|
||
| pub fn handle_delete_cookies( | ||
| documents: &Documents, | ||
| pipeline: PipelineId, | ||
| reply: IpcSender<Result<(), ()>>, | ||
| ) { | ||
| let document = match documents.find_document(pipeline) { | ||
jdm
Member
|
||
| Some(document) => document, | ||
| None => { | ||
| return reply.send(Err(())).unwrap(); | ||
| }, | ||
| }; | ||
| let url = document.url(); | ||
| document | ||
| .window() | ||
| .upcast::<GlobalScope>() | ||
| .resource_threads() | ||
| .send(DeleteCookies(url)) | ||
| .unwrap(); | ||
jdm
Member
|
||
| let _ = reply.send(Ok(())); | ||
| } | ||
|
|
||
| pub fn handle_get_title(documents: &Documents, pipeline: PipelineId, reply: IpcSender<String>) { | ||
| // TODO: Return an error if the pipeline doesn't exist. | ||
| let title = documents | ||
| @@ -971,6 +971,19 @@ impl Handler { | ||
| } | ||
| } | ||
|
|
||
| fn handle_delete_cookies(&self) -> WebDriverResult<WebDriverResponse> { | ||
| let (sender, receiver) = ipc::channel().unwrap(); | ||
| let cmd = WebDriverScriptCommand::DeleteCookies(sender); | ||
| self.browsing_context_script_command(cmd)?; | ||
jdm
Member
|
||
| match receiver.recv().unwrap() { | ||
| Ok(_) => Ok(WebDriverResponse::Void), | ||
| Err(_) => Err(WebDriverError::new( | ||
| ErrorStatus::NoSuchWindow, | ||
| "No such window found.", | ||
| )), | ||
| } | ||
| } | ||
|
|
||
| fn handle_set_timeouts( | ||
| &mut self, | ||
| parameters: &TimeoutsParameters, | ||
| @@ -1261,6 +1274,7 @@ impl WebDriverHandler<ServoExtensionRoute> for Handler { | ||
| WebDriverCommand::ElementSendKeys(ref element, ref keys) => { | ||
| self.handle_element_send_keys(element, keys) | ||
| }, | ||
| WebDriverCommand::DeleteCookies => self.handle_delete_cookies(), | ||
| WebDriverCommand::SetTimeouts(ref x) => self.handle_set_timeouts(x), | ||
| WebDriverCommand::TakeScreenshot => self.handle_take_screenshot(), | ||
| WebDriverCommand::Extension(ref extension) => match *extension { | ||
@jdm Dont we select the document by using a pipeline id?