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