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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "content/browser/frame_host/cross_site_transferring_request.h" | 9 #include "content/browser/frame_host/cross_site_transferring_request.h" |
10 #include "content/browser/frame_host/navigation_before_commit_info.h" | 10 #include "content/browser/frame_host/navigation_before_commit_info.h" |
11 #include "content/browser/frame_host/navigation_controller_impl.h" | 11 #include "content/browser/frame_host/navigation_controller_impl.h" |
12 #include "content/browser/frame_host/navigation_entry_impl.h" | 12 #include "content/browser/frame_host/navigation_entry_impl.h" |
13 #include "content/browser/frame_host/navigation_request.h" | 13 #include "content/browser/frame_host/navigation_request.h" |
14 #include "content/browser/frame_host/navigator.h" | 14 #include "content/browser/frame_host/navigator.h" |
15 #include "content/browser/frame_host/navigator_impl.h" | 15 #include "content/browser/frame_host/navigator_impl.h" |
16 #include "content/browser/frame_host/render_frame_host_manager.h" | 16 #include "content/browser/frame_host/render_frame_host_manager.h" |
17 #include "content/browser/site_instance_impl.h" | 17 #include "content/browser/site_instance_impl.h" |
18 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 18 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 19 #include "content/common/navigation_params.h" |
19 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/render_widget_host_iterator.h" | 26 #include "content/public/browser/render_widget_host_iterator.h" |
26 #include "content/public/browser/web_contents_delegate.h" | 27 #include "content/public/browser/web_contents_delegate.h" |
27 #include "content/public/browser/web_contents_observer.h" | 28 #include "content/public/browser/web_contents_observer.h" |
28 #include "content/public/browser/web_ui_controller.h" | 29 #include "content/public/browser/web_ui_controller.h" |
29 #include "content/public/common/bindings_policy.h" | 30 #include "content/public/common/bindings_policy.h" |
30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
31 #include "content/public/common/javascript_message_type.h" | 32 #include "content/public/common/javascript_message_type.h" |
32 #include "content/public/common/page_transition_types.h" | 33 #include "content/public/common/page_transition_types.h" |
33 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
34 #include "content/public/common/url_utils.h" | 35 #include "content/public/common/url_utils.h" |
35 #include "content/public/test/mock_render_process_host.h" | 36 #include "content/public/test/mock_render_process_host.h" |
36 #include "content/public/test/test_notification_tracker.h" | 37 #include "content/public/test/test_notification_tracker.h" |
37 #include "content/test/test_content_browser_client.h" | 38 #include "content/test/test_content_browser_client.h" |
38 #include "content/test/test_content_client.h" | 39 #include "content/test/test_content_client.h" |
39 #include "content/test/test_render_frame_host.h" | 40 #include "content/test/test_render_frame_host.h" |
40 #include "content/test/test_render_view_host.h" | 41 #include "content/test/test_render_view_host.h" |
41 #include "content/test/test_web_contents.h" | 42 #include "content/test/test_web_contents.h" |
| 43 #include "net/base/load_flags.h" |
42 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
43 | 45 |
44 namespace content { | 46 namespace content { |
45 namespace { | 47 namespace { |
46 | 48 |
47 class RenderFrameHostManagerTestWebUIControllerFactory | 49 class RenderFrameHostManagerTestWebUIControllerFactory |
48 : public WebUIControllerFactory { | 50 : public WebUIControllerFactory { |
49 public: | 51 public: |
50 RenderFrameHostManagerTestWebUIControllerFactory() | 52 RenderFrameHostManagerTestWebUIControllerFactory() |
51 : should_create_webui_(false) { | 53 : should_create_webui_(false) { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 382 |
381 NavigationRequest* GetNavigationRequestForRenderFrameManager( | 383 NavigationRequest* GetNavigationRequestForRenderFrameManager( |
382 RenderFrameHostManager* manager) const { | 384 RenderFrameHostManager* manager) const { |
383 return manager->navigation_request_for_testing(); | 385 return manager->navigation_request_for_testing(); |
384 } | 386 } |
385 | 387 |
386 void EnableBrowserSideNavigation() { | 388 void EnableBrowserSideNavigation() { |
387 CommandLine::ForCurrentProcess()->AppendSwitch( | 389 CommandLine::ForCurrentProcess()->AppendSwitch( |
388 switches::kEnableBrowserSideNavigation); | 390 switches::kEnableBrowserSideNavigation); |
389 } | 391 } |
| 392 |
| 393 void SendRequestNavigation(const GURL& url, |
| 394 FrameTreeNode* node) { |
| 395 SendRequestNavigationWithParameters( |
| 396 url, node, Referrer(), PAGE_TRANSITION_LINK, |
| 397 NavigationController::NO_RELOAD); |
| 398 } |
| 399 |
| 400 void SendRequestNavigationWithParameters( |
| 401 const GURL& url, |
| 402 FrameTreeNode* node, |
| 403 const Referrer& referrer, |
| 404 PageTransition transition_type, |
| 405 NavigationController::ReloadType reload_type) { |
| 406 scoped_ptr<NavigationEntryImpl> entry( |
| 407 NavigationEntryImpl::FromNavigationEntry( |
| 408 NavigationController::CreateNavigationEntry( |
| 409 url, referrer, transition_type, false, std::string(), |
| 410 controller().GetBrowserContext()))); |
| 411 NavigatorImpl* navigator = static_cast<NavigatorImpl*>(node->navigator()); |
| 412 node->render_manager()->RequestNavigation( |
| 413 navigator->MakeNavigationParamsForTest(*entry, reload_type)); |
| 414 } |
| 415 |
| 416 NavigationParamsWithRequestAndCommitInfo* GetNavigationParams( |
| 417 RenderFrameHostManager* manager) { |
| 418 return manager->navigation_params_.get(); |
| 419 } |
| 420 |
390 private: | 421 private: |
391 RenderFrameHostManagerTestWebUIControllerFactory factory_; | 422 RenderFrameHostManagerTestWebUIControllerFactory factory_; |
392 scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; | 423 scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; |
393 }; | 424 }; |
394 | 425 |
395 // Tests that when you navigate from a chrome:// url to another page, and | 426 // Tests that when you navigate from a chrome:// url to another page, and |
396 // then do that same thing in another tab, that the two resulting pages have | 427 // then do that same thing in another tab, that the two resulting pages have |
397 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is | 428 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is |
398 // a regression test for bug 9364. | 429 // a regression test for bug 9364. |
399 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) { | 430 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) { |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 | 1718 |
1688 contents()->GetMainFrame()->OnMessageReceived( | 1719 contents()->GetMainFrame()->OnMessageReceived( |
1689 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1720 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
1690 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1721 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1691 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1722 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
1692 } | 1723 } |
1693 } | 1724 } |
1694 | 1725 |
1695 // PlzNavigate: Test that a proper NavigationRequest is created by | 1726 // PlzNavigate: Test that a proper NavigationRequest is created by |
1696 // BeginNavigation. | 1727 // BeginNavigation. |
| 1728 // Note that all PlzNavigate methods on the browser side require the use of the |
| 1729 // flag kEnableBrowserSideNavigation. |
1697 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { | 1730 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { |
1698 const GURL kUrl1("http://www.google.com/"); | 1731 const GURL kUrl1("http://www.google.com/"); |
1699 const GURL kUrl2("http://www.chromium.org/"); | 1732 const GURL kUrl2("http://www.chromium.org/"); |
1700 const GURL kUrl3("http://www.gmail.com/"); | 1733 const GURL kUrl3("http://www.gmail.com/"); |
1701 const int64 kFirstNavRequestID = 1; | 1734 const int64 kFirstNavRequestID = 1; |
1702 | 1735 |
1703 // TODO(clamy): we should be enabling browser side navigations here | 1736 // TODO(clamy): we should be enabling browser side navigations here |
1704 // when CommitNavigation is properly implemented. | 1737 // when CommitNavigation is properly implemented. |
1705 // Navigate to the first page. | 1738 // Navigate to the first page. |
1706 contents()->NavigateAndCommit(kUrl1); | 1739 contents()->NavigateAndCommit(kUrl1); |
1707 | 1740 |
1708 EnableBrowserSideNavigation(); | 1741 EnableBrowserSideNavigation(); |
1709 // Add a subframe. | 1742 // Add a subframe. |
1710 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( | 1743 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( |
1711 contents()->GetFrameTree()->AddFrame( | 1744 contents()->GetFrameTree()->AddFrame( |
1712 contents()->GetFrameTree()->root(), 14, "Child")); | 1745 contents()->GetFrameTree()->root(), 14, "Child")); |
1713 | 1746 |
| 1747 RenderFrameHostManager* subframe_manager = |
| 1748 subframe_rfh->frame_tree_node()->render_manager(); |
| 1749 SendRequestNavigation(kUrl2, subframe_rfh->frame_tree_node()); |
1714 // Simulate a BeginNavigation IPC on the subframe. | 1750 // Simulate a BeginNavigation IPC on the subframe. |
1715 subframe_rfh->SendBeginNavigationWithURL(kUrl2); | 1751 subframe_rfh->SendBeginNavigationWithURL(kUrl2); |
1716 NavigationRequest* subframe_request = | 1752 NavigationRequest* subframe_request = |
1717 GetNavigationRequestForRenderFrameManager( | 1753 GetNavigationRequestForRenderFrameManager(subframe_manager); |
1718 subframe_rfh->frame_tree_node()->render_manager()); | |
1719 ASSERT_TRUE(subframe_request); | 1754 ASSERT_TRUE(subframe_request); |
1720 EXPECT_EQ(kUrl2, subframe_request->info().navigation_params.url); | 1755 EXPECT_EQ(kUrl2, subframe_request->info().navigation_params.url); |
1721 // First party for cookies url should be that of the main frame. | 1756 // First party for cookies url should be that of the main frame. |
1722 EXPECT_EQ( | 1757 EXPECT_EQ( |
1723 kUrl1, subframe_request->info().first_party_for_cookies); | 1758 kUrl1, subframe_request->info().first_party_for_cookies); |
1724 EXPECT_FALSE(subframe_request->info().is_main_frame); | 1759 EXPECT_FALSE(subframe_request->info().is_main_frame); |
1725 EXPECT_TRUE(subframe_request->info().parent_is_main_frame); | 1760 EXPECT_TRUE(subframe_request->info().parent_is_main_frame); |
1726 EXPECT_EQ(kFirstNavRequestID, subframe_request->navigation_request_id()); | 1761 EXPECT_EQ(kFirstNavRequestID, subframe_request->navigation_request_id()); |
1727 | 1762 |
| 1763 RenderFrameHostManager* main_frame_manager = |
| 1764 contents()->GetMainFrame()->frame_tree_node()->render_manager(); |
| 1765 SendRequestNavigation( |
| 1766 kUrl2, contents()->GetMainFrame()->frame_tree_node()); |
1728 // Simulate a BeginNavigation IPC on the main frame. | 1767 // Simulate a BeginNavigation IPC on the main frame. |
1729 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl3); | 1768 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl3); |
1730 NavigationRequest* main_request = GetNavigationRequestForRenderFrameManager( | 1769 NavigationRequest* main_request = GetNavigationRequestForRenderFrameManager( |
1731 contents()->GetMainFrame()->frame_tree_node()->render_manager()); | 1770 main_frame_manager); |
1732 ASSERT_TRUE(main_request); | 1771 ASSERT_TRUE(main_request); |
1733 EXPECT_EQ(kUrl3, main_request->info().navigation_params.url); | 1772 EXPECT_EQ(kUrl3, main_request->info().navigation_params.url); |
1734 EXPECT_EQ(kUrl3, main_request->info().first_party_for_cookies); | 1773 EXPECT_EQ(kUrl3, main_request->info().first_party_for_cookies); |
1735 EXPECT_TRUE(main_request->info().is_main_frame); | 1774 EXPECT_TRUE(main_request->info().is_main_frame); |
1736 EXPECT_FALSE(main_request->info().parent_is_main_frame); | 1775 EXPECT_FALSE(main_request->info().parent_is_main_frame); |
1737 EXPECT_EQ(kFirstNavRequestID + 1, main_request->navigation_request_id()); | 1776 EXPECT_EQ(kFirstNavRequestID + 1, main_request->navigation_request_id()); |
1738 } | 1777 } |
1739 | 1778 |
1740 // PlzNavigate: Test that RequestNavigation creates a NavigationRequest and that | 1779 // PlzNavigate: Test that RequestNavigation creates a NavigationRequest and that |
1741 // RenderFrameHost is not modified when the navigation commits. | 1780 // RenderFrameHost is not modified when the navigation commits. |
1742 TEST_F(RenderFrameHostManagerTest, | 1781 TEST_F(RenderFrameHostManagerTest, |
1743 BrowserSideNavigationRequestNavigationNoLiveRenderer) { | 1782 BrowserSideNavigationRequestNavigationNoLiveRenderer) { |
1744 const GURL kUrl("http://www.google.com/"); | 1783 const GURL kUrl("http://www.google.com/"); |
1745 | 1784 |
1746 EnableBrowserSideNavigation(); | 1785 EnableBrowserSideNavigation(); |
1747 EXPECT_FALSE(main_test_rfh()->render_view_host()->IsRenderViewLive()); | 1786 EXPECT_FALSE(main_test_rfh()->render_view_host()->IsRenderViewLive()); |
1748 contents()->GetController().LoadURL( | |
1749 kUrl, Referrer(), PAGE_TRANSITION_LINK, std::string()); | |
1750 RenderFrameHostManager* render_manager = | 1787 RenderFrameHostManager* render_manager = |
1751 main_test_rfh()->frame_tree_node()->render_manager(); | 1788 main_test_rfh()->frame_tree_node()->render_manager(); |
| 1789 SendRequestNavigation(kUrl, main_test_rfh()->frame_tree_node()); |
1752 NavigationRequest* main_request = | 1790 NavigationRequest* main_request = |
1753 GetNavigationRequestForRenderFrameManager(render_manager); | 1791 GetNavigationRequestForRenderFrameManager(render_manager); |
1754 // A NavigationRequest should have been generated. | 1792 // A NavigationRequest should have been generated. |
1755 EXPECT_TRUE(main_request != NULL); | 1793 EXPECT_TRUE(main_request != NULL); |
1756 RenderFrameHostImpl* rfh = main_test_rfh(); | 1794 RenderFrameHostImpl* rfh = main_test_rfh(); |
1757 | 1795 |
1758 // Now commit the same url. | 1796 // Now commit the same url. |
1759 NavigationBeforeCommitInfo commit_info; | 1797 NavigationBeforeCommitInfo commit_info; |
1760 commit_info.navigation_url = kUrl; | 1798 commit_info.navigation_url = kUrl; |
1761 commit_info.navigation_request_id = main_request->navigation_request_id(); | 1799 commit_info.navigation_request_id = main_request->navigation_request_id(); |
(...skipping 18 matching lines...) Expand all Loading... |
1780 // Navigate to the first page. | 1818 // Navigate to the first page. |
1781 contents()->NavigateAndCommit(kUrl1); | 1819 contents()->NavigateAndCommit(kUrl1); |
1782 TestRenderViewHost* rvh1 = test_rvh(); | 1820 TestRenderViewHost* rvh1 = test_rvh(); |
1783 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); | 1821 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); |
1784 RenderFrameHostImpl* rfh = main_test_rfh(); | 1822 RenderFrameHostImpl* rfh = main_test_rfh(); |
1785 RenderFrameHostManager* render_manager = | 1823 RenderFrameHostManager* render_manager = |
1786 main_test_rfh()->frame_tree_node()->render_manager(); | 1824 main_test_rfh()->frame_tree_node()->render_manager(); |
1787 | 1825 |
1788 EnableBrowserSideNavigation(); | 1826 EnableBrowserSideNavigation(); |
1789 // Navigate to a different site. | 1827 // Navigate to a different site. |
| 1828 SendRequestNavigation(kUrl2, main_test_rfh()->frame_tree_node()); |
1790 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 1829 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); |
1791 NavigationRequest* main_request = | 1830 NavigationRequest* main_request = |
1792 GetNavigationRequestForRenderFrameManager(render_manager); | 1831 GetNavigationRequestForRenderFrameManager(render_manager); |
1793 ASSERT_TRUE(main_request); | 1832 ASSERT_TRUE(main_request); |
1794 | 1833 |
1795 NavigationBeforeCommitInfo commit_info; | 1834 NavigationBeforeCommitInfo commit_info; |
1796 commit_info.navigation_url = kUrl2; | 1835 commit_info.navigation_url = kUrl2; |
1797 commit_info.navigation_request_id = main_request->navigation_request_id(); | 1836 commit_info.navigation_request_id = main_request->navigation_request_id(); |
1798 render_manager->CommitNavigation(commit_info); | 1837 render_manager->CommitNavigation(commit_info); |
1799 EXPECT_NE(main_test_rfh(), rfh); | 1838 EXPECT_NE(main_test_rfh(), rfh); |
(...skipping 15 matching lines...) Expand all Loading... |
1815 const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); | 1854 const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); |
1816 | 1855 |
1817 // Initialization. | 1856 // Initialization. |
1818 contents()->NavigateAndCommit(kUrl0); | 1857 contents()->NavigateAndCommit(kUrl0); |
1819 RenderFrameHostManager* render_manager = | 1858 RenderFrameHostManager* render_manager = |
1820 main_test_rfh()->frame_tree_node()->render_manager(); | 1859 main_test_rfh()->frame_tree_node()->render_manager(); |
1821 EnableBrowserSideNavigation(); | 1860 EnableBrowserSideNavigation(); |
1822 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 1861 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
1823 | 1862 |
1824 // Request navigation to the 1st URL and gather data. | 1863 // Request navigation to the 1st URL and gather data. |
| 1864 SendRequestNavigation(kUrl1, main_test_rfh()->frame_tree_node()); |
1825 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); | 1865 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); |
1826 NavigationRequest* request1 = | 1866 NavigationRequest* request1 = |
1827 GetNavigationRequestForRenderFrameManager(render_manager); | 1867 GetNavigationRequestForRenderFrameManager(render_manager); |
1828 ASSERT_TRUE(request1); | 1868 ASSERT_TRUE(request1); |
1829 int64 request_id1 = request1->navigation_request_id(); | 1869 int64 request_id1 = request1->navigation_request_id(); |
1830 | 1870 |
1831 // Request navigation to the 2nd URL and gather more data. | 1871 // Request navigation to the 2nd URL and gather more data. |
| 1872 SendRequestNavigation(kUrl2, main_test_rfh()->frame_tree_node()); |
1832 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 1873 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); |
1833 NavigationRequest* request2 = | 1874 NavigationRequest* request2 = |
1834 GetNavigationRequestForRenderFrameManager(render_manager); | 1875 GetNavigationRequestForRenderFrameManager(render_manager); |
1835 ASSERT_TRUE(request2); | 1876 ASSERT_TRUE(request2); |
1836 int64 request_id2 = request2->navigation_request_id(); | 1877 int64 request_id2 = request2->navigation_request_id(); |
1837 EXPECT_NE(request_id1, request_id2); | 1878 EXPECT_NE(request_id1, request_id2); |
1838 | 1879 |
1839 // Confirms that a stale commit is ignored by the RHFM. | 1880 // Confirms that a stale commit is ignored by the RHFM. |
1840 NavigationBeforeCommitInfo nbc_info; | 1881 NavigationBeforeCommitInfo nbc_info; |
1841 nbc_info.navigation_url = kUrl1; | 1882 nbc_info.navigation_url = kUrl1; |
1842 nbc_info.navigation_request_id = request_id1; | 1883 nbc_info.navigation_request_id = request_id1; |
1843 render_manager->CommitNavigation(nbc_info); | 1884 render_manager->CommitNavigation(nbc_info); |
1844 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 1885 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
1845 | 1886 |
1846 // Confirms that a valid, request-matching commit is correctly processed. | 1887 // Confirms that a valid, request-matching commit is correctly processed. |
1847 nbc_info.navigation_url = kUrl2; | 1888 nbc_info.navigation_url = kUrl2; |
1848 nbc_info.navigation_request_id = request_id2; | 1889 nbc_info.navigation_request_id = request_id2; |
1849 render_manager->CommitNavigation(nbc_info); | 1890 render_manager->CommitNavigation(nbc_info); |
1850 EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 1891 EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
1851 } | 1892 } |
1852 | 1893 |
| 1894 // PlzNavigate: Test that a reload navigation is properly signaled to the |
| 1895 // renderer when the navigation can commit. |
| 1896 TEST_F(RenderFrameHostManagerTest, |
| 1897 BrowserSideNavigationReload) { |
| 1898 const GURL kUrl("http://www.google.com/"); |
| 1899 contents()->NavigateAndCommit(kUrl); |
| 1900 |
| 1901 EnableBrowserSideNavigation(); |
| 1902 RenderFrameHostManager* render_manager = |
| 1903 main_test_rfh()->frame_tree_node()->render_manager(); |
| 1904 SendRequestNavigationWithParameters( |
| 1905 kUrl, main_test_rfh()->frame_tree_node(), Referrer(), |
| 1906 PAGE_TRANSITION_LINK, NavigationController::RELOAD); |
| 1907 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); |
| 1908 // A NavigationRequest should have been generated. |
| 1909 NavigationRequest* main_request = |
| 1910 GetNavigationRequestForRenderFrameManager(render_manager); |
| 1911 ASSERT_TRUE(main_request != NULL); |
| 1912 // Navigation parameters should have been generated. |
| 1913 NavigationParamsWithRequestAndCommitInfo* navigation_params = |
| 1914 GetNavigationParams(render_manager); |
| 1915 ASSERT_TRUE(navigation_params != NULL); |
| 1916 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD, |
| 1917 navigation_params->navigation_type); |
| 1918 int page_id = contents()->GetMaxPageIDForSiteInstance( |
| 1919 main_test_rfh()->GetSiteInstance()) + 1; |
| 1920 main_test_rfh()->SendNavigate(page_id, kUrl); |
| 1921 |
| 1922 // Now do a shift+reload. |
| 1923 SendRequestNavigationWithParameters( |
| 1924 kUrl, main_test_rfh()->frame_tree_node(), Referrer(), |
| 1925 PAGE_TRANSITION_LINK, NavigationController::RELOAD_IGNORING_CACHE); |
| 1926 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); |
| 1927 // A NavigationRequest should have been generated. |
| 1928 main_request = |
| 1929 GetNavigationRequestForRenderFrameManager(render_manager); |
| 1930 ASSERT_TRUE(main_request != NULL); |
| 1931 // Navigation parameters should have been generated. |
| 1932 navigation_params = |
| 1933 GetNavigationParams(render_manager); |
| 1934 ASSERT_TRUE(navigation_params != NULL); |
| 1935 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, |
| 1936 navigation_params->navigation_type); |
| 1937 page_id = contents()->GetMaxPageIDForSiteInstance( |
| 1938 main_test_rfh()->GetSiteInstance()) + 1; |
| 1939 main_test_rfh()->SendNavigate(page_id, kUrl); |
| 1940 } |
| 1941 |
1853 } // namespace content | 1942 } // namespace content |
OLD | NEW |