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..1bfb9bc108d0756d709a9c2250320fa8a06de725 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" |
@@ -363,6 +364,11 @@ class RenderFrameHostManagerTest |
return ntp_rvh; |
} |
+ NavigationRequest* NavigationRequestForRenderFrameManager( |
+ RenderFrameHostManager* manager) const { |
+ return manager->navigation_request_for_testing(); |
+ } |
+ |
private: |
RenderFrameHostManagerTestWebUIControllerFactory factory_; |
scoped_ptr<FrameLifetimeConsistencyChecker> lifetime_checker_; |
@@ -1844,4 +1850,46 @@ TEST_F(RenderFrameHostManagerTest, |
} |
} |
+// Project PlzNavigate: Test that a proper NavigationRequest is created by |
jam
2014/07/15 00:05:43
nit: years later, few will know what PlzNavigate c
clamy
2014/07/15 15:32:14
Done.
|
+// 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 = |
+ NavigationRequestForRenderFrameManager( |
+ subframe_rfh->frame_tree_node()->render_manager()); |
+ ASSERT_TRUE(subframe_request); |
+ EXPECT_EQ(kUrl2, subframe_request->info_for_testing().url); |
+ // First party for cookies url should be that of the main frame. |
+ EXPECT_EQ( |
+ kUrl1, subframe_request->info_for_testing().first_party_for_cookies); |
+ EXPECT_FALSE(subframe_request->info_for_testing().is_main_frame); |
+ EXPECT_TRUE(subframe_request->info_for_testing().parent_is_main_frame); |
+ |
+ // Simulate a BeginNavigation IPC on the main frame. |
+ main_test_rfh()->SendBeginNavigationWithURL(kUrl3); |
+ NavigationRequest* main_request = |
+ NavigationRequestForRenderFrameManager( |
+ main_test_rfh()->frame_tree_node()->render_manager()); |
+ ASSERT_TRUE(main_request); |
+ EXPECT_EQ(kUrl3, main_request->info_for_testing().url); |
+ EXPECT_EQ(kUrl3, main_request->info_for_testing().first_party_for_cookies); |
+ EXPECT_TRUE(main_request->info_for_testing().is_main_frame); |
+ EXPECT_FALSE(main_request->info_for_testing().parent_is_main_frame); |
+} |
+ |
} // namespace content |