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/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ASSERT_EQ(1U, root->child_count()); | 251 ASSERT_EQ(1U, root->child_count()); |
252 FrameTreeNode* child = root->child_at(0); | 252 FrameTreeNode* child = root->child_at(0); |
253 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 253 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
254 child->current_frame_host()->render_view_host()); | 254 child->current_frame_host()->render_view_host()); |
255 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 255 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
256 child->current_frame_host()->render_view_host()->GetSiteInstance()); | 256 child->current_frame_host()->render_view_host()->GetSiteInstance()); |
257 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), | 257 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
258 child->current_frame_host()->GetProcess()); | 258 child->current_frame_host()->GetProcess()); |
259 } | 259 } |
260 | 260 |
| 261 // Crash a subframe and ensures its children are cleared from the FrameTree. |
| 262 // See http://crbug.com/338508. |
| 263 // TODO(creis): Enable this on Android when we can kill the process there. |
| 264 #if defined(OS_ANDROID) |
| 265 #define MAYBE_CrashSubframe DISABLED_CrashSubframe |
| 266 #else |
| 267 #define MAYBE_CrashSubframe CrashSubframe |
| 268 #endif |
| 269 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CrashSubframe) { |
| 270 host_resolver()->AddRule("*", "127.0.0.1"); |
| 271 ASSERT_TRUE(test_server()->Start()); |
| 272 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
| 273 NavigateToURL(shell(), main_url); |
| 274 |
| 275 StartFrameAtDataURL(); |
| 276 |
| 277 // These must stay in scope with replace_host. |
| 278 GURL::Replacements replace_host; |
| 279 std::string foo_com("foo.com"); |
| 280 |
| 281 // Load cross-site page into iframe. |
| 282 GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
| 283 replace_host.SetHostStr(foo_com); |
| 284 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
| 285 EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); |
| 286 |
| 287 // Check the subframe process. |
| 288 FrameTreeNode* root = |
| 289 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 290 GetFrameTree()->root(); |
| 291 ASSERT_EQ(1U, root->child_count()); |
| 292 FrameTreeNode* child = root->child_at(0); |
| 293 EXPECT_NE(FrameTreeNode::kInvalidFrameId, root->frame_id()); |
| 294 EXPECT_NE(FrameTreeNode::kInvalidFrameId, root->child_at(0)->frame_id()); |
| 295 |
| 296 // Crash the subframe process. |
| 297 RenderProcessHost* root_process = root->current_frame_host()->GetProcess(); |
| 298 RenderProcessHost* child_process = child->current_frame_host()->GetProcess(); |
| 299 { |
| 300 RenderProcessHostWatcher crash_observer( |
| 301 child_process, |
| 302 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 303 base::KillProcess(child_process->GetHandle(), 0, false); |
| 304 crash_observer.Wait(); |
| 305 } |
| 306 |
| 307 // Ensure that the child frame still exists but has been cleared. |
| 308 EXPECT_EQ(1U, root->child_count()); |
| 309 EXPECT_EQ(FrameTreeNode::kInvalidFrameId, root->child_at(0)->frame_id()); |
| 310 |
| 311 // Now crash the top-level page to clear the child frame. |
| 312 { |
| 313 RenderProcessHostWatcher crash_observer( |
| 314 root_process, |
| 315 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 316 base::KillProcess(root_process->GetHandle(), 0, false); |
| 317 crash_observer.Wait(); |
| 318 } |
| 319 EXPECT_EQ(0U, root->child_count()); |
| 320 EXPECT_EQ(FrameTreeNode::kInvalidFrameId, root->frame_id()); |
| 321 } |
| 322 |
261 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 323 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
262 // security checks are back in place. | 324 // security checks are back in place. |
263 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run | 325 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run |
264 // on Android (http://crbug.com/187570). | 326 // on Android (http://crbug.com/187570). |
265 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 327 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
266 DISABLED_CrossSiteIframeRedirectOnce) { | 328 DISABLED_CrossSiteIframeRedirectOnce) { |
267 ASSERT_TRUE(test_server()->Start()); | 329 ASSERT_TRUE(test_server()->Start()); |
268 net::SpawnedTestServer https_server( | 330 net::SpawnedTestServer https_server( |
269 net::SpawnedTestServer::TYPE_HTTPS, | 331 net::SpawnedTestServer::TYPE_HTTPS, |
270 net::SpawnedTestServer::kLocalhost, | 332 net::SpawnedTestServer::kLocalhost, |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 // There should be two history entries. url2b should have replaced url1. url2b | 680 // There should be two history entries. url2b should have replaced url1. url2b |
619 // should not have replaced url3b. | 681 // should not have replaced url3b. |
620 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | 682 EXPECT_TRUE(controller.GetPendingEntry() == NULL); |
621 EXPECT_EQ(2, controller.GetEntryCount()); | 683 EXPECT_EQ(2, controller.GetEntryCount()); |
622 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 684 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
623 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); | 685 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); |
624 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); | 686 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); |
625 } | 687 } |
626 | 688 |
627 } // namespace content | 689 } // namespace content |
OLD | NEW |