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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl_browsertest.cc

Issue 2632633006: Implement NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE. (Closed)
Patch Set: Addressed comments, made redirect response PlzNavigate-only. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/memory/weak_ptr.h" 5 #include "base/memory/weak_ptr.h"
6 #include "content/browser/frame_host/navigation_handle_impl.h" 6 #include "content/browser/frame_host/navigation_handle_impl.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/common/browser_side_navigation_policy.h" 10 #include "content/public/common/browser_side_navigation_policy.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 : NavigationThrottle(handle), 133 : NavigationThrottle(handle),
134 will_start_result_(will_start_result), 134 will_start_result_(will_start_result),
135 will_redirect_result_(will_redirect_result), 135 will_redirect_result_(will_redirect_result),
136 will_process_result_(will_process_result), 136 will_process_result_(will_process_result),
137 did_call_will_start_(did_call_will_start), 137 did_call_will_start_(did_call_will_start),
138 did_call_will_redirect_(did_call_will_redirect), 138 did_call_will_redirect_(did_call_will_redirect),
139 did_call_will_process_(did_call_will_process) {} 139 did_call_will_process_(did_call_will_process) {}
140 ~TestNavigationThrottle() override {} 140 ~TestNavigationThrottle() override {}
141 141
142 void Resume() { navigation_handle()->Resume(); } 142 void Resume() { navigation_handle()->Resume(); }
143 void Cancel(NavigationThrottle::ThrottleCheckResult result) {
144 navigation_handle()->CancelDeferredNavigation(result);
145 }
143 146
144 RequestContextType request_context_type() { return request_context_type_; } 147 RequestContextType request_context_type() { return request_context_type_; }
145 148
146 private: 149 private:
147 // NavigationThrottle implementation. 150 // NavigationThrottle implementation.
148 NavigationThrottle::ThrottleCheckResult WillStartRequest() override { 151 NavigationThrottle::ThrottleCheckResult WillStartRequest() override {
149 NavigationHandleImpl* navigation_handle_impl = 152 NavigationHandleImpl* navigation_handle_impl =
150 static_cast<NavigationHandleImpl*>(navigation_handle()); 153 static_cast<NavigationHandleImpl*>(navigation_handle());
151 CHECK_NE(REQUEST_CONTEXT_TYPE_UNSPECIFIED, 154 CHECK_NE(REQUEST_CONTEXT_TYPE_UNSPECIFIED,
152 navigation_handle_impl->request_context_type()); 155 navigation_handle_impl->request_context_type());
(...skipping 27 matching lines...) Expand all
180 183
181 NavigationThrottle::ThrottleCheckResult will_start_result_; 184 NavigationThrottle::ThrottleCheckResult will_start_result_;
182 NavigationThrottle::ThrottleCheckResult will_redirect_result_; 185 NavigationThrottle::ThrottleCheckResult will_redirect_result_;
183 NavigationThrottle::ThrottleCheckResult will_process_result_; 186 NavigationThrottle::ThrottleCheckResult will_process_result_;
184 base::Closure did_call_will_start_; 187 base::Closure did_call_will_start_;
185 base::Closure did_call_will_redirect_; 188 base::Closure did_call_will_redirect_;
186 base::Closure did_call_will_process_; 189 base::Closure did_call_will_process_;
187 RequestContextType request_context_type_ = REQUEST_CONTEXT_TYPE_UNSPECIFIED; 190 RequestContextType request_context_type_ = REQUEST_CONTEXT_TYPE_UNSPECIFIED;
188 }; 191 };
189 192
190 // Install a TestNavigationThrottle on all following requests and allows waiting 193 // Installs a TestNavigationThrottle either on all following requests or on
191 // for various NavigationThrottle related events. Waiting works only for the 194 // requests with an expected starting URL, and allows waiting for various
192 // immediately next navigation. New instances are needed to wait for further 195 // NavigationThrottle related events. Waiting works only for the immediately
193 // navigations. 196 // next navigation. New instances are needed to wait for further navigations.
194 class TestNavigationThrottleInstaller : public WebContentsObserver { 197 class TestNavigationThrottleInstaller : public WebContentsObserver {
195 public: 198 public:
196 TestNavigationThrottleInstaller( 199 TestNavigationThrottleInstaller(
197 WebContents* web_contents, 200 WebContents* web_contents,
198 NavigationThrottle::ThrottleCheckResult will_start_result, 201 NavigationThrottle::ThrottleCheckResult will_start_result,
199 NavigationThrottle::ThrottleCheckResult will_redirect_result, 202 NavigationThrottle::ThrottleCheckResult will_redirect_result,
200 NavigationThrottle::ThrottleCheckResult will_process_result) 203 NavigationThrottle::ThrottleCheckResult will_process_result,
204 const GURL& expected_start_url = GURL())
201 : WebContentsObserver(web_contents), 205 : WebContentsObserver(web_contents),
202 will_start_result_(will_start_result), 206 will_start_result_(will_start_result),
203 will_redirect_result_(will_redirect_result), 207 will_redirect_result_(will_redirect_result),
204 will_process_result_(will_process_result), 208 will_process_result_(will_process_result),
209 expected_start_url_(expected_start_url),
205 weak_factory_(this) {} 210 weak_factory_(this) {}
206 ~TestNavigationThrottleInstaller() override {} 211 ~TestNavigationThrottleInstaller() override {}
207 212
208 TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; } 213 TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; }
209 214
210 void WaitForThrottleWillStart() { 215 void WaitForThrottleWillStart() {
211 if (will_start_called_) 216 if (will_start_called_)
212 return; 217 return;
213 will_start_loop_runner_ = new MessageLoopRunner(); 218 will_start_loop_runner_ = new MessageLoopRunner();
214 will_start_loop_runner_->Run(); 219 will_start_loop_runner_->Run();
215 will_start_loop_runner_ = nullptr; 220 will_start_loop_runner_ = nullptr;
216 } 221 }
217 222
218 void WaitForThrottleWillRedirect() { 223 void WaitForThrottleWillRedirect() {
219 if (will_redirect_called_) 224 if (will_redirect_called_)
220 return; 225 return;
221 will_redirect_loop_runner_ = new MessageLoopRunner(); 226 will_redirect_loop_runner_ = new MessageLoopRunner();
222 will_redirect_loop_runner_->Run(); 227 will_redirect_loop_runner_->Run();
223 will_redirect_loop_runner_ = nullptr; 228 will_redirect_loop_runner_ = nullptr;
224 } 229 }
225 230
226 void WaitForThrottleWillProcess() { 231 void WaitForThrottleWillProcess() {
227 if (will_process_called_) 232 if (will_process_called_)
228 return; 233 return;
229 will_process_loop_runner_ = new MessageLoopRunner(); 234 will_process_loop_runner_ = new MessageLoopRunner();
230 will_process_loop_runner_->Run(); 235 will_process_loop_runner_->Run();
231 will_process_loop_runner_ = nullptr; 236 will_process_loop_runner_ = nullptr;
232 } 237 }
233 238
239 void Continue(NavigationThrottle::ThrottleCheckResult result) {
240 ASSERT_NE(NavigationThrottle::DEFER, result);
241 if (result == NavigationThrottle::PROCEED)
242 navigation_throttle()->Resume();
243 else
244 navigation_throttle()->Cancel(result);
245 }
246
234 int will_start_called() { return will_start_called_; } 247 int will_start_called() { return will_start_called_; }
235 int will_redirect_called() { return will_redirect_called_; } 248 int will_redirect_called() { return will_redirect_called_; }
236 int will_process_called() { return will_process_called_; } 249 int will_process_called() { return will_process_called_; }
237 250
238 int install_count() { return install_count_; } 251 int install_count() { return install_count_; }
239 252
253 protected:
254 virtual void DidCallWillStartRequest() {
255 will_start_called_++;
256 if (will_start_loop_runner_)
257 will_start_loop_runner_->Quit();
258 }
259
260 virtual void DidCallWillRedirectRequest() {
261 will_redirect_called_++;
262 if (will_redirect_loop_runner_)
263 will_redirect_loop_runner_->Quit();
264 }
265
266 virtual void DidCallWillProcessResponse() {
267 will_process_called_++;
268 if (will_process_loop_runner_)
269 will_process_loop_runner_->Quit();
270 }
271
240 private: 272 private:
241 void DidStartNavigation(NavigationHandle* handle) override { 273 void DidStartNavigation(NavigationHandle* handle) override {
274 if (!expected_start_url_.is_empty() &&
275 handle->GetURL() != expected_start_url_)
276 return;
277
242 std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle( 278 std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle(
243 handle, will_start_result_, will_redirect_result_, will_process_result_, 279 handle, will_start_result_, will_redirect_result_, will_process_result_,
244 base::Bind(&TestNavigationThrottleInstaller::DidCallWillStartRequest, 280 base::Bind(&TestNavigationThrottleInstaller::DidCallWillStartRequest,
245 weak_factory_.GetWeakPtr()), 281 weak_factory_.GetWeakPtr()),
246 base::Bind(&TestNavigationThrottleInstaller::DidCallWillRedirectRequest, 282 base::Bind(&TestNavigationThrottleInstaller::DidCallWillRedirectRequest,
247 weak_factory_.GetWeakPtr()), 283 weak_factory_.GetWeakPtr()),
248 base::Bind(&TestNavigationThrottleInstaller::DidCallWillProcessResponse, 284 base::Bind(&TestNavigationThrottleInstaller::DidCallWillProcessResponse,
249 weak_factory_.GetWeakPtr()))); 285 weak_factory_.GetWeakPtr())));
250 navigation_throttle_ = static_cast<TestNavigationThrottle*>(throttle.get()); 286 navigation_throttle_ = static_cast<TestNavigationThrottle*>(throttle.get());
251 handle->RegisterThrottleForTesting(std::move(throttle)); 287 handle->RegisterThrottleForTesting(std::move(throttle));
252 ++install_count_; 288 ++install_count_;
253 } 289 }
254 290
255 void DidFinishNavigation(NavigationHandle* handle) override { 291 void DidFinishNavigation(NavigationHandle* handle) override {
256 if (!navigation_throttle_) 292 if (!navigation_throttle_)
257 return; 293 return;
258 294
259 if (handle == navigation_throttle_->navigation_handle()) 295 if (handle == navigation_throttle_->navigation_handle())
260 navigation_throttle_ = nullptr; 296 navigation_throttle_ = nullptr;
261 } 297 }
262 298
263 void DidCallWillStartRequest() {
264 will_start_called_++;
265 if (will_start_loop_runner_)
266 will_start_loop_runner_->Quit();
267 }
268
269 void DidCallWillRedirectRequest() {
270 will_redirect_called_++;
271 if (will_redirect_loop_runner_)
272 will_redirect_loop_runner_->Quit();
273 }
274
275 void DidCallWillProcessResponse() {
276 will_process_called_++;
277 if (will_process_loop_runner_)
278 will_process_loop_runner_->Quit();
279 }
280
281 NavigationThrottle::ThrottleCheckResult will_start_result_; 299 NavigationThrottle::ThrottleCheckResult will_start_result_;
282 NavigationThrottle::ThrottleCheckResult will_redirect_result_; 300 NavigationThrottle::ThrottleCheckResult will_redirect_result_;
283 NavigationThrottle::ThrottleCheckResult will_process_result_; 301 NavigationThrottle::ThrottleCheckResult will_process_result_;
284 int will_start_called_ = 0; 302 int will_start_called_ = 0;
285 int will_redirect_called_ = 0; 303 int will_redirect_called_ = 0;
286 int will_process_called_ = 0; 304 int will_process_called_ = 0;
287 TestNavigationThrottle* navigation_throttle_ = nullptr; 305 TestNavigationThrottle* navigation_throttle_ = nullptr;
288 int install_count_ = 0; 306 int install_count_ = 0;
289 scoped_refptr<MessageLoopRunner> will_start_loop_runner_; 307 scoped_refptr<MessageLoopRunner> will_start_loop_runner_;
290 scoped_refptr<MessageLoopRunner> will_redirect_loop_runner_; 308 scoped_refptr<MessageLoopRunner> will_redirect_loop_runner_;
291 scoped_refptr<MessageLoopRunner> will_process_loop_runner_; 309 scoped_refptr<MessageLoopRunner> will_process_loop_runner_;
310 GURL expected_start_url_;
292 311
293 // The throttle installer can be deleted before all tasks posted by its 312 // The throttle installer can be deleted before all tasks posted by its
294 // throttles are run, so it must be referenced via weak pointers. 313 // throttles are run, so it must be referenced via weak pointers.
295 base::WeakPtrFactory<TestNavigationThrottleInstaller> weak_factory_; 314 base::WeakPtrFactory<TestNavigationThrottleInstaller> weak_factory_;
296 }; 315 };
297 316
317 // Same as above, but installs NavigationThrottles that do not directly return
318 // the pre-programmed check results, but first DEFER the navigation at each
319 // stage and then resume/cancel asynchronously.
320 class TestDeferringNavigationThrottleInstaller
321 : public TestNavigationThrottleInstaller {
322 public:
323 TestDeferringNavigationThrottleInstaller(
324 WebContents* web_contents,
325 NavigationThrottle::ThrottleCheckResult will_start_result,
326 NavigationThrottle::ThrottleCheckResult will_redirect_result,
327 NavigationThrottle::ThrottleCheckResult will_process_result,
328 GURL expected_start_url = GURL())
329 : TestNavigationThrottleInstaller(web_contents,
330 NavigationThrottle::DEFER,
331 NavigationThrottle::DEFER,
332 NavigationThrottle::DEFER,
333 expected_start_url),
334 will_start_deferred_result_(will_start_result),
335 will_redirect_deferred_result_(will_redirect_result),
336 will_process_deferred_result_(will_process_result) {}
337
338 protected:
339 void DidCallWillStartRequest() override {
340 TestNavigationThrottleInstaller::DidCallWillStartRequest();
341 Continue(will_start_deferred_result_);
342 }
343
344 void DidCallWillRedirectRequest() override {
345 TestNavigationThrottleInstaller::DidCallWillStartRequest();
346 Continue(will_redirect_deferred_result_);
347 }
348
349 void DidCallWillProcessResponse() override {
350 TestNavigationThrottleInstaller::DidCallWillStartRequest();
351 Continue(will_process_deferred_result_);
352 }
353
354 private:
355 NavigationThrottle::ThrottleCheckResult will_start_deferred_result_;
356 NavigationThrottle::ThrottleCheckResult will_redirect_deferred_result_;
357 NavigationThrottle::ThrottleCheckResult will_process_deferred_result_;
358 };
359
298 // Records all navigation start URLs from the WebContents. 360 // Records all navigation start URLs from the WebContents.
299 class NavigationStartUrlRecorder : public WebContentsObserver { 361 class NavigationStartUrlRecorder : public WebContentsObserver {
300 public: 362 public:
301 NavigationStartUrlRecorder(WebContents* web_contents) 363 NavigationStartUrlRecorder(WebContents* web_contents)
302 : WebContentsObserver(web_contents) {} 364 : WebContentsObserver(web_contents) {}
303 365
304 void DidStartNavigation(NavigationHandle* navigation_handle) override { 366 void DidStartNavigation(NavigationHandle* navigation_handle) override {
305 urls_.push_back(navigation_handle->GetURL()); 367 urls_.push_back(navigation_handle->GetURL());
306 } 368 }
307 369
308 const std::vector<GURL>& urls() const { return urls_; } 370 const std::vector<GURL>& urls() const { return urls_; }
309 371
310 private: 372 private:
311 std::vector<GURL> urls_; 373 std::vector<GURL> urls_;
312 }; 374 };
313 375
376 bool IsChildFrameCollapsed(Shell* shell, const std::string& element_id) {
377 const char kScript[] =
378 "window.domAutomationController.send("
379 " document.getElementById(\"%s\").clientWidth"
380 ");";
381 int client_width = 0;
382 EXPECT_TRUE(ExecuteScriptAndExtractInt(
383 shell, base::StringPrintf(kScript, element_id.c_str()), &client_width));
384 return !client_width;
385 }
386
314 } // namespace 387 } // namespace
315 388
316 class NavigationHandleImplBrowserTest : public ContentBrowserTest { 389 class NavigationHandleImplBrowserTest : public ContentBrowserTest {
317 protected: 390 protected:
318 void SetUpOnMainThread() override { 391 void SetUpOnMainThread() override {
319 host_resolver()->AddRule("*", "127.0.0.1"); 392 host_resolver()->AddRule("*", "127.0.0.1");
320 SetupCrossSiteRedirector(embedded_test_server()); 393 SetupCrossSiteRedirector(embedded_test_server());
321 ASSERT_TRUE(embedded_test_server()->Start()); 394 ASSERT_TRUE(embedded_test_server()->Start());
322 } 395 }
323 }; 396 };
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // Wait for the end of the navigation. 785 // Wait for the end of the navigation.
713 navigation_observer.Wait(); 786 navigation_observer.Wait();
714 787
715 EXPECT_TRUE(observer.has_committed()); 788 EXPECT_TRUE(observer.has_committed());
716 EXPECT_TRUE(observer.was_redirected()); 789 EXPECT_TRUE(observer.was_redirected());
717 EXPECT_FALSE(observer.is_error()); 790 EXPECT_FALSE(observer.is_error());
718 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), 791 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(),
719 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html"))); 792 GURL(embedded_test_server()->GetURL("bar.com", "/title2.html")));
720 } 793 }
721 794
795 // Ensure that a NavigationThrottle can block the navigation and collapse the
796 // frame owner both on request start as well as after a redirect. Plus, ensure
797 // that the frame is restored on the subsequent non-error-page navigation.
798 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
799 ThrottleBlockAndCollapse) {
800 const char kChildFrameId[] = "child0";
801 GURL main_url(embedded_test_server()->GetURL(
802 "a.com", "/frame_tree/page_with_one_frame.html"));
803 GURL blocked_subframe_url(embedded_test_server()->GetURL(
804 "a.com", "/cross-site/baz.com/title1.html"));
805 GURL allowed_subframe_url(embedded_test_server()->GetURL(
806 "a.com", "/cross-site/baz.com/title2.html"));
807 GURL allowed_subframe_final_url(
808 embedded_test_server()->GetURL("baz.com", "/title2.html"));
809
810 // Exercise both synchronous and deferred throttle check results, and both on
811 // WillStartRequest and on WillRedirectRequest.
812 const struct {
813 NavigationThrottle::ThrottleCheckResult will_start_result;
814 NavigationThrottle::ThrottleCheckResult will_redirect_result;
815 bool deferred_block;
816 } kTestCases[] = {
817 {NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE,
818 NavigationThrottle::PROCEED, false},
819 {NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE,
820 NavigationThrottle::PROCEED, true},
821 {NavigationThrottle::PROCEED,
822 NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE, false},
823 {NavigationThrottle::PROCEED,
824 NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE, true},
825 };
826
827 for (const auto& test_case : kTestCases) {
828 SCOPED_TRACE(::testing::Message() << test_case.will_start_result << ", "
829 << test_case.will_redirect_result << ", "
830 << test_case.deferred_block);
831
832 if (!IsBrowserSideNavigationEnabled() &&
833 test_case.will_redirect_result ==
834 NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) {
835 continue;
836 }
837
838 std::unique_ptr<TestNavigationThrottleInstaller>
839 subframe_throttle_installer;
840 if (test_case.deferred_block) {
841 subframe_throttle_installer.reset(
842 new TestDeferringNavigationThrottleInstaller(
843 shell()->web_contents(), test_case.will_start_result,
844 test_case.will_redirect_result, NavigationThrottle::PROCEED,
845 blocked_subframe_url));
846 } else {
847 subframe_throttle_installer.reset(new TestNavigationThrottleInstaller(
848 shell()->web_contents(), test_case.will_start_result,
849 test_case.will_redirect_result, NavigationThrottle::PROCEED,
850 blocked_subframe_url));
851 }
852
853 {
854 SCOPED_TRACE("Initial navigation blocked on main frame load.");
855 NavigationHandleObserver subframe_observer(shell()->web_contents(),
856 blocked_subframe_url);
857
858 ASSERT_TRUE(NavigateToURL(shell(), main_url));
859 EXPECT_TRUE(subframe_observer.is_error());
860 EXPECT_TRUE(subframe_observer.has_committed());
861 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, subframe_observer.net_error_code());
862 EXPECT_TRUE(IsChildFrameCollapsed(shell(), kChildFrameId));
alexmos 2017/04/11 06:00:29 Could we also check that the corresponding FrameTr
engedy 2017/04/11 08:06:17 Sure. Done.
863 }
864
865 {
866 SCOPED_TRACE("Subsequent subframe navigation is allowed.");
867 NavigationHandleObserver subframe_observer(shell()->web_contents(),
868 allowed_subframe_url);
869
870 ASSERT_TRUE(NavigateIframeToURL(shell()->web_contents(), kChildFrameId,
871 allowed_subframe_url));
872 EXPECT_TRUE(subframe_observer.has_committed());
873 EXPECT_FALSE(subframe_observer.is_error());
874 EXPECT_EQ(allowed_subframe_final_url,
875 subframe_observer.last_committed_url());
876 EXPECT_FALSE(IsChildFrameCollapsed(shell(), kChildFrameId));
877 }
878
879 {
880 SCOPED_TRACE("Subsequent subframe navigation is blocked.");
881 NavigationHandleObserver subframe_observer(shell()->web_contents(),
882 blocked_subframe_url);
883
884 ASSERT_TRUE(NavigateIframeToURL(shell()->web_contents(), kChildFrameId,
885 blocked_subframe_url));
886
887 EXPECT_TRUE(subframe_observer.has_committed());
888 EXPECT_TRUE(subframe_observer.is_error());
889 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, subframe_observer.net_error_code());
890 EXPECT_TRUE(IsChildFrameCollapsed(shell(), kChildFrameId));
891 }
892 }
893 }
894
722 // Checks that the RequestContextType value is properly set. 895 // Checks that the RequestContextType value is properly set.
723 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, 896 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
724 VerifyRequestContextTypeForFrameTree) { 897 VerifyRequestContextTypeForFrameTree) {
725 GURL main_url(embedded_test_server()->GetURL( 898 GURL main_url(embedded_test_server()->GetURL(
726 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); 899 "a.com", "/cross_site_iframe_factory.html?a(b(c))"));
727 GURL b_url(embedded_test_server()->GetURL( 900 GURL b_url(embedded_test_server()->GetURL(
728 "b.com", "/cross_site_iframe_factory.html?b(c())")); 901 "b.com", "/cross_site_iframe_factory.html?b(c())"));
729 GURL c_url(embedded_test_server()->GetURL( 902 GURL c_url(embedded_test_server()->GetURL(
730 "c.com", "/cross_site_iframe_factory.html?c()")); 903 "c.com", "/cross_site_iframe_factory.html?c()"));
731 904
732 TestNavigationThrottleInstaller installer( 905 TestNavigationThrottleInstaller installer(
733 shell()->web_contents(), NavigationThrottle::PROCEED, 906 shell()->web_contents(), NavigationThrottle::PROCEED,
734 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); 907 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
735 TestNavigationManager main_manager(shell()->web_contents(), main_url); 908 TestNavigationManager main_manager(shell()->web_contents(), main_url);
736 TestNavigationManager b_manager(shell()->web_contents(), b_url); 909 TestNavigationManager b_manager(shell()->web_contents(), b_url);
737 TestNavigationManager c_manager(shell()->web_contents(), c_url); 910 TestNavigationManager c_manager(shell()->web_contents(), c_url);
738 NavigationStartUrlRecorder url_recorder(shell()->web_contents()); 911 NavigationStartUrlRecorder url_recorder(shell()->web_contents());
739 912
740 // Starts and verifies the main frame navigation. 913 // Starts and verifies the main frame navigation.
741 shell()->LoadURL(main_url); 914 shell()->LoadURL(main_url);
742 EXPECT_TRUE(main_manager.WaitForRequestStart()); 915 EXPECT_TRUE(main_manager.WaitForRequestStart());
743 // For each navigation a new throttle should have been installed. 916 // For each navigation a new throttle should have been installed.
744 EXPECT_EQ(1, installer.install_count()); 917 EXPECT_EQ(1, installer.install_count());
745 // Checks the only URL recorded so far is the one expected for the main frame. 918 // Checks the only URL recorded so far is the one expected for the main
919 // frame.
alexmos 2017/04/11 06:00:29 nit: unnecessary churn?
engedy 2017/04/11 08:06:17 Looks like it, undone.
746 EXPECT_EQ(main_url, url_recorder.urls().back()); 920 EXPECT_EQ(main_url, url_recorder.urls().back());
747 EXPECT_EQ(1ul, url_recorder.urls().size()); 921 EXPECT_EQ(1ul, url_recorder.urls().size());
748 // Checks the main frame RequestContextType. 922 // Checks the main frame RequestContextType.
749 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION, 923 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION,
750 installer.navigation_throttle()->request_context_type()); 924 installer.navigation_throttle()->request_context_type());
751 925
752 // Ditto for frame b navigation. 926 // Ditto for frame b navigation.
753 main_manager.WaitForNavigationFinished(); 927 main_manager.WaitForNavigationFinished();
754 EXPECT_TRUE(b_manager.WaitForRequestStart()); 928 EXPECT_TRUE(b_manager.WaitForRequestStart());
755 EXPECT_EQ(2, installer.install_count()); 929 EXPECT_EQ(2, installer.install_count());
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 NavigationHandleObserver observer(shell()->web_contents(), error_url); 1386 NavigationHandleObserver observer(shell()->web_contents(), error_url);
1213 EXPECT_FALSE(NavigateToURL(shell(), error_url)); 1387 EXPECT_FALSE(NavigateToURL(shell(), error_url));
1214 EXPECT_TRUE(observer.has_committed()); 1388 EXPECT_TRUE(observer.has_committed());
1215 EXPECT_TRUE(observer.is_error()); 1389 EXPECT_TRUE(observer.is_error());
1216 EXPECT_NE(site_instance, 1390 EXPECT_NE(site_instance,
1217 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); 1391 shell()->web_contents()->GetMainFrame()->GetSiteInstance());
1218 } 1392 }
1219 } 1393 }
1220 1394
1221 } // namespace content 1395 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698