OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/test/test_render_frame_host.h" | 5 #include "content/test/test_render_frame_host.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
10 #include "content/browser/frame_host/navigation_handle_impl.h" | 10 #include "content/browser/frame_host/navigation_handle_impl.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if (IsBrowserSideNavigationEnabled()) { | 412 if (IsBrowserSideNavigationEnabled()) { |
413 // TODO(mkwst): The initiator origin here is incorrect. | 413 // TODO(mkwst): The initiator origin here is incorrect. |
414 BeginNavigationParams begin_params( | 414 BeginNavigationParams begin_params( |
415 std::string(), net::LOAD_NORMAL, has_user_gesture, false, | 415 std::string(), net::LOAD_NORMAL, has_user_gesture, false, |
416 REQUEST_CONTEXT_TYPE_HYPERLINK, | 416 REQUEST_CONTEXT_TYPE_HYPERLINK, |
417 blink::WebMixedContentContextType::Blockable, url::Origin()); | 417 blink::WebMixedContentContextType::Blockable, url::Origin()); |
418 CommonNavigationParams common_params; | 418 CommonNavigationParams common_params; |
419 common_params.url = url; | 419 common_params.url = url; |
420 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); | 420 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); |
421 common_params.transition = ui::PAGE_TRANSITION_LINK; | 421 common_params.transition = ui::PAGE_TRANSITION_LINK; |
| 422 common_params.navigation_type = FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT; |
422 OnBeginNavigation(common_params, begin_params); | 423 OnBeginNavigation(common_params, begin_params); |
423 } | 424 } |
424 } | 425 } |
425 | 426 |
426 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) { | 427 void TestRenderFrameHost::DidChangeOpener(int opener_routing_id) { |
427 OnDidChangeOpener(opener_routing_id); | 428 OnDidChangeOpener(opener_routing_id); |
428 } | 429 } |
429 | 430 |
430 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy( | 431 void TestRenderFrameHost::DidEnforceInsecureRequestPolicy( |
431 blink::WebInsecureRequestPolicy policy) { | 432 blink::WebInsecureRequestPolicy policy) { |
432 OnEnforceInsecureRequestPolicy(policy); | 433 OnEnforceInsecureRequestPolicy(policy); |
433 } | 434 } |
434 | 435 |
435 void TestRenderFrameHost::PrepareForCommit() { | 436 void TestRenderFrameHost::PrepareForCommit() { |
436 PrepareForCommitWithServerRedirect(GURL()); | 437 PrepareForCommitWithServerRedirect(GURL()); |
437 } | 438 } |
438 | 439 |
439 void TestRenderFrameHost::PrepareForCommitWithServerRedirect( | 440 void TestRenderFrameHost::PrepareForCommitWithServerRedirect( |
440 const GURL& redirect_url) { | 441 const GURL& redirect_url) { |
441 if (!IsBrowserSideNavigationEnabled()) { | 442 if (!IsBrowserSideNavigationEnabled()) { |
442 // Non PlzNavigate | 443 // Non PlzNavigate |
443 if (is_waiting_for_beforeunload_ack()) | 444 if (is_waiting_for_beforeunload_ack()) |
444 SendBeforeUnloadACK(true); | 445 SendBeforeUnloadACK(true); |
445 return; | 446 return; |
446 } | 447 } |
447 | 448 |
448 // PlzNavigate | 449 // PlzNavigate |
449 NavigationRequest* request = frame_tree_node_->navigation_request(); | 450 NavigationRequest* request = frame_tree_node_->navigation_request(); |
450 CHECK(request); | 451 CHECK(request); |
451 bool have_to_make_network_request = ShouldMakeNetworkRequestForURL( | 452 bool have_to_make_network_request = |
452 request->common_params().url); | 453 ShouldMakeNetworkRequestForURL(request->common_params().url) && |
| 454 !FrameMsg_Navigate_Type::IsSameDocument( |
| 455 request->common_params().navigation_type); |
453 | 456 |
454 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for | 457 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for |
455 // it. If it runs it will update the request state. | 458 // it. If it runs it will update the request state. |
456 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) { | 459 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) { |
457 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host()) | 460 static_cast<TestRenderFrameHost*>(frame_tree_node()->current_frame_host()) |
458 ->SendBeforeUnloadACK(true); | 461 ->SendBeforeUnloadACK(true); |
459 } | 462 } |
460 | 463 |
461 if (!have_to_make_network_request) | 464 if (!have_to_make_network_request) |
462 return; // |request| is destructed by now. | 465 return; // |request| is destructed by now. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at | 508 // PlzNavigate: NavigationHandle::WillStartRequest has already been called at |
506 // this point. | 509 // this point. |
507 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) | 510 if (!navigation_handle() || IsBrowserSideNavigationEnabled()) |
508 return; | 511 return; |
509 navigation_handle()->CallWillStartRequestForTesting( | 512 navigation_handle()->CallWillStartRequestForTesting( |
510 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), | 513 false /* is_post */, Referrer(GURL(), blink::WebReferrerPolicyDefault), |
511 true /* user_gesture */, transition, false /* is_external_protocol */); | 514 true /* user_gesture */, transition, false /* is_external_protocol */); |
512 } | 515 } |
513 | 516 |
514 } // namespace content | 517 } // namespace content |
OLD | NEW |