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 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1419 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1420 | 1420 |
1421 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1421 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1422 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1422 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1423 ->GetFrameTree() | 1423 ->GetFrameTree() |
1424 ->root(); | 1424 ->root(); |
1425 | 1425 |
1426 TestNavigationObserver observer(shell()->web_contents()); | 1426 TestNavigationObserver observer(shell()->web_contents()); |
1427 | 1427 |
1428 // Navigate the first subframe to a cross-site page with two subframes. | 1428 // Navigate the first subframe to a cross-site page with two subframes. |
1429 // NavigateFrameToURL can't be used here because it doesn't guarantee that | |
1430 // FrameTreeNodes will have been created for child frames when it returns. | |
1431 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4); | |
1432 GURL foo_url( | 1429 GURL foo_url( |
1433 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); | 1430 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); |
1434 NavigationController::LoadURLParams params(foo_url); | 1431 NavigateFrameToURL(root->child_at(0), foo_url); |
1435 params.transition_type = ui::PAGE_TRANSITION_LINK; | 1432 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
1436 params.frame_tree_node_id = root->child_at(0)->frame_tree_node_id(); | |
1437 root->child_at(0)->navigator()->GetController()->LoadURLWithParams(params); | |
1438 frame_observer.Wait(); | |
1439 | 1433 |
1440 // We can't use a TestNavigationObserver to verify the URL here, | 1434 // We can't use a TestNavigationObserver to verify the URL here, |
1441 // since the frame has children that may have clobbered it in the observer. | 1435 // since the frame has children that may have clobbered it in the observer. |
1442 EXPECT_EQ(foo_url, root->child_at(0)->current_url()); | 1436 EXPECT_EQ(foo_url, root->child_at(0)->current_url()); |
1443 | 1437 |
1444 // Ensure that a new process is created for the subframe. | 1438 // Ensure that a new process is created for the subframe. |
1445 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 1439 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
1446 root->child_at(0)->current_frame_host()->GetSiteInstance()); | 1440 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
1447 | 1441 |
1448 // Load cross-site page into subframe's subframe. | 1442 // Load cross-site page into subframe's subframe. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1499 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1506 | 1500 |
1507 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1501 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1508 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1502 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
1509 ->GetFrameTree() | 1503 ->GetFrameTree() |
1510 ->root(); | 1504 ->root(); |
1511 | 1505 |
1512 TestNavigationObserver observer(shell()->web_contents()); | 1506 TestNavigationObserver observer(shell()->web_contents()); |
1513 | 1507 |
1514 // Navigate the second (sandboxed) subframe to a cross-site page with a | 1508 // Navigate the second (sandboxed) subframe to a cross-site page with a |
1515 // subframe. Use RenderFrameHostCreatedObserver to guarantee that all | 1509 // subframe. |
1516 // FrameTreeNodes are created for child frames. | |
1517 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4); | |
1518 GURL foo_url( | 1510 GURL foo_url( |
1519 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); | 1511 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); |
1520 NavigateFrameToURL(root->child_at(1), foo_url); | 1512 NavigateFrameToURL(root->child_at(1), foo_url); |
1521 frame_observer.Wait(); | 1513 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
1522 | 1514 |
1523 // We can't use a TestNavigationObserver to verify the URL here, | 1515 // We can't use a TestNavigationObserver to verify the URL here, |
1524 // since the frame has children that may have clobbered it in the observer. | 1516 // since the frame has children that may have clobbered it in the observer. |
1525 EXPECT_EQ(foo_url, root->child_at(1)->current_url()); | 1517 EXPECT_EQ(foo_url, root->child_at(1)->current_url()); |
1526 | 1518 |
1527 // Load cross-site page into subframe's subframe. | 1519 // Load cross-site page into subframe's subframe. |
1528 ASSERT_EQ(2U, root->child_at(1)->child_count()); | 1520 ASSERT_EQ(2U, root->child_at(1)->child_count()); |
1529 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html")); | 1521 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html")); |
1530 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url); | 1522 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url); |
1531 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1523 EXPECT_TRUE(observer.last_navigation_succeeded()); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 " |--Site A\n" | 2381 " |--Site A\n" |
2390 " +--Site A\n" | 2382 " +--Site A\n" |
2391 " |--Site A\n" | 2383 " |--Site A\n" |
2392 " +--Site A\n" | 2384 " +--Site A\n" |
2393 " +--Site A\n" | 2385 " +--Site A\n" |
2394 "Where A = http://127.0.0.1/", | 2386 "Where A = http://127.0.0.1/", |
2395 DepictFrameTree(root)); | 2387 DepictFrameTree(root)); |
2396 } | 2388 } |
2397 | 2389 |
2398 } // namespace content | 2390 } // namespace content |
OLD | NEW |