Commit 480cebee authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Test delete TransportSecurityState with filter

Test that deleting cache data with a whitelist does not remove
TransportSecurityState.

Bug: 1040065
Change-Id: I41763b4d9034b8fe4eba7e37e9b03cfe575b2fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1992083
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730187}
parent a132281a
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
...@@ -104,6 +105,20 @@ class BrowsingDataRemoverImplBrowserTest : public ContentBrowserTest { ...@@ -104,6 +105,20 @@ class BrowsingDataRemoverImplBrowserTest : public ContentBrowserTest {
completion_observer.BlockUntilCompletion(); completion_observer.BlockUntilCompletion();
} }
void RemoveWithFilterAndWait(
int remove_mask,
std::unique_ptr<BrowsingDataFilterBuilder> filter) {
content::BrowsingDataRemover* remover =
content::BrowserContext::GetBrowsingDataRemover(
shell()->web_contents()->GetBrowserContext());
content::BrowsingDataRemoverCompletionObserver completion_observer(remover);
remover->RemoveWithFilterAndReply(
base::Time(), base::Time::Max(), remove_mask,
content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
std::move(filter), &completion_observer);
completion_observer.BlockUntilCompletion();
}
// Issues a request for kHstsPath on localhost, and expects it to enable HSTS // Issues a request for kHstsPath on localhost, and expects it to enable HSTS
// for the domain. // for the domain.
void IssueRequestThatSetsHsts() { void IssueRequestThatSetsHsts() {
...@@ -214,13 +229,21 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverImplBrowserTest, ...@@ -214,13 +229,21 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverImplBrowserTest,
} }
// Verify that TransportSecurityState data is not cleared if REMOVE_CACHE is not // Verify that TransportSecurityState data is not cleared if REMOVE_CACHE is not
// set. // set or there is a WHITELIST filter.
// TODO(crbug.com/1040065): Add support for filtered deletions and update test.
IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverImplBrowserTest, IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverImplBrowserTest,
PreserveTransportSecurityState) { PreserveTransportSecurityState) {
IssueRequestThatSetsHsts(); IssueRequestThatSetsHsts();
RemoveAndWait(BrowsingDataRemover::DATA_TYPE_DOWNLOADS); RemoveAndWait(BrowsingDataRemover::DATA_TYPE_DOWNLOADS);
EXPECT_TRUE(IsHstsSet()); EXPECT_TRUE(IsHstsSet());
auto filter =
BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST);
filter->AddRegisterableDomain("foobar.com");
RemoveWithFilterAndWait(BrowsingDataRemover::DATA_TYPE_CACHE,
std::move(filter));
EXPECT_TRUE(IsHstsSet());
} }
IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverImplBrowserTest, ClearHttpAuthCache) { IN_PROC_BROWSER_TEST_F(BrowsingDataRemoverImplBrowserTest, ClearHttpAuthCache) {
......
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