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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.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/navigator.h" | 11 #include "content/browser/frame_host/navigator.h" |
11 #include "content/browser/frame_host/render_frame_host_manager.h" | 12 #include "content/browser/frame_host/render_frame_host_manager.h" |
12 #include "content/browser/site_instance_impl.h" | 13 #include "content/browser/site_instance_impl.h" |
13 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 14 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
14 #include "content/common/frame_messages.h" | 15 #include "content/common/frame_messages.h" |
15 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
16 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
19 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 // BeforeUnload finishes. | 357 // BeforeUnload finishes. |
357 ntp_rvh->SendBeforeUnloadACK(true); | 358 ntp_rvh->SendBeforeUnloadACK(true); |
358 | 359 |
359 dest_rvh->SendNavigate(101, kDestUrl); | 360 dest_rvh->SendNavigate(101, kDestUrl); |
360 ntp_rvh->OnSwappedOut(false); | 361 ntp_rvh->OnSwappedOut(false); |
361 | 362 |
362 EXPECT_TRUE(ntp_rvh->IsSwappedOut()); | 363 EXPECT_TRUE(ntp_rvh->IsSwappedOut()); |
363 return ntp_rvh; | 364 return ntp_rvh; |
364 } | 365 } |
365 | 366 |
367 NavigationRequest* NavigationRequestForRenderFrameManager( | |
368 RenderFrameHostManager* manager) const { | |
369 return manager->navigation_request_for_testing(); | |
370 } | |
371 | |
366 private: | 372 private: |
367 RenderFrameHostManagerTestWebUIControllerFactory factory_; | 373 RenderFrameHostManagerTestWebUIControllerFactory factory_; |
368 scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; | 374 scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; |
369 }; | 375 }; |
370 | 376 |
371 // Tests that when you navigate from a chrome:// url to another page, and | 377 // Tests that when you navigate from a chrome:// url to another page, and |
372 // then do that same thing in another tab, that the two resulting pages have | 378 // then do that same thing in another tab, that the two resulting pages have |
373 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is | 379 // different SiteInstances, BrowsingInstances, and RenderProcessHosts. This is |
374 // a regression test for bug 9364. | 380 // a regression test for bug 9364. |
375 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) { | 381 TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) { |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1837 static_cast<SiteInstanceImpl*>( | 1843 static_cast<SiteInstanceImpl*>( |
1838 pending_rfh->GetSiteInstance())->increment_active_view_count(); | 1844 pending_rfh->GetSiteInstance())->increment_active_view_count(); |
1839 | 1845 |
1840 main_test_rfh()->OnMessageReceived( | 1846 main_test_rfh()->OnMessageReceived( |
1841 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1847 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
1842 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1848 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1843 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1849 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
1844 } | 1850 } |
1845 } | 1851 } |
1846 | 1852 |
1853 // Project PlzNavigate: Test that a proper NavigationRequest is created by | |
1854 // BeginNavigation. | |
1855 TEST_F(RenderFrameHostManagerTest,PlzNavigateBeginNavigation) { | |
ppi
2014/07/07 14:10:05
nit: missing space after comma
clamy
2014/07/08 14:21:39
Done.
| |
1856 const GURL kUrl1("http://www.google.com/"); | |
1857 const GURL kUrl2("http://www.chromium.org/"); | |
1858 const GURL kUrl3("http://www.gmail.com/"); | |
1859 | |
1860 // Navigate to the first page. | |
1861 contents()->NavigateAndCommit(kUrl1); | |
1862 TestRenderViewHost* rvh1 = test_rvh(); | |
1863 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); | |
1864 | |
1865 // Add a subframe. | |
1866 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( | |
1867 contents()->GetFrameTree()->AddFrame( | |
1868 contents()->GetFrameTree()->root(), 14, "Child")); | |
1869 | |
1870 // Simulate a BeginNavigation IPC on the subframe. | |
1871 subframe_rfh->SendBeginNavigationWithURL(kUrl2); | |
1872 NavigationRequest* subframe_request = | |
1873 NavigationRequestForRenderFrameManager( | |
1874 subframe_rfh->frame_tree_node()->render_manager()); | |
1875 DCHECK(subframe_request); | |
ppi
2014/07/07 14:10:05
We probably should be using ASSERT_* instead of (D
clamy
2014/07/08 14:21:39
Done.
| |
1876 EXPECT_EQ(kUrl2, subframe_request->info_for_testing().url); | |
1877 // First party for cookies url should be that of the main frame. | |
1878 EXPECT_EQ( | |
1879 kUrl1, subframe_request->info_for_testing().first_party_for_cookies); | |
1880 EXPECT_FALSE(subframe_request->info_for_testing().is_main_frame); | |
1881 EXPECT_TRUE(subframe_request->info_for_testing().parent_is_main_frame); | |
1882 | |
1883 // Simulate a BeginNavigation IPC on the main frame. | |
1884 main_test_rfh()->SendBeginNavigationWithURL(kUrl3); | |
1885 NavigationRequest* main_request = | |
1886 NavigationRequestForRenderFrameManager( | |
1887 main_test_rfh()->frame_tree_node()->render_manager()); | |
1888 DCHECK(main_request); | |
ppi
2014/07/07 14:10:05
See above.
clamy
2014/07/08 14:21:39
Done.
| |
1889 EXPECT_EQ(kUrl3, main_request->info_for_testing().url); | |
1890 EXPECT_EQ(kUrl3, main_request->info_for_testing().first_party_for_cookies); | |
1891 EXPECT_TRUE(main_request->info_for_testing().is_main_frame); | |
1892 EXPECT_FALSE(main_request->info_for_testing().parent_is_main_frame); | |
1893 } | |
1894 | |
1847 } // namespace content | 1895 } // namespace content |
OLD | NEW |