Chromium Code Reviews| 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(const GURL& url, | |
| 396 FrameTreeNode* node) { | |
|
nasko
2014/09/24 22:42:15
nit: I'd put the node parameter first, as we logic
clamy
2014/09/26 17:22:32
Done.
| |
| 397 SendRequestNavigationWithParameters( | |
| 398 url, node, Referrer(), ui::PAGE_TRANSITION_LINK, | |
| 399 FrameMsg_Navigate_Type::NORMAL); | |
| 400 } | |
| 401 | |
| 402 void SendRequestNavigationWithParameters( | |
| 403 const GURL& url, | |
| 404 FrameTreeNode* node, | |
| 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 CoreNavigationParams(entry->GetURL(), entry->GetReferrer(), | |
| 420 entry->GetTransitionType(), navigation_type, | |
| 421 !entry->IsViewSourceMode()), | |
| 422 CommitNavigationParams(entry->GetPageState(), | |
| 423 entry->GetIsOverridingUserAgent(), | |
| 424 base::TimeTicks::Now()))); | |
| 425 RequestNavigationParams request_params( | |
| 426 entry->GetHasPostData(), | |
| 427 entry->extra_headers(), | |
| 428 entry->GetBrowserInitiatedPostData()); | |
| 429 node->render_manager()->RequestNavigation(navigation_request.Pass(), | |
| 430 request_params); | |
| 431 } | |
| 432 | |
| 391 private: | 433 private: |
| 392 RenderFrameHostManagerTestWebUIControllerFactory factory_; | 434 RenderFrameHostManagerTestWebUIControllerFactory factory_; |
| 393 scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; | 435 scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; |
| 394 }; | 436 }; |
| 395 | 437 |
| 396 // Tests that when you navigate from a chrome:// url to another page, and | 438 // 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 | 439 // then do that same thing in another tab, that the two resulting pages have |
| 398 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is | 440 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is |
| 399 // a regression test for bug 9364. | 441 // a regression test for bug 9364. |
| 400 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) { | 442 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) { |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1697 | 1739 |
| 1698 contents()->GetMainFrame()->OnMessageReceived( | 1740 contents()->GetMainFrame()->OnMessageReceived( |
| 1699 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1741 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
| 1700 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1742 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 1701 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1743 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
| 1702 } | 1744 } |
| 1703 } | 1745 } |
| 1704 | 1746 |
| 1705 // PlzNavigate: Test that a proper NavigationRequest is created by | 1747 // PlzNavigate: Test that a proper NavigationRequest is created by |
| 1706 // BeginNavigation. | 1748 // BeginNavigation. |
| 1749 // Note that all PlzNavigate methods on the browser side require the use of the | |
| 1750 // flag kEnableBrowserSideNavigation. | |
| 1707 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { | 1751 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { |
| 1708 const GURL kUrl1("http://www.google.com/"); | 1752 const GURL kUrl1("http://www.google.com/"); |
| 1709 const GURL kUrl2("http://www.chromium.org/"); | 1753 const GURL kUrl2("http://www.chromium.org/"); |
| 1710 const GURL kUrl3("http://www.gmail.com/"); | 1754 const GURL kUrl3("http://www.gmail.com/"); |
| 1711 const int64 kFirstNavRequestID = 1; | 1755 const int64 kFirstNavRequestID = 1; |
| 1712 | 1756 |
| 1713 // TODO(clamy): we should be enabling browser side navigations here | 1757 // TODO(clamy): we should be enabling browser side navigations here |
| 1714 // when CommitNavigation is properly implemented. | 1758 // when CommitNavigation is properly implemented. |
| 1715 // Navigate to the first page. | 1759 // Navigate to the first page. |
| 1716 contents()->NavigateAndCommit(kUrl1); | 1760 contents()->NavigateAndCommit(kUrl1); |
| 1717 | 1761 |
| 1718 EnableBrowserSideNavigation(); | 1762 EnableBrowserSideNavigation(); |
| 1719 // Add a subframe. | 1763 // Add a subframe. |
| 1720 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( | 1764 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( |
| 1721 contents()->GetFrameTree()->AddFrame( | 1765 contents()->GetFrameTree()->AddFrame( |
| 1722 contents()->GetFrameTree()->root(), 14, "Child")); | 1766 contents()->GetFrameTree()->root(), 14, "Child")); |
| 1723 | 1767 |
| 1768 RenderFrameHostManager* subframe_manager = | |
| 1769 subframe_rfh->frame_tree_node()->render_manager(); | |
| 1770 SendRequestNavigation(kUrl2, subframe_rfh->frame_tree_node()); | |
| 1724 // Simulate a BeginNavigation IPC on the subframe. | 1771 // Simulate a BeginNavigation IPC on the subframe. |
| 1725 subframe_rfh->SendBeginNavigationWithURL(kUrl2); | 1772 subframe_rfh->SendBeginNavigationWithURL(kUrl2); |
| 1726 NavigationRequest* subframe_request = | 1773 NavigationRequest* subframe_request = |
| 1727 GetNavigationRequestForRenderFrameManager( | 1774 GetNavigationRequestForRenderFrameManager(subframe_manager); |
| 1728 subframe_rfh->frame_tree_node()->render_manager()); | |
| 1729 ASSERT_TRUE(subframe_request); | 1775 ASSERT_TRUE(subframe_request); |
| 1730 EXPECT_EQ(kUrl2, subframe_request->info().navigation_params.url); | 1776 EXPECT_EQ(kUrl2, subframe_request->core_params().url); |
| 1731 // First party for cookies url should be that of the main frame. | 1777 // First party for cookies url should be that of the main frame. |
| 1732 EXPECT_EQ( | 1778 EXPECT_EQ(kUrl1, subframe_request->info()->first_party_for_cookies); |
| 1733 kUrl1, subframe_request->info().first_party_for_cookies); | 1779 EXPECT_FALSE(subframe_request->info()->is_main_frame); |
| 1734 EXPECT_FALSE(subframe_request->info().is_main_frame); | 1780 EXPECT_TRUE(subframe_request->info()->parent_is_main_frame); |
| 1735 EXPECT_TRUE(subframe_request->info().parent_is_main_frame); | |
| 1736 EXPECT_EQ(kFirstNavRequestID, subframe_request->navigation_request_id()); | 1781 EXPECT_EQ(kFirstNavRequestID, subframe_request->navigation_request_id()); |
| 1737 | 1782 |
| 1783 RenderFrameHostManager* main_frame_manager = | |
| 1784 contents()->GetMainFrame()->frame_tree_node()->render_manager(); | |
| 1785 SendRequestNavigation(kUrl3, contents()->GetMainFrame()->frame_tree_node()); | |
| 1738 // Simulate a BeginNavigation IPC on the main frame. | 1786 // Simulate a BeginNavigation IPC on the main frame. |
| 1739 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl3); | 1787 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl3); |
| 1740 NavigationRequest* main_request = GetNavigationRequestForRenderFrameManager( | 1788 NavigationRequest* main_request = |
| 1741 contents()->GetMainFrame()->frame_tree_node()->render_manager()); | 1789 GetNavigationRequestForRenderFrameManager(main_frame_manager); |
| 1742 ASSERT_TRUE(main_request); | 1790 ASSERT_TRUE(main_request); |
| 1743 EXPECT_EQ(kUrl3, main_request->info().navigation_params.url); | 1791 EXPECT_EQ(kUrl3, main_request->core_params().url); |
| 1744 EXPECT_EQ(kUrl3, main_request->info().first_party_for_cookies); | 1792 EXPECT_EQ(kUrl3, main_request->info()->first_party_for_cookies); |
| 1745 EXPECT_TRUE(main_request->info().is_main_frame); | 1793 EXPECT_TRUE(main_request->info()->is_main_frame); |
| 1746 EXPECT_FALSE(main_request->info().parent_is_main_frame); | 1794 EXPECT_FALSE(main_request->info()->parent_is_main_frame); |
| 1747 EXPECT_EQ(kFirstNavRequestID + 1, main_request->navigation_request_id()); | 1795 EXPECT_EQ(kFirstNavRequestID + 1, main_request->navigation_request_id()); |
| 1748 } | 1796 } |
| 1749 | 1797 |
| 1750 // PlzNavigate: Test that RequestNavigation creates a NavigationRequest and that | 1798 // PlzNavigate: Test that RequestNavigation creates a NavigationRequest and that |
| 1751 // RenderFrameHost is not modified when the navigation commits. | 1799 // RenderFrameHost is not modified when the navigation commits. |
| 1752 TEST_F(RenderFrameHostManagerTest, | 1800 TEST_F(RenderFrameHostManagerTest, |
| 1753 BrowserSideNavigationRequestNavigationNoLiveRenderer) { | 1801 BrowserSideNavigationRequestNavigationNoLiveRenderer) { |
| 1754 const GURL kUrl("http://www.google.com/"); | 1802 const GURL kUrl("http://www.google.com/"); |
| 1755 | 1803 |
| 1756 EnableBrowserSideNavigation(); | 1804 EnableBrowserSideNavigation(); |
| 1757 EXPECT_FALSE(main_test_rfh()->render_view_host()->IsRenderViewLive()); | 1805 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 = | 1806 RenderFrameHostManager* render_manager = |
| 1761 main_test_rfh()->frame_tree_node()->render_manager(); | 1807 main_test_rfh()->frame_tree_node()->render_manager(); |
| 1808 SendRequestNavigation(kUrl, main_test_rfh()->frame_tree_node()); | |
| 1762 NavigationRequest* main_request = | 1809 NavigationRequest* main_request = |
| 1763 GetNavigationRequestForRenderFrameManager(render_manager); | 1810 GetNavigationRequestForRenderFrameManager(render_manager); |
| 1764 // A NavigationRequest should have been generated. | 1811 // A NavigationRequest should have been generated. |
| 1765 EXPECT_TRUE(main_request != NULL); | 1812 EXPECT_TRUE(main_request != NULL); |
| 1766 RenderFrameHostImpl* rfh = main_test_rfh(); | 1813 RenderFrameHostImpl* rfh = main_test_rfh(); |
| 1767 | 1814 |
| 1768 // Now commit the same url. | 1815 // Now commit the same url. |
| 1769 NavigationBeforeCommitInfo commit_info; | 1816 NavigationBeforeCommitInfo commit_info; |
| 1770 commit_info.navigation_url = kUrl; | 1817 commit_info.navigation_url = kUrl; |
| 1771 commit_info.navigation_request_id = main_request->navigation_request_id(); | 1818 commit_info.navigation_request_id = main_request->navigation_request_id(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1790 // Navigate to the first page. | 1837 // Navigate to the first page. |
| 1791 contents()->NavigateAndCommit(kUrl1); | 1838 contents()->NavigateAndCommit(kUrl1); |
| 1792 TestRenderViewHost* rvh1 = test_rvh(); | 1839 TestRenderViewHost* rvh1 = test_rvh(); |
| 1793 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); | 1840 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); |
| 1794 RenderFrameHostImpl* rfh = main_test_rfh(); | 1841 RenderFrameHostImpl* rfh = main_test_rfh(); |
| 1795 RenderFrameHostManager* render_manager = | 1842 RenderFrameHostManager* render_manager = |
| 1796 main_test_rfh()->frame_tree_node()->render_manager(); | 1843 main_test_rfh()->frame_tree_node()->render_manager(); |
| 1797 | 1844 |
| 1798 EnableBrowserSideNavigation(); | 1845 EnableBrowserSideNavigation(); |
| 1799 // Navigate to a different site. | 1846 // Navigate to a different site. |
| 1847 SendRequestNavigation(kUrl2, main_test_rfh()->frame_tree_node()); | |
| 1800 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 1848 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); |
| 1801 NavigationRequest* main_request = | 1849 NavigationRequest* main_request = |
| 1802 GetNavigationRequestForRenderFrameManager(render_manager); | 1850 GetNavigationRequestForRenderFrameManager(render_manager); |
| 1803 ASSERT_TRUE(main_request); | 1851 ASSERT_TRUE(main_request); |
| 1804 | 1852 |
| 1805 NavigationBeforeCommitInfo commit_info; | 1853 NavigationBeforeCommitInfo commit_info; |
| 1806 commit_info.navigation_url = kUrl2; | 1854 commit_info.navigation_url = kUrl2; |
| 1807 commit_info.navigation_request_id = main_request->navigation_request_id(); | 1855 commit_info.navigation_request_id = main_request->navigation_request_id(); |
| 1808 render_manager->CommitNavigation(commit_info); | 1856 render_manager->CommitNavigation(commit_info); |
| 1809 EXPECT_NE(main_test_rfh(), rfh); | 1857 EXPECT_NE(main_test_rfh(), rfh); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1825 const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); | 1873 const GURL kUrl2_site = SiteInstance::GetSiteForURL(browser_context(), kUrl2); |
| 1826 | 1874 |
| 1827 // Initialization. | 1875 // Initialization. |
| 1828 contents()->NavigateAndCommit(kUrl0); | 1876 contents()->NavigateAndCommit(kUrl0); |
| 1829 RenderFrameHostManager* render_manager = | 1877 RenderFrameHostManager* render_manager = |
| 1830 main_test_rfh()->frame_tree_node()->render_manager(); | 1878 main_test_rfh()->frame_tree_node()->render_manager(); |
| 1831 EnableBrowserSideNavigation(); | 1879 EnableBrowserSideNavigation(); |
| 1832 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 1880 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
| 1833 | 1881 |
| 1834 // Request navigation to the 1st URL and gather data. | 1882 // Request navigation to the 1st URL and gather data. |
| 1883 SendRequestNavigation(kUrl1, main_test_rfh()->frame_tree_node()); | |
| 1835 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); | 1884 main_test_rfh()->SendBeginNavigationWithURL(kUrl1); |
| 1836 NavigationRequest* request1 = | 1885 NavigationRequest* request1 = |
| 1837 GetNavigationRequestForRenderFrameManager(render_manager); | 1886 GetNavigationRequestForRenderFrameManager(render_manager); |
| 1838 ASSERT_TRUE(request1); | 1887 ASSERT_TRUE(request1); |
| 1839 int64 request_id1 = request1->navigation_request_id(); | 1888 int64 request_id1 = request1->navigation_request_id(); |
| 1840 | 1889 |
| 1841 // Request navigation to the 2nd URL and gather more data. | 1890 // Request navigation to the 2nd URL and gather more data. |
| 1891 SendRequestNavigation(kUrl2, main_test_rfh()->frame_tree_node()); | |
| 1842 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); | 1892 main_test_rfh()->SendBeginNavigationWithURL(kUrl2); |
| 1843 NavigationRequest* request2 = | 1893 NavigationRequest* request2 = |
| 1844 GetNavigationRequestForRenderFrameManager(render_manager); | 1894 GetNavigationRequestForRenderFrameManager(render_manager); |
| 1845 ASSERT_TRUE(request2); | 1895 ASSERT_TRUE(request2); |
| 1846 int64 request_id2 = request2->navigation_request_id(); | 1896 int64 request_id2 = request2->navigation_request_id(); |
| 1847 EXPECT_NE(request_id1, request_id2); | 1897 EXPECT_NE(request_id1, request_id2); |
| 1848 | 1898 |
| 1849 // Confirms that a stale commit is ignored by the RHFM. | 1899 // Confirms that a stale commit is ignored by the RHFM. |
| 1850 NavigationBeforeCommitInfo nbc_info; | 1900 NavigationBeforeCommitInfo nbc_info; |
| 1851 nbc_info.navigation_url = kUrl1; | 1901 nbc_info.navigation_url = kUrl1; |
| 1852 nbc_info.navigation_request_id = request_id1; | 1902 nbc_info.navigation_request_id = request_id1; |
| 1853 render_manager->CommitNavigation(nbc_info); | 1903 render_manager->CommitNavigation(nbc_info); |
| 1854 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 1904 EXPECT_EQ(kUrl0_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
| 1855 | 1905 |
| 1856 // Confirms that a valid, request-matching commit is correctly processed. | 1906 // Confirms that a valid, request-matching commit is correctly processed. |
| 1857 nbc_info.navigation_url = kUrl2; | 1907 nbc_info.navigation_url = kUrl2; |
| 1858 nbc_info.navigation_request_id = request_id2; | 1908 nbc_info.navigation_request_id = request_id2; |
| 1859 render_manager->CommitNavigation(nbc_info); | 1909 render_manager->CommitNavigation(nbc_info); |
| 1860 EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); | 1910 EXPECT_EQ(kUrl2_site, main_test_rfh()->GetSiteInstance()->GetSiteURL()); |
| 1861 } | 1911 } |
| 1862 | 1912 |
| 1913 // PlzNavigate: Test that a reload navigation is properly signaled to the | |
| 1914 // renderer when the navigation can commit. | |
| 1915 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationReload) { | |
| 1916 const GURL kUrl("http://www.google.com/"); | |
| 1917 contents()->NavigateAndCommit(kUrl); | |
| 1918 | |
| 1919 EnableBrowserSideNavigation(); | |
| 1920 RenderFrameHostManager* render_manager = | |
| 1921 main_test_rfh()->frame_tree_node()->render_manager(); | |
| 1922 SendRequestNavigationWithParameters( | |
| 1923 kUrl, main_test_rfh()->frame_tree_node(), Referrer(), | |
| 1924 ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::RELOAD); | |
| 1925 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); | |
| 1926 // A NavigationRequest should have been generated. | |
| 1927 NavigationRequest* main_request = | |
| 1928 GetNavigationRequestForRenderFrameManager(render_manager); | |
| 1929 ASSERT_TRUE(main_request != NULL); | |
| 1930 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD, | |
| 1931 main_request->core_params().navigation_type); | |
| 1932 int page_id = contents()->GetMaxPageIDForSiteInstance( | |
| 1933 main_test_rfh()->GetSiteInstance()) + 1; | |
| 1934 main_test_rfh()->SendNavigate(page_id, kUrl); | |
| 1935 | |
| 1936 // Now do a shift+reload. | |
| 1937 SendRequestNavigationWithParameters( | |
| 1938 kUrl, | |
| 1939 main_test_rfh()->frame_tree_node(), | |
| 1940 Referrer(), | |
| 1941 ui::PAGE_TRANSITION_LINK, | |
| 1942 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | |
| 1943 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); | |
| 1944 // A NavigationRequest should have been generated. | |
| 1945 main_request = GetNavigationRequestForRenderFrameManager(render_manager); | |
| 1946 ASSERT_TRUE(main_request != NULL); | |
| 1947 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, | |
| 1948 main_request->core_params().navigation_type); | |
| 1949 page_id = contents()->GetMaxPageIDForSiteInstance( | |
| 1950 main_test_rfh()->GetSiteInstance()) + 1; | |
| 1951 main_test_rfh()->SendNavigate(page_id, kUrl); | |
| 1952 } | |
| 1953 | |
| 1863 } // namespace content | 1954 } // namespace content |
| OLD | NEW |