Skip to content

Added WebDriver DeleteCookies Function - #23006

Merged
bors-servo merged 1 commit into
servo:masterfrom
aditj:aditj-patch-7
Apr 19, 2019
Merged

bors-servo merged 1 commit into
servo:masterfrom
aditj:aditj-patch-7

Conversation

@aditj

@aditj aditj commented Mar 9, 2019 •

Copy link
Copy Markdown
Contributor

This change adds DeleteCookies function of the webdriver crate to the servo webdriver server.
See spec


  • There are tests for these changes OR
  • These changes do not require tests because ___

This change is Reviewable

@highfive

highfive commented Mar 9, 2019

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 9, 2019
@aditj
aditj force-pushed the aditj-patch-7 branch 11 times, most recently from 3b7c38c to 841e71a Compare March 14, 2019 15:57

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! We need to make some changes to fully match the specification, however.

Comment thread components/net/resource_thread.rs Outdated
),
},
CoreResourceMsg::DeleteCookies() => {
http_state.cookie_jar.write().unwrap().clear_storage();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to accept a URL in this message and use that to clear only the cookies for that document.

Comment thread components/webdriver_server/lib.rs Outdated
}

fn handle_delete_cookies(&self) -> WebDriverResult<WebDriverResponse> {
let (sender,_) = ipc::channel().unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wait for the response from the receiver that's created here and return any error that occurs.

Comment thread components/net/cookie_storage.rs Outdated
}

pub fn clear_storage(&mut self) {
self.cookies_map.clear();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll try to implement that :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm a little help , what should I assign the value of cookie's expiry_time variable to?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try now().to_timespec() - Duration::seconds(1)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we need it in timespec since the type of expiry_time is Tm.

Comment thread components/script/script_thread.rs Outdated
webdriver_handlers::handle_add_cookie(&*documents, pipeline_id, params, reply)
},
WebDriverScriptCommand::DeleteCookies(reply) => {
webdriver_handlers::handle_delete_cookies(&*documents,reply)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass pipeline_id in order to choose a particular document.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll delete cookies of a particular document.
But I think this discussion is worth a read.

Comment thread components/script/webdriver_handlers.rs Outdated
}

pub fn handle_delete_cookies(documents: &Documents,reply: IpcSender<Result<(),()>>) {
for (id, document) in documents.iter() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will want to:

  1. choose a particular document
  2. get all of its cookies
  3. send a message deleting those cookies for this document's URL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm is the algorithm compliant now?

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 14, 2019
@jdm jdm assigned jdm and unassigned emilio Mar 14, 2019
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 14, 2019
@aditj
aditj force-pushed the aditj-patch-7 branch 5 times, most recently from 289142a to a3b1ab7 Compare March 15, 2019 23:08
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Error syncing changes upstream. Logs saved in error-snapshot-1552691546047.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Error syncing changes upstream. Logs saved in error-snapshot-1552691852886.

@jdm jdm added the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Apr 8, 2019
@jdm

jdm commented Apr 8, 2019

Copy link
Copy Markdown
Member

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.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Apr 12, 2019
@aditj
aditj force-pushed the aditj-patch-7 branch 2 times, most recently from 1589f5b to 2f70220 Compare April 14, 2019 05:15
@CYBAI

CYBAI commented Apr 16, 2019

Copy link
Copy Markdown
Member

If it's hard to rebase, I'd suggest

  1. cherry-pick the commit for this PR into a new branch based on latest master
  2. rename aditj-patch-7 to a temp name
  3. rename the new branch to aditj-patch-7

Then you should be able to have a clean branch 🤔 After confirming the new branch works fine, then you can remove the old branch which you renamed at step 2.

@jdm jdm removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 16, 2019
@aditj

aditj commented Apr 17, 2019

Copy link
Copy Markdown
Contributor Author

If it's hard to rebase, I'd suggest

  1. cherry-pick the commit for this PR into a new branch based on latest master
  2. rename aditj-patch-7 to a temp name
  3. rename the new branch to aditj-patch-7

Then you should be able to have a clean branch After confirming the new branch works fine, then you can remove the old branch which you renamed at step 2.

Its a merge commit,cherry-pick isn't working :(

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 17, 2019
@jdm

jdm commented Apr 18, 2019

Copy link
Copy Markdown
Member

@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 git reset --hard 04c93c511b021a1e76512f997992667540657c4e, followed by git apply 23006.diff, committing the changes, then force pushing your branch.

@aditj

aditj commented Apr 18, 2019

Copy link
Copy Markdown
Contributor Author

@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 git reset --hard 04c93c511b021a1e76512f997992667540657c4e, followed by git apply 23006.diff, committing the changes, then force pushing your branch.

Thanks @jdm ! I didnt know such a tool existed 😄 , I'll try it!

@aditj

aditj commented Apr 18, 2019

Copy link
Copy Markdown
Contributor Author

@jdm I (and git) can't find that commit id , where did you get it from?

@jdm

jdm commented Apr 18, 2019

Copy link
Copy Markdown
Member

@aditj That was the most recent commit from master. If you git fetch from servo/servo, you should be able to use it.

@aditj

aditj commented Apr 19, 2019

Copy link
Copy Markdown
Contributor Author

@aditj That was the most recent commit from master. If you git fetch from servo/servo, you should be able to use it.

I think it looks clean now :D
Thanks a lot @jdm and @CYBAI !

@CYBAI CYBAI removed the S-needs-rebase There are merge conflict errors. label Apr 19, 2019
@jdm

jdm commented Apr 19, 2019

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 64961cc has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 19, 2019
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 64961cc with merge 53b752b...

bors-servo pushed a commit that referenced this pull request Apr 19, 2019
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android-mac, arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, magicleap, status-taskcluster
Approved by: jdm
Pushing 53b752b to master...

@bors-servo
bors-servo merged commit 64961cc into servo:master Apr 19, 2019
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants