Expose the origin of a cookie to JS
Categories
(Core :: Networking: Cookies, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox76 | --- | fixed |
People
(Reporter: miker, Assigned: baku)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-triaged])
Attachments
(2 files)
Updated•7 years ago
|
Comment 1•7 years ago
•
|
||
Comment 3•5 years ago
|
||
I think that it would still be useful to know the location where the cookie was created (source line and URL) - in case it was JavaScript.
This is what we already do for XHRs - showing the source line + URL + stacktrace.
Here is the place where we collect stack-trace info for HTTP requests
https://searchfox.org/mozilla-central/rev/61f224ec08ddc6f9a93ac45c8c3c5f7159be7c2a/devtools/server/actors/network-monitor/stack-trace-collector.js#116-117
We handle: "http-on-opening-request" and "document-on-opening-request"
If we had similar events for cookies (fired synchronously so, we can get the current JS stacktrace) we could use similar concepts.
I see that there is already: http-on-response-set-cookie
https://searchfox.org/mozilla-central/rev/61f224ec08ddc6f9a93ac45c8c3c5f7159be7c2a/netwerk/protocol/http/HttpBaseChannel.cpp#2130
Fired only when a cookie is created due to the presence of Set-Cookie header in the response header of any network request.
(DevTools is not using it yet so, I can't confirm how that works)
Perhaps having http-on-javascript-set-cookie could be used for the case where a cookie is created from JS
Harald, what do you think about this feature-wise?
Honza
Comment 4•5 years ago
|
||
Cookies could definitely be improved, both when/where cookies were set but also when they got blocked (especially supporting samesize, bug 795346).
Slightly diverging, do we have a http-on-response-set-cookie
-like event for blocked cookies?
Assignee | ||
Comment 5•5 years ago
|
||
I wrote a patch that exposes a new notification, triggered when document.cookie is set with a valid value.
Subject: the document
Topic: document-set-cookie
Data: the cookie string
Assignee | ||
Comment 6•5 years ago
|
||
Updated•5 years ago
|
Assignee | ||
Comment 7•5 years ago
|
||
Depends on D67589
Assignee | ||
Comment 8•5 years ago
|
||
http-on-response-set-cookie
is notified when we process the HTTP Set-Cookie header. We don't throw special notifications when 1 of those cookies is rejected. Lately, I introduced a few new console events about that. If needed we can do something more.
About sameSite cookies, what do you have in mind?
Comment 10•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6bd429e30868
https://hg.mozilla.org/mozilla-central/rev/e22128209b50
Description
•