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

Side by Side Diff: content/browser/frame_host/navigator_impl_unittest.cc

Issue 1066823004: PlzNavigate: improve tracking of improper subframe swap-out. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and changes from CR coments (sorry about the mixed patch set) Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/frame_host/navigation_request.h" 10 #include "content/browser/frame_host/navigation_request.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 EXPECT_TRUE(request->browser_initiated()); 251 EXPECT_TRUE(request->browser_initiated());
252 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, request->state()); 252 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, request->state());
253 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 253 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
254 254
255 // Simulate a beforeUnload denial. 255 // Simulate a beforeUnload denial.
256 main_test_rfh()->SendBeforeUnloadACK(false); 256 main_test_rfh()->SendBeforeUnloadACK(false);
257 EXPECT_FALSE(node->navigation_request()); 257 EXPECT_FALSE(node->navigation_request());
258 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); 258 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
259 } 259 }
260 260
261 // PlzNavigate: Test that a proper NavigationRequest is created by 261 // PlzNavigate: Test that navigation state is properly maintained when
262 // RequestNavigation. 262 // navigating simultaneously at the root frame and at a subframe levels.
263 TEST_F(NavigatorTestWithBrowserSideNavigation, BeginNavigation) { 263 TEST_F(NavigatorTestWithBrowserSideNavigation,
clamy 2015/04/27 12:05:20 Note that the original goal of this test is to che
264 NavigatingAtRootAndSubframeSimultaneously) {
264 const GURL kUrl1("http://www.google.com/"); 265 const GURL kUrl1("http://www.google.com/");
265 const GURL kUrl2("http://www.chromium.org/"); 266 const GURL kUrl2("http://www.chromium.org/");
266 const GURL kUrl3("http://www.gmail.com/"); 267 const GURL kUrl3("http://www.gmail.com/");
267 268
268 contents()->NavigateAndCommit(kUrl1); 269 contents()->NavigateAndCommit(kUrl1);
270 process()->sink().ClearMessages();
269 271
270 // Add a subframe. 272 // Add a subframe.
271 FrameTreeNode* root_node = contents()->GetFrameTree()->root(); 273 FrameTreeNode* root_node = contents()->GetFrameTree()->root();
272 TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child"); 274 TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child");
273 ASSERT_TRUE(subframe_rfh); 275 ASSERT_TRUE(subframe_rfh);
274 276
275 // Start a navigation at the subframe. 277 // Start a navigation at the subframe.
276 FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node(); 278 FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node();
277 RequestNavigation(subframe_node, kUrl2); 279 RequestNavigation(subframe_node, kUrl2);
278 NavigationRequest* subframe_request = subframe_node->navigation_request(); 280 NavigationRequest* subframe_request = subframe_node->navigation_request();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // BeforeUnloadACK was received from the renderer so the navigation should 326 // BeforeUnloadACK was received from the renderer so the navigation should
325 // have started. 327 // have started.
326 EXPECT_EQ(NavigationRequest::STARTED, main_request->state()); 328 EXPECT_EQ(NavigationRequest::STARTED, main_request->state());
327 329
328 // Main frame navigation to a different site should use a speculative 330 // Main frame navigation to a different site should use a speculative
329 // RenderFrameHost. 331 // RenderFrameHost.
330 EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); 332 EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node));
331 333
332 // As the main frame hasn't yet committed the subframe still exists. Thus, the 334 // As the main frame hasn't yet committed the subframe still exists. Thus, the
333 // above situation regarding subframe navigations is valid here. 335 // above situation regarding subframe navigations is valid here.
336 ASSERT_TRUE(subframe_node->navigation_request());
334 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 337 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
335 switches::kSitePerProcess)) { 338 switches::kSitePerProcess)) {
336 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); 339 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node));
337 } else { 340 } else {
338 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); 341 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node));
339 } 342 }
343
344 // Have the navigation commit for the root node's speculative RenderFrameHost.
clamy 2015/04/27 12:05:20 This comment is misleading. If you want to simulat
345 scoped_refptr<ResourceResponse> response(new ResourceResponse);
346 main_loader->CallOnResponseStarted(response, MakeEmptyStream());
347 TestRenderFrameHost* speculative_root_rfh =
348 GetSpeculativeRenderFrameHost(root_node);
349 ASSERT_TRUE(speculative_root_rfh);
350 EXPECT_TRUE(DidRenderFrameHostRequestCommit(speculative_root_rfh));
351
352 // The subframe request is still there as the subframe still exists.
353 ASSERT_TRUE(subframe_node->navigation_request());
340 } 354 }
341 355
342 // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels 356 // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels
343 // the navigation. 357 // the navigation.
344 TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) { 358 TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) {
345 const GURL kUrl1("http://www.chromium.org/"); 359 const GURL kUrl1("http://www.chromium.org/");
346 const GURL kUrl2("http://www.google.com/"); 360 const GURL kUrl2("http://www.google.com/");
347 361
348 // Load a URL. 362 // Load a URL.
349 contents()->NavigateAndCommit(kUrl1); 363 contents()->NavigateAndCommit(kUrl1);
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1133
1120 SiteInstance* converted_instance_2 = 1134 SiteInstance* converted_instance_2 =
1121 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); 1135 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get());
1122 // Should return |unrelated_instance| because its site matches and it is 1136 // Should return |unrelated_instance| because its site matches and it is
1123 // unrelated to the current SiteInstance. 1137 // unrelated to the current SiteInstance.
1124 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); 1138 EXPECT_EQ(unrelated_instance.get(), converted_instance_2);
1125 } 1139 }
1126 } 1140 }
1127 1141
1128 } // namespace content 1142 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698