Closed Bug 1623866 Opened 5 years ago Closed 5 years ago

Expose the origin of a cookie to the user

Categories

(DevTools :: Netmonitor, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: Honza, Unassigned)

References

(Blocks 1 open bug)

Details

This is a follow up for bug 1437057

There is a new notification triggered when document.cookie is set with a valid value.

Subject: the document
Topic: document-set-cookie
Data: the cookie string


We can now expose the origin of the cookie (+stack trace) to the user.

Honza

Harald, this probably requires some UX discussion.

Where we can expose the info?
Should we do it in the Cookies side panel?

Honza

Flags: needinfo?(hkirschner)

We already show which cookies requests set in Network panel (in which case the request is the stack), but maybe storage panel could eventually provide a timeline for which stacks changes a cookie.

GivenI am rather thinking of how this can help to expose blocked cookies. Should we add an event for blocked cookies or should we just treat any cookie that gets received and is not fired as set?

Blocks: 1623949
Flags: needinfo?(hkirschner)

(In reply to :Harald Kirschner :digitarald from comment #2)

GivenI am rather thinking of how this can help to expose blocked cookies. Should we add an event for blocked cookies

Yes, I filled bug 1624286 for it.

Honza

MVP would probably be to show this information as "stack" column in the cookies table. I assume this will only work when the Storage panel is active when cookies are set?

Flags: needinfo?(odvarko)

(In reply to :Harald Kirschner :digitarald from comment #4)

MVP would probably be to show this information as "stack" column in the cookies table.

Yep, I like that (I was thinking about the same)

I assume this will only work when the Storage panel is active when cookies are set?

I don't see any relation between the Cookies side panel and the Storage panel so, the Store pane should have no impact.


Some more comments on the implementation:

The Storage panel is using

  • nsICookieManager2.getCookiesFromHost to get list of cookies for the current host (used when populating the list on navigation) [2]
  • cookie-changed observer notification to update the list dynamically [1]

[1] https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Observer_Notifications
[2] https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICookieManager2

The Cookies side panel is using

  • nsIHttpChannel.visitOriginalResponseHeaders to look for set-cookies header [4] and parsing it to get all individual cookies [3]

[3] https://searchfox.org/mozilla-central/rev/c80fa7258c935223fe319c5345b58eae85d4c6ae/devtools/shared/webconsole/network-helper.js#359
[4] https://searchfox.org/mozilla-central/rev/c80fa7258c935223fe319c5345b58eae85d4c6ae/devtools/server/actors/network-monitor/network-observer.js#382

  • There is no support for dynamical update of the list in the Cookies panel

Honza

Flags: needinfo?(odvarko)

(In reply to Jan Honza Odvarko [:Honza] (always need-info? me) from comment #5)

(In reply to :Harald Kirschner :digitarald from comment #4)

MVP would probably be to show this information as "stack" column in the cookies table.

Yep, I like that (I was thinking about the same)

I am a bit confused about that. Honza, I think Harald means the cookies table within the Storage Inspector, while it seems you are referring to the Cookies side panel within the Net Monitor.

To my understanding, the information exposed by this new notification is whether a Cookie is set in JavaScript, so it is unrelated to any network requests.

The information about the origin of a cookie is best placed within the Storage Inspector, which is covered in bug 1350812. The only relation to the Net Monitor I see is that if a cookie was set via a network request, the Storage Inspector should link to that request within the Net Monitor. Though I guess this doesn't involve any changes to the Net Monitor itself, at most allowing other panels to select the Cookies side panel.

Sebastian

Yes, correct, my mistake.

  • The Storage panel is a good place where we can show the cookie origin - bug 1350812
  • The Cookies side panel is a good place where we can show rejected cookies - bug 1470069

So, I think we can close this one.

Honza

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
No longer blocks: 1623949
You need to log in before you can comment on or make changes to this bug.