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

Unified Diff: content/browser/frame_host/navigator_impl_unittest.cc

Issue 701953006: PlzNavigate: Speculatively spawns a renderer process for navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-applying previous changes over. Created 6 years, 1 month 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/navigator_impl_unittest.cc
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index 96afc97d3479fbf69b0575ba16bdf879d1bfb3eb..2476047f458949b500803abcddfbe376b42462f5 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -85,6 +85,8 @@ class NavigatorTestWithBrowserSideNavigation
// BeginNavigation.
// Note that all PlzNavigate methods on the browser side require the use of the
// flag kEnableBrowserSideNavigation.
+// TODO(carlosk): Will fix this ASAP but it currently crashes with my latest
+// changes from speculative renderer creation.
TEST_F(NavigatorTestWithBrowserSideNavigation, BeginNavigation) {
clamy 2014/11/25 16:50:57 Is it still failing?
carlosk 2014/11/28 13:08:17 Now it's not anymore so that TODO is gone.
const GURL kUrl1("http://www.google.com/");
const GURL kUrl2("http://www.chromium.org/");
@@ -228,12 +230,11 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) {
scoped_refptr<ResourceResponse> response(new ResourceResponse);
GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted(
response, MakeEmptyStream());
- RenderFrameHostImpl* pending_rfh =
- node->render_manager()->pending_frame_host();
- ASSERT_TRUE(pending_rfh);
- EXPECT_NE(pending_rfh, rfh);
- EXPECT_TRUE(pending_rfh->IsRenderFrameLive());
- EXPECT_TRUE(pending_rfh->render_view_host()->IsRenderViewLive());
+ RenderFrameHostImpl* final_rfh = main_test_rfh();
+ ASSERT_TRUE(final_rfh);
+ EXPECT_NE(final_rfh, rfh);
+ EXPECT_TRUE(final_rfh->IsRenderFrameLive());
+ EXPECT_TRUE(final_rfh->render_view_host()->IsRenderViewLive());
}
// PlzNavigate: Test that redirects are followed.
@@ -269,15 +270,14 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) {
response = new ResourceResponse;
GetLoaderForNavigationRequest(main_request)->CallOnResponseStarted(
response, MakeEmptyStream());
- RenderFrameHostImpl* pending_rfh =
- node->render_manager()->pending_frame_host();
- ASSERT_TRUE(pending_rfh);
- EXPECT_NE(pending_rfh, rfh);
- EXPECT_TRUE(pending_rfh->IsRenderFrameLive());
- EXPECT_TRUE(pending_rfh->render_view_host()->IsRenderViewLive());
+ RenderFrameHostImpl* final_rfh = main_test_rfh();
+ ASSERT_TRUE(final_rfh);
+ EXPECT_NE(final_rfh, rfh);
+ EXPECT_TRUE(final_rfh->IsRenderFrameLive());
+ EXPECT_TRUE(final_rfh->render_view_host()->IsRenderViewLive());
}
-// PlzNavigate: Test that a navigation is cancelled if another request has been
+// PlzNavigate: Test that a navigation is canceled if another request has been
// issued in the meantime.
TEST_F(NavigatorTestWithBrowserSideNavigation, ReplacePendingNavigation) {
const GURL kUrl0("http://www.wikipedia.org/");
@@ -315,10 +315,9 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, ReplacePendingNavigation) {
scoped_refptr<ResourceResponse> response(new ResourceResponse);
GetLoaderForNavigationRequest(request2)->CallOnResponseStarted(
response, MakeEmptyStream());
- RenderFrameHostImpl* pending_rfh =
- node->render_manager()->pending_frame_host();
- ASSERT_TRUE(pending_rfh);
- EXPECT_EQ(kUrl2_site, pending_rfh->GetSiteInstance()->GetSiteURL());
+ RenderFrameHostImpl* final_rfh = main_test_rfh();
+ ASSERT_TRUE(final_rfh);
+ EXPECT_EQ(kUrl2_site, final_rfh->GetSiteInstance()->GetSiteURL());
}
// PlzNavigate: Test that a reload navigation is properly signaled to the
@@ -354,4 +353,48 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
main_request->common_params().navigation_type);
}
+// PlzNavigate: Confirms that a speculative renderer process is used when
nasko 2014/11/25 00:19:10 nit: s/renderer process/renderer/ or s/renderer pr
carlosk 2014/11/28 13:08:17 Done.
+// navigation when navigating from one site to the other
clamy 2014/11/25 16:50:57 Remove "when navigation"
carlosk 2014/11/28 13:08:17 Done.
+TEST_F(NavigatorTestWithBrowserSideNavigation,
+ SpeculativeRendererWorksBaseCase) {
+ // Navigates to an initial site.
clamy 2014/11/25 16:50:57 nit: Navigate (no s).
carlosk 2014/11/28 13:08:17 Done.
+ const GURL kUrlInit("http://wikipedia.org/");
+ contents()->NavigateAndCommit(kUrlInit);
+ TestRenderFrameHost* mrfh = main_test_rfh();
+ FrameTreeNode* node = mrfh->frame_tree_node();
+ RenderFrameHostManager* rfhm = node->render_manager();
+ RenderFrameHost* srfh = rfhm->speculative_render_frame_host();
+ ASSERT_FALSE(srfh);
+
+ // Begins navigating to another site.
nasko 2014/11/25 00:19:10 nit: Begin (no s).
carlosk 2014/11/28 13:08:17 Done.
+ const GURL kUrl("http://google.com/");
+ SendRequestNavigation(node, kUrl);
+ contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl);
+ srfh = rfhm->speculative_render_frame_host();
+ ASSERT_TRUE(srfh);
+ EXPECT_NE(srfh, mrfh);
+ EXPECT_TRUE(srfh->GetProcess()->HasConnection());
+
+ // Commits.
nasko 2014/11/25 00:19:10 nit: Commit (no s).
carlosk 2014/11/28 13:08:17 Done.
+ scoped_refptr<ResourceResponse> response(new ResourceResponse);
+ NavigationRequest* main_request = GetNavigationRequestForFrameTreeNode(node);
+ GetLoaderForNavigationRequest(main_request)
+ ->CallOnResponseStarted(response, MakeEmptyStream());
+ EXPECT_EQ(srfh, main_test_rfh());
+ EXPECT_FALSE(rfhm->speculative_render_frame_host());
+
+ // And just for completeness invokes OnDidCommitProvisionalLoad which
clamy 2014/11/25 16:50:57 nit: invoke (no s).
carlosk 2014/11/28 13:08:17 Done.
+ // shouldn't change anything in RFHM.
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
+ params.page_id = 1;
+ params.url = kUrl;
+ params.was_within_same_page = false;
+ params.is_post = false;
+ params.post_id = -1;
+ params.page_state = PageState::CreateForTesting(kUrl, false, 0, 0);
+ main_test_rfh()->SendNavigateWithParams(&params);
+ EXPECT_EQ(srfh, main_test_rfh());
+ EXPECT_FALSE(rfhm->speculative_render_frame_host());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698