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

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

Issue 2861053004: [subresource_filter] Add metrics for all NavigationThrottle delays (Closed)
Patch Set: microseconds Created 3 years, 7 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/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

Powered by Google App Engine
This is Rietveld 408576698