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

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: Addressed Przemek's comments + fixed compilation error 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..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

Powered by Google App Engine
This is Rietveld 408576698