Index: components/subresource_filter/content/browser/subframe_navigation_filtering_throttle_unittest.cc |
diff --git a/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle_unittest.cc b/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle_unittest.cc |
index 71a590963eecba369f8e45737b22cd27c9c061a8..89c4320932106844d3c0e0e5f00eb556c979c5f1 100644 |
--- a/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle_unittest.cc |
+++ b/components/subresource_filter/content/browser/subframe_navigation_filtering_throttle_unittest.cc |
@@ -11,6 +11,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
#include "base/strings/stringprintf.h" |
+#include "base/test/histogram_tester.h" |
#include "components/subresource_filter/content/browser/async_document_subresource_filter.h" |
#include "components/subresource_filter/content/browser/async_document_subresource_filter_test_utils.h" |
#include "components/subresource_filter/core/common/activation_level.h" |
@@ -190,4 +191,29 @@ TEST_F(SubframeNavigationFilteringThrottleTest, FilterSubsubframe) { |
SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL); |
} |
+TEST_F(SubframeNavigationFilteringThrottleTest, DelayMetrics) { |
+ base::HistogramTester histogram_tester; |
+ InitializeDocumentSubresourceFilter(GURL("https://example.test")); |
+ CreateTestSubframeAndInitNavigation(GURL("https://example.test/allowed.html"), |
+ main_rfh()); |
+ |
+ SimulateStartAndExpectResult(content::NavigationThrottle::PROCEED); |
+ SimulateRedirectAndExpectResult(GURL("https://example.test/disallowed.html"), |
+ content::NavigationThrottle::CANCEL); |
+ |
+ const char kFilterDelayDisallowed[] = |
+ "SubresourceFilter.DocumentLoad.SubframeFilteringDelay.Disallowed"; |
+ const char kFilterDelayAllowed[] = |
+ "SubresourceFilter.DocumentLoad.SubframeFilteringDelay.Allowed"; |
+ histogram_tester.ExpectTotalCount(kFilterDelayDisallowed, 1); |
+ histogram_tester.ExpectTotalCount(kFilterDelayAllowed, 0); |
+ |
+ CreateTestSubframeAndInitNavigation(GURL("https://example.test/allowed.html"), |
+ main_rfh()); |
+ SimulateStartAndExpectResult(content::NavigationThrottle::PROCEED); |
+ SimulateCommitAndExpectResult(content::NavigationThrottle::PROCEED); |
+ histogram_tester.ExpectTotalCount(kFilterDelayDisallowed, 1); |
+ histogram_tester.ExpectTotalCount(kFilterDelayAllowed, 1); |
+} |
+ |
} // namespace subresource_filter |