OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
11 #include "content/browser/frame_host/navigation_request_info.h" | 11 #include "content/browser/frame_host/navigation_request_info.h" |
12 #include "content/browser/frame_host/navigator.h" | 12 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/frame_host/navigator_impl.h" | 13 #include "content/browser/frame_host/navigator_impl.h" |
14 #include "content/browser/frame_host/render_frame_host_manager.h" | 14 #include "content/browser/frame_host/render_frame_host_manager.h" |
15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
16 #include "content/browser/streams/stream.h" | 16 #include "content/browser/streams/stream.h" |
| 17 #include "content/common/frame_messages.h" |
17 #include "content/common/navigation_params.h" | 18 #include "content/common/navigation_params.h" |
18 #include "content/public/browser/stream_handle.h" | 19 #include "content/public/browser/stream_handle.h" |
19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
20 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
21 #include "content/public/common/url_utils.h" | 22 #include "content/public/common/url_utils.h" |
22 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
23 #include "content/test/browser_side_navigation_test_utils.h" | 24 #include "content/test/browser_side_navigation_test_utils.h" |
24 #include "content/test/test_navigation_url_loader.h" | 25 #include "content/test/test_navigation_url_loader.h" |
25 #include "content/test/test_render_frame_host.h" | 26 #include "content/test/test_render_frame_host.h" |
26 #include "content/test/test_web_contents.h" | 27 #include "content/test/test_web_contents.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // RenderFrame when the navigation can commit. A speculative RenderFrameHost | 447 // RenderFrame when the navigation can commit. A speculative RenderFrameHost |
447 // should not be created at any step. | 448 // should not be created at any step. |
448 TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) { | 449 TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) { |
449 const GURL kUrl("http://www.google.com/"); | 450 const GURL kUrl("http://www.google.com/"); |
450 contents()->NavigateAndCommit(kUrl); | 451 contents()->NavigateAndCommit(kUrl); |
451 | 452 |
452 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); | 453 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
453 SendRequestNavigationWithParameters( | 454 SendRequestNavigationWithParameters( |
454 node, kUrl, Referrer(), ui::PAGE_TRANSITION_LINK, | 455 node, kUrl, Referrer(), ui::PAGE_TRANSITION_LINK, |
455 NavigationController::RELOAD); | 456 NavigationController::RELOAD); |
456 main_test_rfh()->SendBeginNavigationWithURL(kUrl); | |
457 // A NavigationRequest should have been generated. | 457 // A NavigationRequest should have been generated. |
458 NavigationRequest* main_request = | 458 NavigationRequest* main_request = |
459 GetNavigationRequestForFrameTreeNode(node); | 459 GetNavigationRequestForFrameTreeNode(node); |
460 ASSERT_TRUE(main_request != NULL); | 460 ASSERT_TRUE(main_request != NULL); |
461 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD, | 461 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD, |
462 main_request->common_params().navigation_type); | 462 main_request->common_params().navigation_type); |
| 463 main_test_rfh()->PrepareForCommit(kUrl); |
463 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 464 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
464 | 465 |
465 main_test_rfh()->SendNavigate(0, kUrl); | 466 main_test_rfh()->SendNavigate(0, kUrl); |
466 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 467 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
467 | 468 |
468 // Now do a shift+reload. | 469 // Now do a shift+reload. |
469 SendRequestNavigationWithParameters( | 470 SendRequestNavigationWithParameters( |
470 node, kUrl, Referrer(), ui::PAGE_TRANSITION_LINK, | 471 node, kUrl, Referrer(), ui::PAGE_TRANSITION_LINK, |
471 NavigationController::RELOAD_IGNORING_CACHE); | 472 NavigationController::RELOAD_IGNORING_CACHE); |
472 main_test_rfh()->SendBeginNavigationWithURL(kUrl); | |
473 // A NavigationRequest should have been generated. | 473 // A NavigationRequest should have been generated. |
474 main_request = GetNavigationRequestForFrameTreeNode(node); | 474 main_request = GetNavigationRequestForFrameTreeNode(node); |
475 ASSERT_TRUE(main_request != NULL); | 475 ASSERT_TRUE(main_request != NULL); |
476 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, | 476 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, |
477 main_request->common_params().navigation_type); | 477 main_request->common_params().navigation_type); |
| 478 main_test_rfh()->PrepareForCommit(kUrl); |
478 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 479 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
479 } | 480 } |
480 | 481 |
481 // PlzNavigate: Confirm that a speculative RenderFrameHost is used when | 482 // PlzNavigate: Confirm that a speculative RenderFrameHost is used when |
482 // navigating from one site to another. | 483 // navigating from one site to another. |
483 TEST_F(NavigatorTestWithBrowserSideNavigation, | 484 TEST_F(NavigatorTestWithBrowserSideNavigation, |
484 SpeculativeRendererWorksBaseCase) { | 485 SpeculativeRendererWorksBaseCase) { |
485 // Navigate to an initial site. | 486 // Navigate to an initial site. |
486 const GURL kUrlInit("http://wikipedia.org/"); | 487 const GURL kUrlInit("http://wikipedia.org/"); |
487 contents()->NavigateAndCommit(kUrlInit); | 488 contents()->NavigateAndCommit(kUrlInit); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); | 637 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); |
637 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); | 638 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
638 | 639 |
639 rfh1->SendNavigate(1, kUrl1); | 640 rfh1->SendNavigate(1, kUrl1); |
640 EXPECT_EQ(rfh1, main_test_rfh()); | 641 EXPECT_EQ(rfh1, main_test_rfh()); |
641 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 642 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
642 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); | 643 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); |
643 } | 644 } |
644 | 645 |
645 } // namespace content | 646 } // namespace content |
OLD | NEW |