Skip to content

Commit

Permalink
Merge pull request #5318 from /issues/9337
Browse files Browse the repository at this point in the history
allow first party subdomains when blocking 3rd-party cookies to match…
  • Loading branch information
bridiver authored and bsclifton committed Apr 24, 2020
1 parent 5e724ae commit ac0b626
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
16 changes: 15 additions & 1 deletion browser/net/brave_network_delegate_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -148,6 +151,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_;

private:
Expand Down Expand Up @@ -240,7 +244,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,
Expand Down Expand Up @@ -313,6 +322,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ac0b626

Please sign in to comment.