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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 7744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7755 // opener proxies, |rvh| should be reused as a swapped out RVH. In | 7755 // opener proxies, |rvh| should be reused as a swapped out RVH. In |
| 7756 // https://crbug.com/627893, recreating the opener RenderView was hitting a | 7756 // https://crbug.com/627893, recreating the opener RenderView was hitting a |
| 7757 // CHECK(params.swapped_out) in the renderer process, since its | 7757 // CHECK(params.swapped_out) in the renderer process, since its |
| 7758 // RenderViewHost was brought into an active state by the navigation to | 7758 // RenderViewHost was brought into an active state by the navigation to |
| 7759 // |stall_url| above, even though it never committed. | 7759 // |stall_url| above, even though it never committed. |
| 7760 GURL b_url(embedded_test_server()->GetURL("b.com", "/title3.html")); | 7760 GURL b_url(embedded_test_server()->GetURL("b.com", "/title3.html")); |
| 7761 EXPECT_TRUE(NavigateToURL(popup_shell, b_url)); | 7761 EXPECT_TRUE(NavigateToURL(popup_shell, b_url)); |
| 7762 EXPECT_FALSE(rvh->is_active()); | 7762 EXPECT_FALSE(rvh->is_active()); |
| 7763 } | 7763 } |
| 7764 | 7764 |
| 7765 // Test the a crashed subframe can be successfully navigated to the site it was | |
|
Charlie Reis
2016/08/11 18:50:29
nit: s/the/that/
alexmos
2016/08/11 20:45:48
Done.
| |
| 7766 // on before crashing. See https://crbug.com/634368. | |
| 7767 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 7768 NavigateCrashedSubframeToSameSite) { | |
| 7769 GURL main_url(embedded_test_server()->GetURL( | |
| 7770 "a.com", "/cross_site_iframe_factory.html?a(b)")); | |
| 7771 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 7772 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | |
| 7773 FrameTreeNode* child = root->child_at(0); | |
| 7774 | |
| 7775 // Set up a postMessage handler in the main frame for later use. | |
| 7776 EXPECT_TRUE(ExecuteScript( | |
| 7777 root->current_frame_host(), | |
| 7778 "window.addEventListener('message'," | |
| 7779 " function(e) { document.title = e.data; });")); | |
| 7780 | |
| 7781 // Crash the subframe process. | |
| 7782 RenderProcessHost* child_process = child->current_frame_host()->GetProcess(); | |
| 7783 RenderProcessHostWatcher crash_observer( | |
| 7784 child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | |
| 7785 child_process->Shutdown(0, false); | |
| 7786 crash_observer.Wait(); | |
| 7787 EXPECT_FALSE(child->current_frame_host()->IsRenderFrameLive()); | |
| 7788 | |
| 7789 // When the subframe dies, its RenderWidgetHostView should be cleared and | |
| 7790 // reset in the CrossProcessFrameConnector. | |
| 7791 EXPECT_FALSE(child->current_frame_host()->GetView()); | |
| 7792 RenderFrameProxyHost* proxy_to_parent = | |
| 7793 child->render_manager()->GetProxyToParent(); | |
| 7794 EXPECT_FALSE( | |
| 7795 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | |
| 7796 | |
| 7797 // Navigate the subframe to the same site it was on before crashing. This | |
| 7798 // should reuse the subframe's current RenderFrameHost and reinitialize the | |
| 7799 // RenderFrame in a new process. | |
| 7800 NavigateFrameToURL(child, | |
| 7801 embedded_test_server()->GetURL("b.com", "/title1.html")); | |
| 7802 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive()); | |
| 7803 | |
| 7804 // The RenderWidgetHostView for the child should be recreated and set to be | |
| 7805 // used in the CrossProcessFrameConnector. Without this, the frame won't be | |
| 7806 // rendered properly. | |
| 7807 EXPECT_TRUE(child->current_frame_host()->GetView()); | |
| 7808 EXPECT_EQ( | |
| 7809 child->current_frame_host()->GetView(), | |
| 7810 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | |
| 7811 | |
| 7812 // Send a postMessage from the child to its parent. This verifies that the | |
| 7813 // parent's proxy in the child's SiteInstance was also restored. | |
| 7814 base::string16 expected_title(base::UTF8ToUTF16("I am alive!")); | |
| 7815 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | |
| 7816 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), | |
| 7817 "parent.postMessage('I am alive!', '*');")); | |
| 7818 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
| 7819 } | |
| 7820 | |
| 7765 } // namespace content | 7821 } // namespace content |
| OLD | NEW |