Allow frontend consumers to subscribe to cookie banner handling events via nsICookieBannerService
Categories
(Core :: Privacy: Anti-Tracking, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox109 | --- | fixed |
People
(Reporter: pbz, Assigned: pbz)
References
(Blocks 1 open bug)
Details
Attachments
(7 files, 1 obsolete file)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
We can use a similar pattern to nsIWebProgressListener
. The frontend component subscribing to cookie banner handling signals can implement an interface with a method to be called whenever we handle a banner.
Since banners can be handled either via CookieBannerParent/Child (clicking) or nsICookieInjector, nsICookieBannerService needs to accept calls from both of these components:
Banner Clicking
For the clicking code we can simply call into the service from here: https://searchfox.org/mozilla-central/rev/49011d374b626d5f0e7dc751a8a57365878e65f1/toolkit/components/cookiebanners/CookieBannerChild.jsm#223
Cookie Injector
The cookie injector should only send this signal to the service if it sets a cookie that has previously not been set to avoid duplicate notifications for sites where we have already handled the banner. This is a bit tricky to determine since we usually only set session cookies. We might have to add a persistent store to keep track of which sites we handled via cookie injection. We can also consider it out of scope for now and focus only on the clicking component.
Comment 1•2 years ago
•
|
||
Would it make sense to also expose this as some state on gProtectionsHandler, since the UI is being integrated into the protections doorhanger and the glowing state of the shield toolbar button?
Assignee | ||
Comment 2•2 years ago
|
||
(In reply to Jared Hirsch [:jhirsch] (he/him) (Needinfo please) from comment #1)
Would it make sense to also expose this as some state on gProtectionsHandler, since the UI is being integrated into the protections doorhanger and the glowing state of the shield toolbar button?
Either that or gIdentityHandler, which I think is a slightly better fit since it handles the identity icons too.
After some good pointers from :emilio I'm actually considering dispatching a custom chrome-only event that these components can listen for on the chrome window. That should make the implementation a bit simpler.
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 3•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 4•2 years ago
|
||
Updated•2 years ago
|
Assignee | ||
Comment 5•2 years ago
|
||
I misunderstood the exact requirements here. Seems like we need multiple events.
A) A cookie banner is detected, but the handling feature is disabled => dispatch a "cookiebannerdetected" event
B) A cookie banner is detected and handled => First dispatch a "cookiebannerdetected" event, then a "cookiebannerhandled" event
C) The mechanism is turned off entirely, no events should be dispatched.
For A) to work we need to add a new cookie banner service mode, that enables the cookie banner service and serves rules, but prevents the click and the cookie injection component from acting on cookie banners. The click component should only perform the detection and dispatch events.
Assignee | ||
Comment 6•2 years ago
|
||
Depends on D161630
Assignee | ||
Comment 7•2 years ago
|
||
Depends on D161725
Assignee | ||
Comment 8•2 years ago
|
||
Depends on D161726
Assignee | ||
Comment 9•2 years ago
|
||
Depends on D161727
Assignee | ||
Comment 10•2 years ago
|
||
Depends on D161728
Assignee | ||
Comment 11•2 years ago
|
||
Depends on D161729
Comment 12•2 years ago
|
||
Comment 13•2 years ago
|
||
Backed out for causing bc failures on browser_startup_content_subframe.js.
[task 2022-11-14T21:08:02.322Z] 21:08:02 INFO - GECKO(7346) | [Child 8921: Main Thread]: I/DocShellAndDOMWindowLeak ++DOMWINDOW == 3 (7fc8c5f36000) [pid = 8921] [serial = 3] [outer = 7fc8e1491d90]
[task 2022-11-14T21:08:02.337Z] 21:08:02 INFO - Console message: [JavaScript Warning: "This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”." {file: "http://example.com/browser/browser/base/content/test/performance/file_empty.html" line: 0}]
[task 2022-11-14T21:08:02.434Z] 21:08:02 INFO - TEST-INFO | started process screentopng
[task 2022-11-14T21:08:02.682Z] 21:08:02 INFO - TEST-INFO | screentopng: exit 0
[task 2022-11-14T21:08:02.686Z] 21:08:02 INFO - Buffered messages logged at 21:08:01
[task 2022-11-14T21:08:02.687Z] 21:08:02 INFO - Entering test bound
[task 2022-11-14T21:08:02.687Z] 21:08:02 INFO - Buffered messages finished
[task 2022-11-14T21:08:02.688Z] 21:08:02 INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/performance/browser_startup_content_subframe.js | should have no unexpected modules loaded on content process startup - Got 1, expected +0
[task 2022-11-14T21:08:02.688Z] 21:08:02 INFO - Stack trace:
[task 2022-11-14T21:08:02.689Z] 21:08:02 INFO - chrome://mochikit/content/browser-test.js:test_is:1485
[task 2022-11-14T21:08:02.689Z] 21:08:02 INFO - chrome://mochitests/content/browser/browser/base/content/test/performance/head.js:checkLoadedScripts:898
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - chrome://mochitests/content/browser/browser/base/content/test/performance/browser_startup_content_subframe.js:null:146
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - Not taking screenshot here: see the one that was previously logged
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/performance/browser_startup_content_subframe.js | Unexpected modules loaded during content process startup: resource://gre/modules/PrivateBrowsingUtils.sys.mjs -
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - Stack trace:
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - 0 get #isPrivateBrowsing() ["resource://gre/actors/CookieBannerChild.jsm":89:4]
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - 1 get #isEnabled() ["resource://gre/actors/CookieBannerChild.jsm":100:8]
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - 2 handleEvent() ["resource://gre/actors/CookieBannerChild.jsm":70:8]
[task 2022-11-14T21:08:02.690Z] 21:08:02 INFO - Console message: [JavaScript Warning: "Partitioned cookie or storage access was provided to “http://example.com/browser/browser/base/content/test/performance/file_empty.html” because it is loaded in the third-party context and dynamic state partitioning is enabled."]
[task 2022-11-14T21:08:02.693Z] 21:08:02 INFO - TEST-PASS | browser/base/content/test/performance/browser_startup_content_subframe.js | intermittent entry resource://gre/modules/nsAsyncShutdown.jsm for content process startup must exist -
Comment 14•2 years ago
|
||
Comment 15•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c1319c1bb849
https://hg.mozilla.org/mozilla-central/rev/4faa3165085b
https://hg.mozilla.org/mozilla-central/rev/468b3bfd4d0a
https://hg.mozilla.org/mozilla-central/rev/d4dcb9dc697f
https://hg.mozilla.org/mozilla-central/rev/a5961ee60155
https://hg.mozilla.org/mozilla-central/rev/617a4ff0e8ad
https://hg.mozilla.org/mozilla-central/rev/24083a0e31cf
Assignee | ||
Updated•2 years ago
|
Description
•