diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-29 10:46:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-02 12:02:10 +0000 |
commit | 99677208ff3b216fdfec551fbe548da5520cd6fb (patch) | |
tree | 476a4865c10320249360e859d8fdd3e01833b03a /chromium/net/reporting | |
parent | c30a6232df03e1efbd9f3b226777b07e087a1122 (diff) | |
download | qtwebengine-chromium-99677208ff3b216fdfec551fbe548da5520cd6fb.tar.gz |
BASELINE: Update Chromium to 86.0.4240.124
Change-Id: Ide0ff151e94cd665ae6521a446995d34a9d1d644
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/reporting')
5 files changed, 78 insertions, 18 deletions
diff --git a/chromium/net/reporting/mock_persistent_reporting_store.cc b/chromium/net/reporting/mock_persistent_reporting_store.cc index f6544ae3ba5..6fb1c7d2ceb 100644 --- a/chromium/net/reporting/mock_persistent_reporting_store.cc +++ b/chromium/net/reporting/mock_persistent_reporting_store.cc @@ -283,6 +283,10 @@ int MockPersistentReportingStore::CountCommands(Command::Type t) { return c; } +void MockPersistentReportingStore::ClearCommands() { + command_list_.clear(); +} + MockPersistentReportingStore::CommandList MockPersistentReportingStore::GetAllCommands() const { return command_list_; diff --git a/chromium/net/reporting/mock_persistent_reporting_store.h b/chromium/net/reporting/mock_persistent_reporting_store.h index 6d464deda48..04f1d897965 100644 --- a/chromium/net/reporting/mock_persistent_reporting_store.h +++ b/chromium/net/reporting/mock_persistent_reporting_store.h @@ -121,6 +121,8 @@ class MockPersistentReportingStore // Count the number of commands with type |t|. int CountCommands(Command::Type t); + void ClearCommands(); + CommandList GetAllCommands() const; // Gets the number of stored endpoints/groups, simulating the actual number diff --git a/chromium/net/reporting/reporting_cache_impl.cc b/chromium/net/reporting/reporting_cache_impl.cc index 7b4e0345b27..373d1b96ed0 100644 --- a/chromium/net/reporting/reporting_cache_impl.cc +++ b/chromium/net/reporting/reporting_cache_impl.cc @@ -249,10 +249,6 @@ void ReportingCacheImpl::OnParsedHeader( AddOrUpdateEndpoint(std::move(new_endpoint)); } - // Remove endpoints that may have been previously configured for this group, - // but which were not specified in the current header. - RemoveEndpointsInGroupOtherThan(new_group.group_key, new_endpoints); - AddOrUpdateEndpointGroup(std::move(new_group)); } @@ -262,6 +258,15 @@ void ReportingCacheImpl::OnParsedHeader( // TODO(crbug.com/983000): Allow duplicate endpoint URLs. for (const auto& group_key_and_endpoint_set : endpoints_per_group) { new_client.endpoint_count += group_key_and_endpoint_set.second.size(); + + // Remove endpoints that may have been previously configured for this group, + // but which were not specified in the current header. + // This must be done all at once after all the groups in the header have + // been processed, rather than after each individual group, otherwise + // headers with multiple groups of the same name will clobber previous parts + // of themselves. See crbug.com/1116529. + RemoveEndpointsInGroupOtherThan(group_key_and_endpoint_set.first, + group_key_and_endpoint_set.second); } // Remove endpoint groups that may have been configured for an existing client diff --git a/chromium/net/reporting/reporting_header_parser_unittest.cc b/chromium/net/reporting/reporting_header_parser_unittest.cc index fcedd578574..9d72c0409b4 100644 --- a/chromium/net/reporting/reporting_header_parser_unittest.cc +++ b/chromium/net/reporting/reporting_header_parser_unittest.cc @@ -908,14 +908,47 @@ TEST_P(ReportingHeaderParserTest, EndpointGroupKey) { TEST_P(ReportingHeaderParserTest, HeaderErroneouslyContainsMultipleGroupsOfSameName) { + // Add a preexisting header to test that a header with multiple groups of the + // same name is treated as if it specified a single group with the combined + // set of specified endpoints. In particular, it must overwrite/update any + // preexisting group all at once. See https://crbug.com/1116529. + std::vector<ReportingEndpoint::EndpointInfo> preexisting = {{kEndpoint1_}}; + std::string preexisting_header = + ConstructHeaderGroupString(MakeEndpointGroup(kGroup1_, preexisting)); + + ParseHeader(kNik_, kUrl1_, preexisting_header); + EXPECT_TRUE( + EndpointGroupExistsInCache(kGroupKey11_, OriginSubdomains::DEFAULT)); + EXPECT_EQ(1u, cache()->GetEndpointGroupCountForTesting()); + EXPECT_TRUE(ClientExistsInCacheForOrigin(kOrigin1_)); + EXPECT_EQ(1u, cache()->GetEndpointCount()); + ReportingEndpoint endpoint = FindEndpointInCache(kGroupKey11_, kEndpoint1_); + ASSERT_TRUE(endpoint); + + if (mock_store()) { + mock_store()->Flush(); + EXPECT_EQ(1, mock_store()->StoredEndpointsCount()); + EXPECT_EQ(1, mock_store()->StoredEndpointGroupsCount()); + MockPersistentReportingStore::CommandList expected_commands; + expected_commands.emplace_back(CommandType::ADD_REPORTING_ENDPOINT, + kGroupKey11_, kEndpoint1_); + expected_commands.emplace_back(CommandType::ADD_REPORTING_ENDPOINT_GROUP, + kGroupKey11_); + EXPECT_THAT(mock_store()->GetAllCommands(), + testing::IsSupersetOf(expected_commands)); + // Reset commands so we can check that the next part, adding the header with + // duplicate groups, does not cause clearing of preexisting endpoints twice. + mock_store()->ClearCommands(); + } + std::vector<ReportingEndpoint::EndpointInfo> endpoints1 = {{kEndpoint1_}}; std::vector<ReportingEndpoint::EndpointInfo> endpoints2 = {{kEndpoint2_}}; - std::string header = + std::string duplicate_groups_header = ConstructHeaderGroupString(MakeEndpointGroup(kGroup1_, endpoints1)) + ", " + ConstructHeaderGroupString(MakeEndpointGroup(kGroup1_, endpoints2)); - ParseHeader(kNik_, kUrl1_, header); + ParseHeader(kNik_, kUrl1_, duplicate_groups_header); // Result is as if they set the two groups with the same name as one group. EXPECT_TRUE( EndpointGroupExistsInCache(kGroupKey11_, OriginSubdomains::DEFAULT)); @@ -924,7 +957,7 @@ TEST_P(ReportingHeaderParserTest, EXPECT_TRUE(ClientExistsInCacheForOrigin(kOrigin1_)); EXPECT_EQ(2u, cache()->GetEndpointCount()); - ReportingEndpoint endpoint = FindEndpointInCache(kGroupKey11_, kEndpoint1_); + ReportingEndpoint endpoint1 = FindEndpointInCache(kGroupKey11_, kEndpoint1_); ASSERT_TRUE(endpoint); EXPECT_EQ(kOrigin1_, endpoint.group_key.origin); EXPECT_EQ(kGroup1_, endpoint.group_key.group_name); @@ -947,14 +980,30 @@ TEST_P(ReportingHeaderParserTest, EXPECT_EQ(2, mock_store()->StoredEndpointsCount()); EXPECT_EQ(1, mock_store()->StoredEndpointGroupsCount()); MockPersistentReportingStore::CommandList expected_commands; - expected_commands.emplace_back(CommandType::ADD_REPORTING_ENDPOINT, - kGroupKey11_, kEndpoint1_); + expected_commands.emplace_back( + CommandType::UPDATE_REPORTING_ENDPOINT_DETAILS, kGroupKey11_, + kEndpoint1_); expected_commands.emplace_back(CommandType::ADD_REPORTING_ENDPOINT, kGroupKey11_, kEndpoint2_); - expected_commands.emplace_back(CommandType::ADD_REPORTING_ENDPOINT_GROUP, - kGroupKey11_); - EXPECT_THAT(mock_store()->GetAllCommands(), - testing::IsSupersetOf(expected_commands)); + expected_commands.emplace_back( + CommandType::UPDATE_REPORTING_ENDPOINT_GROUP_DETAILS, kGroupKey11_); + MockPersistentReportingStore::CommandList actual_commands = + mock_store()->GetAllCommands(); + EXPECT_THAT(actual_commands, testing::IsSupersetOf(expected_commands)); + for (const auto& command : actual_commands) { + EXPECT_NE(CommandType::DELETE_REPORTING_ENDPOINT, command.type); + EXPECT_NE(CommandType::DELETE_REPORTING_ENDPOINT_GROUP, command.type); + + // The endpoint with URL kEndpoint1_ is only ever updated, not added anew. + EXPECT_NE( + MockPersistentReportingStore::Command( + CommandType::ADD_REPORTING_ENDPOINT, kGroupKey11_, kEndpoint1_), + command); + // The group is only ever updated, not added anew. + EXPECT_NE(MockPersistentReportingStore::Command( + CommandType::ADD_REPORTING_ENDPOINT_GROUP, kGroupKey11_), + command); + } } } diff --git a/chromium/net/reporting/reporting_uploader_unittest.cc b/chromium/net/reporting/reporting_uploader_unittest.cc index 364585b3cfd..62bdda70498 100644 --- a/chromium/net/reporting/reporting_uploader_unittest.cc +++ b/chromium/net/reporting/reporting_uploader_unittest.cc @@ -14,7 +14,7 @@ #include "base/test/scoped_feature_list.h" #include "net/base/features.h" #include "net/base/network_isolation_key.h" -#include "net/cookies/cookie_inclusion_status.h" +#include "net/cookies/cookie_access_result.h" #include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store_test_callbacks.h" #include "net/http/http_status_code.h" @@ -119,7 +119,7 @@ class TestUploadCallback { if (waiting_) { waiting_ = false; - closure_.Run(); + std::move(closure_).Run(); } } @@ -127,7 +127,7 @@ class TestUploadCallback { ReportingUploader::Outcome outcome_; bool waiting_; - base::Closure closure_; + base::OnceClosure closure_; }; TEST_F(ReportingUploaderTest, Upload) { @@ -447,7 +447,7 @@ TEST_F(ReportingUploaderTest, DontSendCookies) { server_.RegisterRequestHandler(base::BindRepeating(&ReturnResponse, HTTP_OK)); ASSERT_TRUE(server_.Start()); - ResultSavingCookieCallback<CookieInclusionStatus> cookie_callback; + ResultSavingCookieCallback<CookieAccessResult> cookie_callback; GURL url = server_.GetURL("/"); auto cookie = CanonicalCookie::Create(url, "foo=bar", base::Time::Now(), base::nullopt /* server_time */); @@ -455,7 +455,7 @@ TEST_F(ReportingUploaderTest, DontSendCookies) { std::move(cookie), url, CookieOptions::MakeAllInclusive(), cookie_callback.MakeCallback()); cookie_callback.WaitUntilDone(); - ASSERT_TRUE(cookie_callback.result().IsInclude()); + ASSERT_TRUE(cookie_callback.result().status.IsInclude()); TestUploadCallback upload_callback; uploader_->StartUpload(kOrigin, server_.GetURL("/"), NetworkIsolationKey(), |