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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 574403002: If a RemoteFrame asks to navigate, send an OpenURL IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +plumbing and test Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "content/browser/frame_host/cross_process_frame_connector.h" 9 #include "content/browser/frame_host/cross_process_frame_connector.h"
10 #include "content/browser/frame_host/frame_tree.h" 10 #include "content/browser/frame_host/frame_tree.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 ->GetRenderWidgetHostViewsInTree(); 292 ->GetRenderWidgetHostViewsInTree();
293 EXPECT_EQ(2U, views_set.size()); 293 EXPECT_EQ(2U, views_set.size());
294 } 294 }
295 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); 295 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent());
296 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); 296 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
297 EXPECT_EQ( 297 EXPECT_EQ(
298 child->current_frame_host()->render_view_host()->GetView(), 298 child->current_frame_host()->render_view_host()->GetView(),
299 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); 299 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
300 } 300 }
301 301
302 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) {
303 host_resolver()->AddRule("*", "127.0.0.1");
304 ASSERT_TRUE(test_server()->Start());
305 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
306 NavigateToURL(shell(), main_url);
307
308 // It is safe to obtain the root frame tree node here, as it doesn't change.
309 FrameTreeNode* root =
310 static_cast<WebContentsImpl*>(shell()->web_contents())->
311 GetFrameTree()->root();
312
313 SitePerProcessWebContentsObserver observer(shell()->web_contents());
314
315 // Load same-site page into iframe.
316 FrameTreeNode* child = root->child_at(0);
317 GURL http_url(test_server()->GetURL("files/title1.html"));
318 NavigateFrameToURL(child, http_url);
319 EXPECT_EQ(http_url, observer.navigation_url());
320 EXPECT_TRUE(observer.navigation_succeeded());
321 RenderFrameProxyHost* proxy_to_parent =
Charlie Reis 2014/09/18 20:22:28 We don't need the proxy_to_parent checks in this t
Nate Chapin 2014/09/18 22:39:02 Done.
322 child->render_manager()->GetRenderFrameProxyHost(
323 shell()->web_contents()->GetSiteInstance());
324 EXPECT_FALSE(proxy_to_parent);
325
326 // These must stay in scope with replace_host.
327 GURL::Replacements replace_host;
328 std::string foo_com("foo.com");
329
330 // Load cross-site page into iframe.
331 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
332 replace_host.SetHostStr(foo_com);
333 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
334 NavigateFrameToURL(root->child_at(0), cross_site_url);
335 EXPECT_EQ(cross_site_url, observer.navigation_url());
336 EXPECT_TRUE(observer.navigation_succeeded());
337
338 // Ensure that we have created a new process for the subframe.
339 ASSERT_EQ(1U, root->child_count());
340 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
341 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
342 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
343 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
344 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
Charlie Reis 2014/09/18 20:22:28 Let's keep this site_instance check (as a sanity c
Nate Chapin 2014/09/18 22:39:02 Done.
345 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
346 proxy_to_parent = child->render_manager()->GetProxyToParent();
347 EXPECT_TRUE(proxy_to_parent);
348 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
349 EXPECT_EQ(
350 rvh->GetView(),
351 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
352
353 // Emulate the main frame changing the src of the iframe such that it
354 // navigates crosssite.
Charlie Reis 2014/09/18 20:22:28 nit: cross-site
Nate Chapin 2014/09/18 22:39:02 Done.
355 cross_site_url = test_server()->GetURL("files/title3.html");
356 std::string bar_com("bar.com");
357 replace_host.SetHostStr(bar_com);
358 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
359 NavigateIframeToURL(shell(), cross_site_url, "test");
360 EXPECT_EQ(cross_site_url, observer.navigation_url());
361 EXPECT_TRUE(observer.navigation_succeeded());
362
363 // Check again that a new process is created and is different from the
364 // top level one and the previous one.
365 ASSERT_EQ(1U, root->child_count());
366 child = root->child_at(0);
367 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(),
368 child->current_frame_host()->render_view_host());
369 EXPECT_NE(rvh, child->current_frame_host()->render_view_host());
370 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
371 child->current_frame_host()->GetSiteInstance());
372 EXPECT_NE(site_instance,
373 child->current_frame_host()->GetSiteInstance());
Charlie Reis 2014/09/18 20:22:28 Again, these two site_instance checks are probably
Nate Chapin 2014/09/18 22:39:02 Done.
374 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(),
375 child->current_frame_host()->GetProcess());
376 EXPECT_NE(rph, child->current_frame_host()->GetProcess());
377 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent());
378 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
379 EXPECT_EQ(
380 child->current_frame_host()->render_view_host()->GetView(),
381 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
382 }
Charlie Reis 2014/09/18 20:22:27 Can we add a navigation back to the original site
383
302 // Crash a subframe and ensures its children are cleared from the FrameTree. 384 // Crash a subframe and ensures its children are cleared from the FrameTree.
303 // See http://crbug.com/338508. 385 // See http://crbug.com/338508.
304 // TODO(creis): Disabled for flakiness; see http://crbug.com/405582. 386 // TODO(creis): Disabled for flakiness; see http://crbug.com/405582.
305 // TODO(creis): Enable this on Android when we can kill the process there. 387 // TODO(creis): Enable this on Android when we can kill the process there.
306 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) { 388 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) {
307 host_resolver()->AddRule("*", "127.0.0.1"); 389 host_resolver()->AddRule("*", "127.0.0.1");
308 ASSERT_TRUE(test_server()->Start()); 390 ASSERT_TRUE(test_server()->Start());
309 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); 391 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
310 NavigateToURL(shell(), main_url); 392 NavigateToURL(shell(), main_url);
311 393
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 "server-redirect?" + client_redirect_http_url.spec())); 644 "server-redirect?" + client_redirect_http_url.spec()));
563 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 645 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
564 646
565 // DidFailProvisionalLoad when navigating to client_redirect_http_url. 647 // DidFailProvisionalLoad when navigating to client_redirect_http_url.
566 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 648 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
567 EXPECT_FALSE(observer.navigation_succeeded()); 649 EXPECT_FALSE(observer.navigation_succeeded());
568 } 650 }
569 } 651 }
570 652
571 } // namespace content 653 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698