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_id = |
| 470 child1_rfh->GetSiteInstance()->GetProcess()->GetID(); |
| 471 int subframe_rvh_id = child1_rfh->render_view_host()->GetRoutingID(); |
| 472 EXPECT_TRUE(RenderViewHost::FromID(subframe_process_id, subframe_rvh_id)); |
467 | 473 |
468 // Use Javascript in the parent to remove one of the frames and ensure that | 474 // Use Javascript in the parent to remove one of the frames and ensure that |
469 // the subframe goes away. | 475 // the subframe goes away. |
470 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 476 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
471 "document.body.removeChild(" | 477 "document.body.removeChild(" |
472 "document.querySelectorAll('iframe')[0])")); | 478 "document.querySelectorAll('iframe')[0])")); |
473 ASSERT_EQ(1U, root->child_count()); | 479 ASSERT_EQ(1U, root->child_count()); |
474 | 480 |
475 // Load a new same-site page in the top-level frame and ensure the other | 481 // Load a new same-site page in the top-level frame and ensure the other |
476 // subframe goes away. | 482 // subframe goes away. |
477 GURL new_url(embedded_test_server()->GetURL("/title1.html")); | 483 GURL new_url(embedded_test_server()->GetURL("/title1.html")); |
478 NavigateToURL(shell(), new_url); | 484 NavigateToURL(shell(), new_url); |
479 ASSERT_EQ(0U, root->child_count()); | 485 ASSERT_EQ(0U, root->child_count()); |
| 486 |
| 487 // Ensure the RVH for the subframe gets cleaned up when the frame goes away. |
| 488 EXPECT_FALSE(RenderViewHost::FromID(subframe_process_id, subframe_rvh_id)); |
480 } | 489 } |
481 | 490 |
482 // Ensure that root frames cannot be detached. | 491 // Ensure that root frames cannot be detached. |
483 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { | 492 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { |
484 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 493 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
485 NavigateToURL(shell(), main_url); | 494 NavigateToURL(shell(), main_url); |
486 | 495 |
487 // It is safe to obtain the root frame tree node here, as it doesn't change. | 496 // It is safe to obtain the root frame tree node here, as it doesn't change. |
488 FrameTreeNode* root = | 497 FrameTreeNode* root = |
489 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 498 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
(...skipping 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2459 " |--Site A\n" | 2468 " |--Site A\n" |
2460 " +--Site A\n" | 2469 " +--Site A\n" |
2461 " |--Site A\n" | 2470 " |--Site A\n" |
2462 " +--Site A\n" | 2471 " +--Site A\n" |
2463 " +--Site A\n" | 2472 " +--Site A\n" |
2464 "Where A = http://127.0.0.1/", | 2473 "Where A = http://127.0.0.1/", |
2465 DepictFrameTree(root)); | 2474 DepictFrameTree(root)); |
2466 } | 2475 } |
2467 | 2476 |
2468 } // namespace content | 2477 } // namespace content |
OLD | NEW |