Commit cbf177b2 authored by Randy Smith's avatar Randy Smith Committed by Commit Bot

Invert the implementation of "{including,excluding}_domains" to match comment.

Both test and implementation were inverted from the comment in the Mojo
interface for CookieManagerImpl deletion functionality.  This CL fixes that.

Bug: 721395
Change-Id: I39274d5fc91a27ab988dcc6de61ded25dfe874e0
Reviewed-on: https://chromium-review.googlesource.com/701138
Commit-Queue: Randy Smith <rdsmith@chromium.org>
Reviewed-by: default avatarYuzhu Shen <yzshen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506886}
parent 7ae9c79d
...@@ -36,10 +36,10 @@ class PredicateWrapper { ...@@ -36,10 +36,10 @@ class PredicateWrapper {
// Ignore begin/end times; they're handled by method args. // Ignore begin/end times; they're handled by method args.
bool result = true; bool result = true;
if (use_excluding_domains_) if (use_excluding_domains_)
result &= (excluding_domains_.count(cookie.Domain()) != 0); result &= (excluding_domains_.count(cookie.Domain()) == 0);
if (use_including_domains_) if (use_including_domains_)
result &= (including_domains_.count(cookie.Domain()) == 0); result &= (including_domains_.count(cookie.Domain()) != 0);
if (session_control_ != if (session_control_ !=
mojom::CookieDeletionSessionControl::IGNORE_CONTROL) { mojom::CookieDeletionSessionControl::IGNORE_CONTROL) {
......
...@@ -631,13 +631,11 @@ TEST_F(CookieManagerImplTest, DeleteByExcludingDomains) { ...@@ -631,13 +631,11 @@ TEST_F(CookieManagerImplTest, DeleteByExcludingDomains) {
filter.excluding_domains = std::vector<std::string>(); filter.excluding_domains = std::vector<std::string>();
filter.excluding_domains->push_back("foo_host2"); filter.excluding_domains->push_back("foo_host2");
EXPECT_EQ(1u, service_wrapper()->DeleteCookies(filter)); EXPECT_EQ(2u, service_wrapper()->DeleteCookies(filter));
std::vector<net::CanonicalCookie> cookies = std::vector<net::CanonicalCookie> cookies =
service_wrapper()->GetAllCookies(); service_wrapper()->GetAllCookies();
ASSERT_EQ(2u, cookies.size()); ASSERT_EQ(1u, cookies.size());
std::sort(cookies.begin(), cookies.end(), &CompareCanonicalCookies); EXPECT_EQ("A2", cookies[0].Name());
EXPECT_EQ("A1", cookies[0].Name());
EXPECT_EQ("A3", cookies[1].Name());
} }
TEST_F(CookieManagerImplTest, DeleteByIncludingDomains) { TEST_F(CookieManagerImplTest, DeleteByIncludingDomains) {
...@@ -669,13 +667,11 @@ TEST_F(CookieManagerImplTest, DeleteByIncludingDomains) { ...@@ -669,13 +667,11 @@ TEST_F(CookieManagerImplTest, DeleteByIncludingDomains) {
filter.including_domains = std::vector<std::string>(); filter.including_domains = std::vector<std::string>();
filter.including_domains->push_back("foo_host1"); filter.including_domains->push_back("foo_host1");
filter.including_domains->push_back("foo_host3"); filter.including_domains->push_back("foo_host3");
EXPECT_EQ(1u, service_wrapper()->DeleteCookies(filter)); EXPECT_EQ(2u, service_wrapper()->DeleteCookies(filter));
std::vector<net::CanonicalCookie> cookies = std::vector<net::CanonicalCookie> cookies =
service_wrapper()->GetAllCookies(); service_wrapper()->GetAllCookies();
ASSERT_EQ(2u, cookies.size()); ASSERT_EQ(1u, cookies.size());
std::sort(cookies.begin(), cookies.end(), &CompareCanonicalCookies); EXPECT_EQ("A2", cookies[0].Name());
EXPECT_EQ("A1", cookies[0].Name());
EXPECT_EQ("A3", cookies[1].Name());
} }
TEST_F(CookieManagerImplTest, DeleteBySessionStatus) { TEST_F(CookieManagerImplTest, DeleteBySessionStatus) {
...@@ -736,12 +732,12 @@ TEST_F(CookieManagerImplTest, DeleteByAll) { ...@@ -736,12 +732,12 @@ TEST_F(CookieManagerImplTest, DeleteByAll) {
filter.created_after_time = now - base::TimeDelta::FromDays(4); filter.created_after_time = now - base::TimeDelta::FromDays(4);
filter.created_before_time = now - base::TimeDelta::FromDays(2); filter.created_before_time = now - base::TimeDelta::FromDays(2);
filter.excluding_domains = std::vector<std::string>();
filter.excluding_domains->push_back("no.com");
filter.excluding_domains->push_back("nope.com");
filter.including_domains = std::vector<std::string>(); filter.including_domains = std::vector<std::string>();
filter.including_domains->push_back("no.com"); filter.including_domains->push_back("no.com");
filter.including_domains->push_back("yes.com"); filter.including_domains->push_back("nope.com");
filter.excluding_domains = std::vector<std::string>();
filter.excluding_domains->push_back("no.com");
filter.excluding_domains->push_back("yes.com");
filter.session_control = filter.session_control =
mojom::CookieDeletionSessionControl::PERSISTENT_COOKIES; mojom::CookieDeletionSessionControl::PERSISTENT_COOKIES;
...@@ -931,8 +927,8 @@ TEST_F(CookieManagerImplTest, Notification) { ...@@ -931,8 +927,8 @@ TEST_F(CookieManagerImplTest, Notification) {
// a notification will be generated, and one for which a notification // a notification will be generated, and one for which a notification
// will not be generated. // will not be generated.
mojom::CookieDeletionFilter filter; mojom::CookieDeletionFilter filter;
filter.excluding_domains = std::vector<std::string>(); filter.including_domains = std::vector<std::string>();
filter.excluding_domains->push_back(notification_url.host()); filter.including_domains->push_back(notification_url.host());
EXPECT_EQ(2u, service_wrapper()->DeleteCookies(filter)); EXPECT_EQ(2u, service_wrapper()->DeleteCookies(filter));
// The notification may already have arrived, or it may arrive in the future. // The notification may already have arrived, or it may arrive in the future.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment