OLD | NEW |
---|---|
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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 // Load a cross-site page into both iframes. | 452 // Load a cross-site page into both iframes. |
453 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 453 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
454 NavigateFrameToURL(root->child_at(0), foo_url); | 454 NavigateFrameToURL(root->child_at(0), foo_url); |
455 EXPECT_TRUE(observer.last_navigation_succeeded()); | 455 EXPECT_TRUE(observer.last_navigation_succeeded()); |
456 EXPECT_EQ(foo_url, observer.last_navigation_url()); | 456 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
457 NavigateFrameToURL(root->child_at(1), foo_url); | 457 NavigateFrameToURL(root->child_at(1), foo_url); |
458 EXPECT_TRUE(observer.last_navigation_succeeded()); | 458 EXPECT_TRUE(observer.last_navigation_succeeded()); |
459 EXPECT_EQ(foo_url, observer.last_navigation_url()); | 459 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
460 | 460 |
461 // Ensure that we have created a new process for the subframes. | 461 // Ensure that we have created a new process for the subframes. |
462 RenderFrameHostImpl* child1_rfh = root->child_at(0)->current_frame_host(); | |
463 RenderFrameHostImpl* child2_rfh = root->child_at(1)->current_frame_host(); | |
462 ASSERT_EQ(2U, root->child_count()); | 464 ASSERT_EQ(2U, root->child_count()); |
463 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 465 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
464 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 466 child1_rfh->GetSiteInstance()); |
465 EXPECT_EQ(root->child_at(0)->current_frame_host()->GetSiteInstance(), | 467 EXPECT_EQ(child1_rfh->GetSiteInstance(), child2_rfh->GetSiteInstance()); |
466 root->child_at(1)->current_frame_host()->GetSiteInstance()); | 468 |
469 int subframe_process = child1_rfh->GetSiteInstance()->GetProcess()->GetID(); | |
Charlie Reis
2015/05/21 18:48:16
At the risk of spilling to the next line, I think
nasko
2015/05/21 21:28:08
Done.
| |
470 int subframe_rvh = child1_rfh->render_view_host()->GetRoutingID(); | |
471 EXPECT_TRUE(RenderViewHost::FromID(subframe_process, subframe_rvh)); | |
467 | 472 |
468 // Use Javascript in the parent to remove one of the frames and ensure that | 473 // Use Javascript in the parent to remove one of the frames and ensure that |
469 // the subframe goes away. | 474 // the subframe goes away. |
470 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 475 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
471 "document.body.removeChild(" | 476 "document.body.removeChild(" |
472 "document.querySelectorAll('iframe')[0])")); | 477 "document.querySelectorAll('iframe')[0])")); |
473 ASSERT_EQ(1U, root->child_count()); | 478 ASSERT_EQ(1U, root->child_count()); |
474 | 479 |
475 // Load a new same-site page in the top-level frame and ensure the other | 480 // Load a new same-site page in the top-level frame and ensure the other |
476 // subframe goes away. | 481 // subframe goes away. |
477 GURL new_url(embedded_test_server()->GetURL("/title1.html")); | 482 GURL new_url(embedded_test_server()->GetURL("/title1.html")); |
478 NavigateToURL(shell(), new_url); | 483 NavigateToURL(shell(), new_url); |
479 ASSERT_EQ(0U, root->child_count()); | 484 ASSERT_EQ(0U, root->child_count()); |
485 | |
486 EXPECT_FALSE(RenderViewHost::FromID(subframe_process, subframe_rvh)); | |
Charlie Reis
2015/05/21 18:48:16
// Ensure the RVH for the subframe gets cleaned up
nasko
2015/05/21 21:28:08
Done.
| |
480 } | 487 } |
481 | 488 |
482 // Ensure that root frames cannot be detached. | 489 // Ensure that root frames cannot be detached. |
483 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { | 490 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { |
484 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 491 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
485 NavigateToURL(shell(), main_url); | 492 NavigateToURL(shell(), main_url); |
486 | 493 |
487 // It is safe to obtain the root frame tree node here, as it doesn't change. | 494 // It is safe to obtain the root frame tree node here, as it doesn't change. |
488 FrameTreeNode* root = | 495 FrameTreeNode* root = |
489 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 496 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
(...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2460 " |--Site A\n" | 2467 " |--Site A\n" |
2461 " +--Site A\n" | 2468 " +--Site A\n" |
2462 " |--Site A\n" | 2469 " |--Site A\n" |
2463 " +--Site A\n" | 2470 " +--Site A\n" |
2464 " +--Site A\n" | 2471 " +--Site A\n" |
2465 "Where A = http://127.0.0.1/", | 2472 "Where A = http://127.0.0.1/", |
2466 DepictFrameTree(root)); | 2473 DepictFrameTree(root)); |
2467 } | 2474 } |
2468 | 2475 |
2469 } // namespace content | 2476 } // namespace content |
OLD | NEW |