Closed Bug 1605354 Opened 5 years ago Closed 3 years ago

Add support for `urls` to `Network.getCookies()`

Categories

(Remote Protocol :: CDP, enhancement, P2)

enhancement

Tracking

(firefox97 fixed)

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: whimboo, Assigned: nafees87n, Mentored)

References

Details

(Whiteboard: [lang=js])

Attachments

(1 file)

From the docs, the code in Chrom(ium), and by testing in a live session it's not clear what this parameter actually does. Might it be some kind of filtering, or adding additional urls to get the cookies from. When I tested with the chrome-remote-interface client the list of cookies is always the same for eg. http://heise.de.

We would need some feedback from Chrome engineers in how to handle this option.

Puppeteer is using it, so adding it to the reserved backlog.

Blocks: 1605363

This is a filter, yes -- the host part of the URL is used as a key to retrieve the cookies for given host, and scheme and path are then used to match "secure" and "path" attributes in the returned cookies.
The retrieval/filtering logic is here: https://cs.chromium.org/chromium/src/net/cookies/cookie_monster.cc?rcl=3d246751a62e4b7dea22abb64eab73792b87c5ed&l=576
There are some puppeteer tests that cover cookie filtering by URL: https://github.com/puppeteer/puppeteer/blob/1de9906260269491c9011fcab33a58e280603fd3/test/cookies.spec.js#L121

Thank you. So to wrap-up and hopefully I understood that correctly:

  1. If no domain filter is set the currently open page including all its iframes (would need bug 1605362 first) is traversed for collecting cookies
  2. If a domain filter is set only the cookies for the given domains are getting retrieved, and the current page isn't obeyed at all

With this list of cookies:

  1. Filter out the cookies which don't match the path of the URL / domain
  2. Filter out the cookies which don't match the security flag
Depends on: 1605362
Type: task → enhancement
Priority: P3 → P2
Whiteboard: [puppeteer-beta-reserve] → [puppeteer-beta2-mvp]

Improved cookie handling will not be part of the beta2 milestone.

Whiteboard: [puppeteer-beta2-mvp]
Component: CDP: Network → CDP
Mentor: hskupin
Whiteboard: [lang=js]

CC'ing nafees87n on this bug given that he has shown interest to work on it.

Hi Nafees. It's been a while since we have heard last. I wonder if you are still interested in working on this bug? Thanks.

Flags: needinfo?(nafees87n)

Hi Henrik
I got occupied in other work, hence could not work on this.
Today I got a chance to look at this. What I can conclude is that if no domain filter is present, the current flow is good enough else, I need to filter based on domain. Here I could not understand where I could get the URL to match the cookie's domain. I need help with that part.

Thanks

Flags: needinfo?(nafees87n) → needinfo?(hskupin)

Sure! So the urls are coming via an argument to the Network.getCookies command. That means you will have to add it after this line like:

  async getCookies(options = {}) {
    const { urls = default_urls } = options;

Whereby default_urls is the code that you recently added to get the URLs of all the browsing contexts in the current tree. You could move that code into an internal helper method (starting with an underscore) in the same file, similar to _buildCookie. Then we could just call this method.

When done please make sure to run again the cookie related tests of the Puppeteer unit tests. I'm fairly sure that some are going to pass now.

Lets me know if there are remaining questions which I could help with.

Flags: needinfo?(hskupin)
Assignee: nobody → nafees87n
Status: NEW → ASSIGNED
Attachment #9243301 - Attachment description: WIP: Bug 1605354 - Support for Urls added to Network.getCookies() → Bug 1605354 - Support for Urls added to Network.getCookies() r=whimboo

Hi @nafees87n. I haven't heard from you for a while and wonder if I could help to get you going in case you are blocked. Please let me know if you are still interested to finish up this patch. Thanks!

Flags: needinfo?(nafees87n)

Hi @whimboo Got a bit busy. Will submit the patch in a couple of days

Flags: needinfo?(nafees87n)

Hi nafees87n, I'm not sure if you didn't get the Phabricator emails for my review or if you are under time constraints again. Please le me know again if you are interested to continue on this patch. Thanks.

Flags: needinfo?(nafees87n)

Hi whimboo
Apologies for the inconvenience. I am under time constraints. Hence couldn't get time to work on this. I'll try to complete this patch asap.

Flags: needinfo?(nafees87n)

No worries and I hope the back and forth is something you can still cope with. If not please really let me know and I will have to finish it off. Maybe it sounded easier at the beginning but getting all the required tests together is actually time consuming but also very helpful for a stable implementation of the feature. As such thanks a lot for still updating the patch! It's really appreciated!

Attachment #9243301 - Attachment description: Bug 1605354 - Support for Urls added to Network.getCookies() r=whimboo → Bug 1605354 - [remote] Support for Network.getCookies's "urls" parameter. r=whimboo
Pushed by hskupin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/78e7be5c38c7 [remote] Support for Network.getCookies's "urls" parameter. r=webdriver-reviewers,whimboo
Regressions: 1747434
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch

Thanks a lot Nafees87n for implementing this feature! And I assume that you have learned quit a bit. If you are interested and have time in the future please drop me a message and let me know what you are eager to learn. That way we can find something else for you.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: