Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
| 9 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 9 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 replace_host.SetHostStr(foo_com); | 476 replace_host.SetHostStr(foo_com); |
| 477 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | 477 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
| 478 EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); | 478 EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); |
| 479 | 479 |
| 480 // Check the subframe process. | 480 // Check the subframe process. |
| 481 FrameTreeNode* root = | 481 FrameTreeNode* root = |
| 482 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 482 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 483 GetFrameTree()->root(); | 483 GetFrameTree()->root(); |
| 484 ASSERT_EQ(1U, root->child_count()); | 484 ASSERT_EQ(1U, root->child_count()); |
| 485 FrameTreeNode* child = root->child_at(0); | 485 FrameTreeNode* child = root->child_at(0); |
| 486 EXPECT_NE(FrameTreeNode::kInvalidFrameId, root->frame_id()); | 486 EXPECT_EQ(main_url, root->current_url()); |
| 487 EXPECT_NE(FrameTreeNode::kInvalidFrameId, root->child_at(0)->frame_id()); | 487 EXPECT_EQ(cross_site_url, child->current_url()); |
| 488 | 488 |
| 489 // Crash the subframe process. | 489 // Crash the subframe process. |
| 490 RenderProcessHost* root_process = root->current_frame_host()->GetProcess(); | 490 RenderProcessHost* root_process = root->current_frame_host()->GetProcess(); |
| 491 RenderProcessHost* child_process = child->current_frame_host()->GetProcess(); | 491 RenderProcessHost* child_process = child->current_frame_host()->GetProcess(); |
| 492 { | 492 { |
| 493 RenderProcessHostWatcher crash_observer( | 493 RenderProcessHostWatcher crash_observer( |
| 494 child_process, | 494 child_process, |
| 495 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 495 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 496 base::KillProcess(child_process->GetHandle(), 0, false); | 496 base::KillProcess(child_process->GetHandle(), 0, false); |
| 497 crash_observer.Wait(); | 497 crash_observer.Wait(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 // Ensure that the child frame still exists but has been cleared. | 500 // Ensure that the child frame still exists but has been cleared. |
| 501 // TODO(creis): Can we check something else, like the URL? | |
|
awong
2014/02/20 00:25:30
This is confusing since the code below is actually
Charlie Reis
2014/02/20 00:43:53
Oops! I was fixing my own TODO from patch set 1 a
| |
| 501 EXPECT_EQ(1U, root->child_count()); | 502 EXPECT_EQ(1U, root->child_count()); |
| 502 EXPECT_EQ(FrameTreeNode::kInvalidFrameId, root->child_at(0)->frame_id()); | 503 EXPECT_EQ(main_url, root->current_url()); |
| 504 EXPECT_EQ(GURL(), child->current_url()); | |
| 503 | 505 |
| 504 // Now crash the top-level page to clear the child frame. | 506 // Now crash the top-level page to clear the child frame. |
| 505 { | 507 { |
| 506 RenderProcessHostWatcher crash_observer( | 508 RenderProcessHostWatcher crash_observer( |
| 507 root_process, | 509 root_process, |
| 508 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 510 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 509 base::KillProcess(root_process->GetHandle(), 0, false); | 511 base::KillProcess(root_process->GetHandle(), 0, false); |
| 510 crash_observer.Wait(); | 512 crash_observer.Wait(); |
| 511 } | 513 } |
| 512 EXPECT_EQ(0U, root->child_count()); | 514 EXPECT_EQ(0U, root->child_count()); |
| 513 EXPECT_EQ(FrameTreeNode::kInvalidFrameId, root->frame_id()); | 515 EXPECT_EQ(GURL(), root->current_url()); |
| 514 } | 516 } |
| 515 | 517 |
| 516 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 518 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
| 517 // security checks are back in place. | 519 // security checks are back in place. |
| 518 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run | 520 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run |
| 519 // on Android (http://crbug.com/187570). | 521 // on Android (http://crbug.com/187570). |
| 520 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 522 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 521 DISABLED_CrossSiteIframeRedirectOnce) { | 523 DISABLED_CrossSiteIframeRedirectOnce) { |
| 522 ASSERT_TRUE(test_server()->Start()); | 524 ASSERT_TRUE(test_server()->Start()); |
| 523 net::SpawnedTestServer https_server( | 525 net::SpawnedTestServer https_server( |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 936 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
| 935 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); | 937 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); |
| 936 | 938 |
| 937 // Make sure the request for url2 did not complete. | 939 // Make sure the request for url2 did not complete. |
| 938 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); | 940 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); |
| 939 | 941 |
| 940 shell()->web_contents()->SetDelegate(old_delegate); | 942 shell()->web_contents()->SetDelegate(old_delegate); |
| 941 } | 943 } |
| 942 | 944 |
| 943 } // namespace content | 945 } // namespace content |
| OLD | NEW |