Index: content/browser/frame_host/render_frame_host_manager_unittest.cc |
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc |
index a5100dfbe4b2dc071a52f2e80d9c8271e3b260c9..8d69ee8b84886f9695099620309e7de088f6bbe7 100644 |
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc |
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "content/browser/frame_host/cross_site_transferring_request.h" |
#include "content/browser/frame_host/navigation_controller_impl.h" |
#include "content/browser/frame_host/navigation_entry_impl.h" |
+#include "content/browser/frame_host/navigation_request.h" |
#include "content/browser/frame_host/navigator.h" |
#include "content/browser/frame_host/render_frame_host_manager.h" |
#include "content/browser/site_instance_impl.h" |
@@ -1844,4 +1845,44 @@ TEST_F(RenderFrameHostManagerTest, |
} |
} |
+// Project PlzNavigate: Test that a proper NavigationRequest is created by |
+// BeginNavigation. |
+TEST_F(RenderFrameHostManagerTest,PlzNavigateBeginNavigation) { |
+ const GURL kUrl1("http://www.google.com/"); |
+ const GURL kUrl2("http://www.chromium.org/"); |
+ const GURL kUrl3("http://www.gmail.com/"); |
+ |
+ // Navigate to the first page. |
+ contents()->NavigateAndCommit(kUrl1); |
+ TestRenderViewHost* rvh1 = test_rvh(); |
+ EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); |
+ |
+ // Add a subframe. |
+ TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( |
+ contents()->GetFrameTree()->AddFrame( |
+ contents()->GetFrameTree()->root(), 14, "Child")); |
+ |
+ // Simulate a BeginNavigation IPC on the subframe. |
+ subframe_rfh->SendBeginNavigationWithURL(kUrl2); |
+ NavigationRequest* subframe_request = |
+ subframe_rfh->frame_tree_node()->render_manager()->navigation_request(); |
+ DCHECK(subframe_request); |
+ EXPECT_EQ(kUrl2, subframe_request->info().url); |
+ // First party for cookies url should be that of the main frame. |
+ EXPECT_EQ(kUrl1, subframe_request->info().first_party_for_cookies); |
+ EXPECT_FALSE(subframe_request->info().is_main_frame); |
+ EXPECT_TRUE(subframe_request->info().parent_is_main_frame); |
+ |
+ // Simulate a BeginNavigation IPC on the main frame. |
+ main_test_rfh()->SendBeginNavigationWithURL(kUrl3); |
+ NavigationRequest* main_request = |
+ main_test_rfh()->frame_tree_node()->render_manager() |
+ ->navigation_request(); |
+ DCHECK(main_request); |
+ EXPECT_EQ(kUrl3, main_request->info().url); |
+ EXPECT_EQ(kUrl3, main_request->info().first_party_for_cookies); |
+ EXPECT_TRUE(main_request->info().is_main_frame); |
+ EXPECT_FALSE(main_request->info().parent_is_main_frame); |
+} |
+ |
} // namespace content |