Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded WebDriver DeleteCookies Function #23006
Conversation
highfive
commented
Mar 9, 2019
|
Heads up! This PR modifies the following files:
|
3b7c38c
to
841e71a
|
Good start! We need to make some changes to fully match the specification, however. |
| @@ -236,6 +236,10 @@ impl ResourceChannelManager { | |||
| http_state, | |||
| ), | |||
| }, | |||
| CoreResourceMsg::DeleteCookies() => { | |||
| http_state.cookie_jar.write().unwrap().clear_storage(); | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 14, 2019
Member
According to https://w3c.github.io/webdriver/#dfn-delete-cookies (which is invoked from https://w3c.github.io/webdriver/#dfn-delete-all-cookies) this can delete more cookies than we want. We will want a message that includes the list of cookies to delete and the URL associated with the deletion request.
This comment has been minimized.
This comment has been minimized.
aditj
Mar 14, 2019
Author
Contributor
According to https://w3c.github.io/webdriver/#dfn-delete-cookies (which is invoked from https://w3c.github.io/webdriver/#dfn-delete-all-cookies) this can delete more cookies than we want. We will want a message that includes the list of cookies to delete and the URL associated with the deletion request.
I think we dont need to give a list of cookies and the URL associated since the spec we need to delete all the cookies pertaining to a particular document. (I dont find the need of a URL)
This comment has been minimized.
This comment has been minimized.
jdm
Mar 14, 2019
Member
You're right about one part; https://w3c.github.io/webdriver/#dfn-associated-cookies means that we do not need to create a list of cookies to delete ahead of time. However, https://w3c.github.io/webdriver/#dfn-delete-cookies means that we some way of indexing into the cookie storage (see how CookieStorage::cookies_for_url does that).
This comment has been minimized.
This comment has been minimized.
jdm
Mar 25, 2019
Member
We still need to accept a URL in this message and use that to clear only the cookies for that document.
| @@ -970,6 +970,13 @@ impl Handler { | |||
| } | |||
| } | |||
|
|
|||
| fn handle_delete_cookies(&self) -> WebDriverResult<WebDriverResponse> { | |||
| let (sender,_) = ipc::channel().unwrap(); | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 14, 2019
Member
We should wait for the response from the receiver that's created here and return any error that occurs.
| @@ -83,7 +83,9 @@ impl CookieStorage { | |||
| Ok(None) | |||
| } | |||
| } | |||
|
|
|||
| pub fn clear_storage(&mut self) { | |||
| self.cookies_map.clear(); | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 14, 2019
Member
According to https://w3c.github.io/webdriver/#dfn-delete-cookies we should set the cookie expiry time to the past, rather than deleting the actual stored cookie.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aditj
Mar 14, 2019
Author
Contributor
@jdm a little help , what should I assign the value of cookie's expiry_time variable to?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aditj
Mar 15, 2019
Author
Contributor
I dont think we need it in timespec since the type of expiry_time is Tm.
| @@ -1840,6 +1840,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,reply) | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
aditj
Mar 14, 2019
Author
Contributor
Okay I'll delete cookies of a particular document.
But I think this discussion is worth a read.
| @@ -356,6 +356,17 @@ pub fn handle_add_cookie( | |||
| .unwrap(); | |||
| } | |||
|
|
|||
| pub fn handle_delete_cookies(documents: &Documents,reply: IpcSender<Result<(),()>>) { | |||
| for (id, document) in documents.iter() { | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 14, 2019
Member
We will want to:
- choose a particular document
- get all of its cookies
- send a message deleting those cookies for this document's URL
This comment has been minimized.
This comment has been minimized.
289142a
to
a3b1ab7
|
Error syncing changes upstream. Logs saved in error-snapshot-1552691546047. |
|
Error syncing changes upstream. Logs saved in error-snapshot-1552691852886. |
|
Unfortunately something went wrong with the last rebase (or merge), so we will need to figure out how to extract the actual changes from this PR's list of commits. |
1589f5b
to
2f70220
|
If it's hard to rebase, I'd suggest
Then you should be able to have a clean branch |
Its a merge commit,cherry-pick isn't working :( |
|
@aditj In that case, I recommend taking the output of https://patch-diff.githubusercontent.com/raw/servo/servo/pull/23006.diff, saving it, then running |
Thanks @jdm ! I didnt know such a tool existed |
|
@jdm I (and git) can't find that commit id , where did you get it from? |
|
@aditj That was the most recent commit from master. If you git fetch from servo/servo, you should be able to use it. |
|
@bors-servo r+ |
|
|
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 -->
|
|
aditj commentedMar 9, 2019
•
edited
This change adds DeleteCookies function of the webdriver crate to the servo webdriver server.
See spec
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is