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

Side by Side Diff: components/navigation_interception/intercept_navigation_throttle_unittest.cc

Issue 2696493003: Introduce SubframeNavigationFilteringThrottle (Closed)
Patch Set: s/proceed2/allowed2/ (trybots prev) Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/navigation_interception/intercept_navigation_throttle.h" 5 #include "components/navigation_interception/intercept_navigation_throttle.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 std::unique_ptr<content::NavigationHandle> test_handle = 64 std::unique_ptr<content::NavigationHandle> test_handle =
65 content::NavigationHandle::CreateNavigationHandleForTesting(url, 65 content::NavigationHandle::CreateNavigationHandleForTesting(url,
66 main_rfh()); 66 main_rfh());
67 test_handle->RegisterThrottleForTesting( 67 test_handle->RegisterThrottleForTesting(
68 base::MakeUnique<InterceptNavigationThrottle>( 68 base::MakeUnique<InterceptNavigationThrottle>(
69 test_handle.get(), 69 test_handle.get(),
70 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, 70 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation,
71 base::Unretained(mock_callback_receiver_.get())), 71 base::Unretained(mock_callback_receiver_.get())),
72 true)); 72 true));
73 return test_handle->CallWillStartRequestForTesting( 73 return test_handle->CallWillStartRequestForTesting(
74 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); 74 is_post, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false,
75 content::NavigationHandle::ThrottleChecksFinishedCallback());
75 } 76 }
76 77
77 NavigationThrottle::ThrottleCheckResult Simulate302() { 78 NavigationThrottle::ThrottleCheckResult Simulate302() {
78 std::unique_ptr<content::NavigationHandle> test_handle = 79 std::unique_ptr<content::NavigationHandle> test_handle =
79 content::NavigationHandle::CreateNavigationHandleForTesting( 80 content::NavigationHandle::CreateNavigationHandleForTesting(
80 GURL(kTestUrl), main_rfh()); 81 GURL(kTestUrl), main_rfh());
81 test_handle->RegisterThrottleForTesting( 82 test_handle->RegisterThrottleForTesting(
82 base::MakeUnique<InterceptNavigationThrottle>( 83 base::MakeUnique<InterceptNavigationThrottle>(
83 test_handle.get(), 84 test_handle.get(),
84 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation, 85 base::Bind(&MockInterceptCallbackReceiver::ShouldIgnoreNavigation,
85 base::Unretained(mock_callback_receiver_.get())), 86 base::Unretained(mock_callback_receiver_.get())),
86 true)); 87 true));
87 test_handle->CallWillStartRequestForTesting( 88 test_handle->CallWillStartRequestForTesting(
88 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false); 89 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false,
89 return test_handle->CallWillRedirectRequestForTesting(GURL(kTestUrl), false, 90 content::NavigationHandle::ThrottleChecksFinishedCallback());
90 GURL(), false); 91 return test_handle->CallWillRedirectRequestForTesting(
92 GURL(kTestUrl), false, GURL(), false,
93 content::NavigationHandle::ThrottleChecksFinishedCallback());
91 } 94 }
92 95
93 std::unique_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; 96 std::unique_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_;
94 }; 97 };
95 98
96 TEST_F(InterceptNavigationThrottleTest, 99 TEST_F(InterceptNavigationThrottleTest,
97 RequestDeferredAndResumedIfNavigationNotIgnored) { 100 RequestDeferredAndResumedIfNavigationNotIgnored) {
98 ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _)) 101 ON_CALL(*mock_callback_receiver_, ShouldIgnoreNavigation(_, _))
99 .WillByDefault(Return(false)); 102 .WillByDefault(Return(false));
100 EXPECT_CALL( 103 EXPECT_CALL(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 ShouldIgnoreNavigation( 158 ShouldIgnoreNavigation(
156 _, AllOf(NavigationParamsUrlIsTest(), 159 _, AllOf(NavigationParamsUrlIsTest(),
157 Property(&NavigationParams::is_post, Eq(false))))) 160 Property(&NavigationParams::is_post, Eq(false)))))
158 .WillOnce(Return(false)); 161 .WillOnce(Return(false));
159 NavigationThrottle::ThrottleCheckResult result = Simulate302(); 162 NavigationThrottle::ThrottleCheckResult result = Simulate302();
160 163
161 EXPECT_EQ(NavigationThrottle::PROCEED, result); 164 EXPECT_EQ(NavigationThrottle::PROCEED, result);
162 } 165 }
163 166
164 } // namespace navigation_interception 167 } // namespace navigation_interception
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698