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

Unified 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698