Auto merge of #23006 - aditj:aditj-patch-7, r=jdm

Added WebDriver DeleteCookies Function

<!-- Please describe your changes on the following line: -->
This change adds DeleteCookies function of the webdriver crate to the servo webdriver server.
See [spec](https://w3c.github.io/webdriver/#delete-all-cookies)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix part of #8623 (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23006)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-04-19 09:48:30 -04:00 committed by GitHub
commit 53b752bab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 1 deletions

View file

@ -1844,6 +1844,9 @@ impl ScriptThread {
WebDriverScriptCommand::AddCookie(params, reply) => {
webdriver_handlers::handle_add_cookie(&*documents, pipeline_id, params, reply)
},
WebDriverScriptCommand::DeleteCookies(reply) => {
webdriver_handlers::handle_delete_cookies(&*documents, pipeline_id, reply)
},
WebDriverScriptCommand::ExecuteScript(script, reply) => {
webdriver_handlers::handle_execute_script(&*documents, pipeline_id, script, reply)
},

View file

@ -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) {
Some(document) => document,
None => {
return reply.send(Err(())).unwrap();
},
};
let url = document.url();
document
.window()
.upcast::<GlobalScope>()
.resource_threads()
.send(DeleteCookies(url))
.unwrap();
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