| Index: components/domain_reliability/monitor_unittest.cc
|
| diff --git a/components/domain_reliability/monitor_unittest.cc b/components/domain_reliability/monitor_unittest.cc
|
| index 6f869937837fbd6381c154b2d4683859b6a6dc64..7b1ba3a5738a1458cbac482d71fb00f2dad49e19 100644
|
| --- a/components/domain_reliability/monitor_unittest.cc
|
| +++ b/components/domain_reliability/monitor_unittest.cc
|
| @@ -295,25 +295,78 @@ TEST_F(DomainReliabilityMonitorTest, ClearBeacons) {
|
| // Make sure it was added.
|
| EXPECT_EQ(1u, CountQueuedBeacons(context));
|
|
|
| - monitor_.ClearBrowsingData(CLEAR_BEACONS);
|
| + monitor_.ClearBrowsingData(
|
| + CLEAR_BEACONS, base::Callback<bool(const GURL&)>());
|
|
|
| // Make sure the beacon was cleared, but not the contexts.
|
| EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
|
| EXPECT_EQ(0u, CountQueuedBeacons(context));
|
| }
|
|
|
| +TEST_F(DomainReliabilityMonitorTest, ClearBeaconsWithFilter) {
|
| + // Create two contexts, each with one beacon.
|
| + GURL origin1("http://example.com/");
|
| + GURL origin2("http://example.org/");
|
| +
|
| + DomainReliabilityContext* context1 =
|
| + CreateAndAddContextForOrigin(origin1, false);
|
| + RequestInfo request = MakeRequestInfo();
|
| + request.url = origin1;
|
| + request.status =
|
| + net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET);
|
| + OnRequestLegComplete(request);
|
| +
|
| + DomainReliabilityContext* context2 =
|
| + CreateAndAddContextForOrigin(origin2, false);
|
| + request = MakeRequestInfo();
|
| + request.url = origin2;
|
| + request.status =
|
| + net::URLRequestStatus::FromError(net::ERR_CONNECTION_RESET);
|
| + OnRequestLegComplete(request);
|
| +
|
| + // Delete the beacons for |origin1|.
|
| + monitor_.ClearBrowsingData(
|
| + CLEAR_BEACONS,
|
| + base::Bind(&GURL::operator==, base::Unretained(&origin1)));
|
| +
|
| + // Beacons for |context1| were cleared. Beacons for |context2| and
|
| + // the contexts themselves were not.
|
| + EXPECT_EQ(2u, monitor_.contexts_size_for_testing());
|
| + EXPECT_EQ(0u, CountQueuedBeacons(context1));
|
| + EXPECT_EQ(1u, CountQueuedBeacons(context2));
|
| +}
|
| +
|
| TEST_F(DomainReliabilityMonitorTest, ClearContexts) {
|
| CreateAndAddContext();
|
|
|
| // Initially the monitor should have just the test context.
|
| EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
|
|
|
| - monitor_.ClearBrowsingData(CLEAR_CONTEXTS);
|
| + monitor_.ClearBrowsingData(
|
| + CLEAR_CONTEXTS, base::Callback<bool(const GURL&)>());
|
|
|
| // Clearing contexts should leave the monitor with none.
|
| EXPECT_EQ(0u, monitor_.contexts_size_for_testing());
|
| }
|
|
|
| +TEST_F(DomainReliabilityMonitorTest, ClearContextsWithFilter) {
|
| + GURL origin1("http://example.com/");
|
| + GURL origin2("http://example.org/");
|
| +
|
| + CreateAndAddContextForOrigin(origin1, false);
|
| + CreateAndAddContextForOrigin(origin2, false);
|
| +
|
| + EXPECT_EQ(2u, monitor_.contexts_size_for_testing());
|
| +
|
| + // Delete the contexts for |origin1|.
|
| + monitor_.ClearBrowsingData(
|
| + CLEAR_CONTEXTS,
|
| + base::Bind(&GURL::operator==, base::Unretained(&origin1)));
|
| +
|
| + // Only one of the contexts should have been deleted.
|
| + EXPECT_EQ(1u, monitor_.contexts_size_for_testing());
|
| +}
|
| +
|
| TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSelf) {
|
| DomainReliabilityContext* context =
|
| CreateAndAddContextForOrigin(GURL("https://wildcard/"), true);
|
|
|