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