Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow first party subdomains when blocking 3rd-party cookies to match… (uplift to 1.9.x) #5329

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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