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 | |
323 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 261 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
324 // security checks are back in place. | 262 // security checks are back in place. |
325 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run | 263 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run |
326 // on Android (http://crbug.com/187570). | 264 // on Android (http://crbug.com/187570). |
327 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 265 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
328 DISABLED_CrossSiteIframeRedirectOnce) { | 266 DISABLED_CrossSiteIframeRedirectOnce) { |
329 ASSERT_TRUE(test_server()->Start()); | 267 ASSERT_TRUE(test_server()->Start()); |
330 net::SpawnedTestServer https_server( | 268 net::SpawnedTestServer https_server( |
331 net::SpawnedTestServer::TYPE_HTTPS, | 269 net::SpawnedTestServer::TYPE_HTTPS, |
332 net::SpawnedTestServer::kLocalhost, | 270 net::SpawnedTestServer::kLocalhost, |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 // There should be two history entries. url2b should have replaced url1. url2b | 618 // There should be two history entries. url2b should have replaced url1. url2b |
681 // should not have replaced url3b. | 619 // should not have replaced url3b. |
682 EXPECT_TRUE(controller.GetPendingEntry() == NULL); | 620 EXPECT_TRUE(controller.GetPendingEntry() == NULL); |
683 EXPECT_EQ(2, controller.GetEntryCount()); | 621 EXPECT_EQ(2, controller.GetEntryCount()); |
684 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); | 622 EXPECT_EQ(1, controller.GetCurrentEntryIndex()); |
685 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); | 623 EXPECT_EQ(url2b, controller.GetEntryAtIndex(0)->GetURL()); |
686 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); | 624 EXPECT_EQ(url3b, controller.GetEntryAtIndex(1)->GetURL()); |
687 } | 625 } |
688 | 626 |
689 } // namespace content | 627 } // namespace content |
OLD | NEW |