Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 367653002: Add a FrameHostMsg_BeginNavigation IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit test + fixed bug in parent_is_render_frame_computation Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 static_cast<SiteInstanceImpl*>( 1838 static_cast<SiteInstanceImpl*>(
1838 pending_rfh->GetSiteInstance())->increment_active_view_count(); 1839 pending_rfh->GetSiteInstance())->increment_active_view_count();
1839 1840
1840 main_test_rfh()->OnMessageReceived( 1841 main_test_rfh()->OnMessageReceived(
1841 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); 1842 FrameHostMsg_BeforeUnload_ACK(0, false, now, now));
1842 EXPECT_FALSE(contents()->cross_navigation_pending()); 1843 EXPECT_FALSE(contents()->cross_navigation_pending());
1843 EXPECT_FALSE(rvh_deleted_observer.deleted()); 1844 EXPECT_FALSE(rvh_deleted_observer.deleted());
1844 } 1845 }
1845 } 1846 }
1846 1847
1848 // Project PlzNavigate: Test that a proper NavigationRequest is created by
1849 // BeginNavigation.
1850 TEST_F(RenderFrameHostManagerTest,PlzNavigateBeginNavigation) {
1851 const GURL kUrl1("http://www.google.com/");
1852 const GURL kUrl2("http://www.chromium.org/");
1853 const GURL kUrl3("http://www.gmail.com/");
1854
1855 // Navigate to the first page.
1856 contents()->NavigateAndCommit(kUrl1);
1857 TestRenderViewHost* rvh1 = test_rvh();
1858 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state());
1859
1860 // Add a subframe.
1861 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>(
1862 contents()->GetFrameTree()->AddFrame(
1863 contents()->GetFrameTree()->root(), 14, "Child"));
1864
1865 // Simulate a BeginNavigation IPC on the subframe.
1866 subframe_rfh->SendBeginNavigationWithURL(kUrl2);
1867 NavigationRequest* subframe_request =
1868 subframe_rfh->frame_tree_node()->render_manager()->navigation_request();
1869 DCHECK(subframe_request);
1870 EXPECT_EQ(kUrl2, subframe_request->info().url);
1871 // First party for cookies url should be that of the main frame.
1872 EXPECT_EQ(kUrl1, subframe_request->info().first_party_for_cookies);
1873 EXPECT_FALSE(subframe_request->info().is_main_frame);
1874 EXPECT_TRUE(subframe_request->info().parent_is_main_frame);
1875
1876 // Simulate a BeginNavigation IPC on the main frame.
1877 main_test_rfh()->SendBeginNavigationWithURL(kUrl3);
1878 NavigationRequest* main_request =
1879 main_test_rfh()->frame_tree_node()->render_manager()
1880 ->navigation_request();
1881 DCHECK(main_request);
1882 EXPECT_EQ(kUrl3, main_request->info().url);
1883 EXPECT_EQ(kUrl3, main_request->info().first_party_for_cookies);
1884 EXPECT_TRUE(main_request->info().is_main_frame);
1885 EXPECT_FALSE(main_request->info().parent_is_main_frame);
1886 }
1887
1847 } // namespace content 1888 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698