diff --git a/browser/net/brave_network_delegate_browsertest.cc b/browser/net/brave_network_delegate_browsertest.cc index cf71e2121e2e..c35d6c1096a8 100644 --- a/browser/net/brave_network_delegate_browsertest.cc +++ b/browser/net/brave_network_delegate_browsertest.cc @@ -61,6 +61,9 @@ class BraveNetworkDelegateBrowserTest : public InProcessBrowserTest { third_party_cookie_url_ = embedded_test_server()->GetURL("b.com", "/set-cookie?name=Good"); + subdomain_first_party_cookie_url_ = + embedded_test_server()->GetURL("subdomain.a.com", + "/set-cookie?name=Good"); google_oauth_cookie_url_ = https_server_.GetURL("accounts.google.com", "/set-cookie?oauth=true"); @@ -158,6 +161,7 @@ class BraveNetworkDelegateBrowserTest : public InProcessBrowserTest { GURL cookie_iframe_url_; GURL https_cookie_iframe_url_; GURL third_party_cookie_url_; + GURL subdomain_first_party_cookie_url_; GURL google_oauth_cookie_url_; GURL wordpress_top_url_; GURL wordpress_frame_url_; @@ -255,7 +259,12 @@ IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, NavigateFrameTo(third_party_cookie_url_); ExpectCookiesOnHost(top_level_page_url_, "name=Good"); - ExpectCookiesOnHost(GURL(third_party_cookie_url_.host()), ""); + ExpectCookiesOnHost(third_party_cookie_url_, ""); + + NavigateFrameTo(subdomain_first_party_cookie_url_); + + ExpectCookiesOnHost(top_level_page_url_, "name=Good"); + ExpectCookiesOnHost(subdomain_first_party_cookie_url_, "name=Good"); } IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, @@ -328,6 +337,11 @@ IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, ExpectCookiesOnHost(top_level_page_url_, "name=Good"); ExpectCookiesOnHost(GURL("http://b.com"), ""); + + NavigateFrameTo(subdomain_first_party_cookie_url_); + + ExpectCookiesOnHost(top_level_page_url_, "name=Good"); + ExpectCookiesOnHost(subdomain_first_party_cookie_url_, "name=Good"); } IN_PROC_BROWSER_TEST_F(BraveNetworkDelegateBrowserTest, diff --git a/components/content_settings/core/browser/brave_content_settings_pref_provider.cc b/components/content_settings/core/browser/brave_content_settings_pref_provider.cc index 6c5bb20f83d9..e963c07e9233 100644 --- a/components/content_settings/core/browser/brave_content_settings_pref_provider.cc +++ b/components/content_settings/core/browser/brave_content_settings_pref_provider.cc @@ -31,7 +31,12 @@ Rule CloneRule(const Rule& rule, bool reverse_patterns = false) { auto secondary_pattern = rule.secondary_pattern; if (secondary_pattern == ContentSettingsPattern::FromString("https://firstParty/*")) { - secondary_pattern = rule.primary_pattern; + if (!rule.primary_pattern.MatchesAllHosts()) { + secondary_pattern = ContentSettingsPattern::FromString( + "*://[*.]" + rule.primary_pattern.GetHost() + "/*"); + } else { + secondary_pattern = rule.primary_pattern; + } } // brave plugin rules incorrectly use the embedded url as the primary