Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Unified Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc

Issue 2733833002: Change logic for recording redirect pattern histograms. (Closed)
Patch Set: fix deps Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc
index 19d02222603ba19c529e8500f2a4257edbf9b939..cf8334793681697ec0e1e5b47bd8d67efa39a12d 100644
--- a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc
+++ b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc
@@ -13,6 +13,7 @@
#include "components/subresource_filter/content/common/subresource_filter_messages.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "components/subresource_filter/core/browser/subresource_filter_features_test_support.h"
+#include "components/subresource_filter/core/common/activation_list.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/mock_render_process_host.h"
@@ -61,6 +62,18 @@ enum RedirectChainMatchPattern {
NUM_HIT_PATTERNS,
};
+std::string GetSuffixForList(const ActivationList& type) {
+ switch (type) {
+ case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL:
+ return ".SocialEngineeringAdsInterstitial";
+ case ActivationList::PHISHING_INTERSTITIAL:
+ return ".PhishingInterstital";
+ case ActivationList::NONE:
+ return std::string();
+ }
+ return std::string();
+}
+
struct ActivationListTestData {
ActivationDecision expected_activation_decision;
const char* const activation_list;
@@ -268,18 +281,20 @@ class ContentSubresourceFilterDriverFactoryTest
content::RenderFrameHostTester* rfh_tester =
content::RenderFrameHostTester::For(main_rfh());
rfh_tester->AppendChild(kSubframeName);
+ ActivationList activation_list =
+ GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata);
+ const std::string suffix(GetSuffixForList(activation_list));
if (expected_pattern != EMPTY) {
- EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName),
+ EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName + suffix),
::testing::ElementsAre(base::Bucket(expected_pattern, 1)));
EXPECT_THAT(
- tester.GetAllSamples(kNavigationChainSize),
+ tester.GetAllSamples(kNavigationChainSize + suffix),
::testing::ElementsAre(base::Bucket(navigation_chain.size(), 1)));
-
} else {
- EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName),
+ EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName + suffix),
::testing::IsEmpty());
- EXPECT_THAT(tester.GetAllSamples(kNavigationChainSize),
+ EXPECT_THAT(tester.GetAllSamples(kNavigationChainSize + suffix),
::testing::IsEmpty());
}
}
@@ -426,10 +441,10 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
kActivationScopeAllSites,
kActivationListSocialEngineeringAdsInterstitial);
const GURL url(kExampleUrlWithParams);
- NavigateAndExpectActivation({true}, {url}, EMPTY,
+ NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
ActivationDecision::ACTIVATION_DISABLED);
factory()->AddHostOfURLToWhitelistSet(url);
- NavigateAndExpectActivation({true}, {url}, EMPTY,
+ NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
ActivationDecision::ACTIVATION_DISABLED);
}
@@ -675,13 +690,14 @@ TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest,
const GURL test_url("https://example.com/nonsoceng?q=engsocnon");
std::vector<GURL> navigation_chain;
- const bool expected_activation =
- test_data.expected_activation_decision == ActivationDecision::ACTIVATED;
+ ActivationList effective_list = GetListForThreatTypeAndMetadata(
+ test_data.threat_type, test_data.threat_type_metadata);
NavigateAndExpectActivation(
{false, false, false, true},
{GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), test_url}, test_data.threat_type,
test_data.threat_type_metadata, content::Referrer(),
- ui::PAGE_TRANSITION_LINK, expected_activation ? F0M0L1 : EMPTY,
+ ui::PAGE_TRANSITION_LINK,
+ effective_list != ActivationList::NONE ? F0M0L1 : EMPTY,
test_data.expected_activation_decision);
};

Powered by Google App Engine
This is Rietveld 408576698