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

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

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: Rebase. 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/content_subresource_filter_throttle_manager_unittest.cc
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager_unittest.cc b/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager_unittest.cc
index c020f88c01c0204158632a57ae981276e3f31a50..4dc4324525e2e5c0f76d767fe927b21cfe9cdfb0 100644
--- a/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager_unittest.cc
+++ b/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager_unittest.cc
@@ -22,6 +22,7 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
@@ -317,7 +318,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
// A disallowed subframe navigation should be successfully filtered.
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
EXPECT_EQ(1, attempted_frame_activations());
@@ -353,9 +355,12 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/before-redirect.html"), main_rfh());
SimulateStartAndExpectResult(content::NavigationThrottle::PROCEED);
+ content::NavigationThrottle::ThrottleCheckResult expected_result =
+ content::IsBrowserSideNavigationEnabled()
+ ? content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE
+ : content::NavigationThrottle::CANCEL;
SimulateRedirectAndExpectResult(
- GURL("https://www.example.com/disallowed.html"),
- content::NavigationThrottle::CANCEL);
+ GURL("https://www.example.com/disallowed.html"), expected_result);
EXPECT_EQ(1, disallowed_notification_count());
EXPECT_EQ(1, attempted_frame_activations());
@@ -392,13 +397,15 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
// A disallowed subframe navigation should be successfully filtered.
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/1/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/2/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
EXPECT_EQ(1, attempted_frame_activations());
@@ -413,7 +420,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
// A disallowed subframe navigation should be successfully filtered.
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/1/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
@@ -423,7 +431,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/2/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(2, disallowed_notification_count());
EXPECT_EQ(2, attempted_frame_activations());
@@ -440,7 +449,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
// A disallowed subframe navigation should be successfully filtered.
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/1/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
@@ -452,7 +462,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/2/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
EXPECT_EQ(1, attempted_frame_activations());
@@ -500,7 +511,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest, RulesetHandleRegeneration) {
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
@@ -515,7 +527,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest, RulesetHandleRegeneration) {
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(2, disallowed_notification_count());
EXPECT_EQ(2, attempted_frame_activations());
@@ -565,7 +578,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest,
// A subframe navigation fail.
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/disallowed.html"), main_rfh());
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
EXPECT_EQ(1, attempted_frame_activations());
@@ -624,7 +638,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest, ActivationPropagation) {
// A final, nested subframe navigation is filtered.
CreateSubframeWithTestNavigation(GURL("https://www.c.com/disallowed.html"),
subframe2);
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(1, disallowed_notification_count());
EXPECT_EQ(3, attempted_frame_activations());
@@ -664,7 +679,8 @@ TEST_P(ContentSubresourceFilterThrottleManagerTest, ActivationPropagation2) {
// Navigate a sub-subframe that is not filtered due to the whitelist.
CreateSubframeWithTestNavigation(
GURL("https://www.example.com/disallowed.html"), subframe3);
- SimulateStartAndExpectResult(content::NavigationThrottle::CANCEL);
+ SimulateStartAndExpectResult(
+ content::NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
EXPECT_EQ(4, attempted_frame_activations());
EXPECT_EQ(1, disallowed_notification_count());

Powered by Google App Engine
This is Rietveld 408576698