Querying third-party cookies enabled status in content_shell web tests?

662 views
Skip to first unread message

Christian Biesinger

unread,
Aug 10, 2023, 12:18:22 PM8/10/23
to net-dev
Hello!

tldr: can I query the cookie_settings from
content/shell/browser/shell_federated_permission_context.cc?

I am trying to write a wpt test for this change:
https://chromium-review.googlesource.com/c/chromium/src/+/4763234

The wpt test in that CL "works", but is not super useful because in
production we run this code:
https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/webid/federated_identity_api_permission_context.cc;l=47

However, in our test runner we use this code instead:
https://source.chromium.org/chromium/chromium/src/+/main:content/shell/browser/shell_federated_permission_context.cc;l=20

I was not able to find a way to query the cookie manager whether
third-party cookies are enabled in content_shell...
CookieSettingsFactory is a chrome/ class, and the CookieManager mojo
interface has a BlockThirdPartyCookies function but no apparent way to
query whether they are blocked.

So... any advice for how to update
shell_federated_permission_context.cc to query the 3pc status?

Thanks!
Christian

Matt Menke

unread,
Aug 10, 2023, 12:44:47 PM8/10/23
to Christian Biesinger, net-dev
WPT tests can't test chrome/ code.  They're intended to test the web platform, and content/ is officially Chrome's web platform implementation, so WPT tests are only run using content_shell, which excludes Chrome code.

More generally, we don't expose 3P cookie settings to the we directly (though sites can test for it), since it's more fingerprinting information, and we want to discourage sites from, e.g., blocking users with 3P cookies disabled, demanding they change Chrome's cookie settings.

If you need to test chrome/ code, I suggest a browsertest instead, which can query CookieSettings or even the cookie store directly.

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAPTJ0XGgdSFKCH3er303S%3DuqfFj%3Dy1JC%3D-ZEvps59RDfYYJK3Q%40mail.gmail.com.

Christian Biesinger

unread,
Aug 10, 2023, 1:31:26 PM8/10/23
to Matt Menke, net-dev
Sure, but I'm not asking about testing chrome code or exposing 3pc
status to the web. I'm asking about letting
content/shell/browser/shell_federated_permission_context.cc query the
3pc status, if possible?

Christian

Matt Menke

unread,
Aug 10, 2023, 1:31:28 PM8/10/23
to Christian Biesinger, net-dev
Sorry, misunderstood.  Looks like CookieSettingsFactory is a chrome-layer concept, but the CookieSettings object in the network service (https://source.chromium.org/chromium/chromium/src/+/main:services/network/cookie_settings.h;l=48?q=services%2Fnetwork%2F%20cookiesettings&ss=chromium) is configured through a "content settings" object.  are handled in content/, and used in the network service to configure cookies.  It looks like the stats may only be set by Chrome embedders by directly calling the Mojo setter (https://source.chromium.org/search?q=%3ESetContentSettings%20-file:test%20-file:gen%2F&ss=chromium%2Fchromium%2Fsrc), so you may be out of luck trying to get at the current settings in content/ (or even in chrome/)

Maksim Orlovich

unread,
Aug 10, 2023, 2:08:31 PM8/10/23
to Christian Biesinger, Matt Menke, net-dev
Well, is there anything in content_shell that configures network service to turn off 3PC? The answer depends on that.



Christian Biesinger

unread,
Aug 10, 2023, 3:15:49 PM8/10/23
to Maksim Orlovich, Matt Menke, net-dev
Reply all
Reply to author
Forward
0 new messages