| 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 8694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8705 FrameTreeNode* child = root->child_at(0); | 8705 FrameTreeNode* child = root->child_at(0); |
| 8706 | 8706 |
| 8707 // Set up a postMessage handler in the main frame for later use. | 8707 // Set up a postMessage handler in the main frame for later use. |
| 8708 EXPECT_TRUE(ExecuteScript( | 8708 EXPECT_TRUE(ExecuteScript( |
| 8709 root->current_frame_host(), | 8709 root->current_frame_host(), |
| 8710 "window.addEventListener('message'," | 8710 "window.addEventListener('message'," |
| 8711 " function(e) { document.title = e.data; });")); | 8711 " function(e) { document.title = e.data; });")); |
| 8712 | 8712 |
| 8713 // Crash the subframe process. | 8713 // Crash the subframe process. |
| 8714 RenderProcessHost* child_process = child->current_frame_host()->GetProcess(); | 8714 RenderProcessHost* child_process = child->current_frame_host()->GetProcess(); |
| 8715 LOG(ERROR) << "; child_process->GetHandle() = " << child_process->GetHandle(); |
| 8716 |
| 8717 { |
| 8718 LOG(ERROR) << "Sleeping 10 seconds"; |
| 8719 scoped_refptr<MessageLoopRunner> runner(new MessageLoopRunner()); |
| 8720 base::SequencedTaskRunnerHandle::Get()->PostDelayedTask( |
| 8721 FROM_HERE, runner->QuitClosure(), base::TimeDelta::FromSeconds(10)); |
| 8722 runner->Run(); |
| 8723 } |
| 8724 |
| 8715 RenderProcessHostWatcher crash_observer( | 8725 RenderProcessHostWatcher crash_observer( |
| 8716 child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 8726 child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 8717 child_process->Shutdown(0, false); | 8727 child_process->Shutdown(0, false); |
| 8718 crash_observer.Wait(); | 8728 crash_observer.Wait(); |
| 8719 EXPECT_FALSE(child->current_frame_host()->IsRenderFrameLive()); | 8729 EXPECT_FALSE(child->current_frame_host()->IsRenderFrameLive()); |
| 8720 | 8730 |
| 8731 { |
| 8732 LOG(ERROR) << "Sleeping 10 seconds"; |
| 8733 scoped_refptr<MessageLoopRunner> runner(new MessageLoopRunner()); |
| 8734 base::SequencedTaskRunnerHandle::Get()->PostDelayedTask( |
| 8735 FROM_HERE, runner->QuitClosure(), base::TimeDelta::FromSeconds(10)); |
| 8736 runner->Run(); |
| 8737 } |
| 8738 |
| 8721 // When the subframe dies, its RenderWidgetHostView should be cleared and | 8739 // When the subframe dies, its RenderWidgetHostView should be cleared and |
| 8722 // reset in the CrossProcessFrameConnector. | 8740 // reset in the CrossProcessFrameConnector. |
| 8723 EXPECT_FALSE(child->current_frame_host()->GetView()); | 8741 EXPECT_FALSE(child->current_frame_host()->GetView()); |
| 8724 RenderFrameProxyHost* proxy_to_parent = | 8742 RenderFrameProxyHost* proxy_to_parent = |
| 8725 child->render_manager()->GetProxyToParent(); | 8743 child->render_manager()->GetProxyToParent(); |
| 8726 EXPECT_FALSE( | 8744 EXPECT_FALSE( |
| 8727 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | 8745 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
| 8728 | 8746 |
| 8729 // Navigate the subframe to the same site it was on before crashing. This | 8747 // Navigate the subframe to the same site it was on before crashing. This |
| 8730 // should reuse the subframe's current RenderFrameHost and reinitialize the | 8748 // should reuse the subframe's current RenderFrameHost and reinitialize the |
| 8731 // RenderFrame in a new process. | 8749 // RenderFrame in a new process. |
| 8732 NavigateFrameToURL(child, | 8750 TestFrameNavigationObserver child_navigation_observer(child); |
| 8733 embedded_test_server()->GetURL("b.com", "/title1.html")); | 8751 EXPECT_TRUE( |
| 8752 ExecuteScript(root->current_frame_host(), |
| 8753 "var f = document.getElementsByTagName('iframe')[0];\n" |
| 8754 "f.src = f.src\n")); |
| 8755 child_navigation_observer.Wait(); |
| 8734 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive()); | 8756 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive()); |
| 8735 | 8757 |
| 8736 // The RenderWidgetHostView for the child should be recreated and set to be | 8758 // The RenderWidgetHostView for the child should be recreated and set to be |
| 8737 // used in the CrossProcessFrameConnector. Without this, the frame won't be | 8759 // used in the CrossProcessFrameConnector. Without this, the frame won't be |
| 8738 // rendered properly. | 8760 // rendered properly. |
| 8739 EXPECT_TRUE(child->current_frame_host()->GetView()); | 8761 EXPECT_TRUE(child->current_frame_host()->GetView()); |
| 8740 EXPECT_EQ( | 8762 EXPECT_EQ( |
| 8741 child->current_frame_host()->GetView(), | 8763 child->current_frame_host()->GetView(), |
| 8742 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | 8764 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
| 8743 | 8765 |
| 8744 // Send a postMessage from the child to its parent. This verifies that the | 8766 // Send a postMessage from the child to its parent. This verifies that the |
| 8745 // parent's proxy in the child's SiteInstance was also restored. | 8767 // parent's proxy in the child's SiteInstance was also restored. |
| 8746 base::string16 expected_title(base::UTF8ToUTF16("I am alive!")); | 8768 base::string16 expected_title(base::UTF8ToUTF16("I am alive!")); |
| 8747 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | 8769 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 8748 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), | 8770 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), |
| 8749 "parent.postMessage('I am alive!', '*');")); | 8771 "parent.postMessage('I am alive!', '*');")); |
| 8750 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 8772 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 8773 |
| 8774 LOG(ERROR) << "Starting message loop for interactive UI..."; |
| 8775 (new content::MessageLoopRunner)->Run(); |
| 8751 } | 8776 } |
| 8752 | 8777 |
| 8753 // Test that session history length and offset are replicated to all renderer | 8778 // Test that session history length and offset are replicated to all renderer |
| 8754 // processes in a FrameTree. This allows each renderer to see correct values | 8779 // processes in a FrameTree. This allows each renderer to see correct values |
| 8755 // for history.length, and to check the offset validity properly for | 8780 // for history.length, and to check the offset validity properly for |
| 8756 // navigations initiated via history.go(). See https:/crbug.com/501116. | 8781 // navigations initiated via history.go(). See https:/crbug.com/501116. |
| 8757 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SessionHistoryReplication) { | 8782 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SessionHistoryReplication) { |
| 8758 GURL main_url(embedded_test_server()->GetURL( | 8783 GURL main_url(embedded_test_server()->GetURL( |
| 8759 "a.com", "/cross_site_iframe_factory.html?a(a,a)")); | 8784 "a.com", "/cross_site_iframe_factory.html?a(a,a)")); |
| 8760 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 8785 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9993 names.insert(root->children[0]->frame_entry->frame_unique_name()); | 10018 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
| 9994 } | 10019 } |
| 9995 | 10020 |
| 9996 // More than one entry in the set means that the subframe frame navigation | 10021 // More than one entry in the set means that the subframe frame navigation |
| 9997 // entries didn't have a consistent unique name. This will break history | 10022 // entries didn't have a consistent unique name. This will break history |
| 9998 // navigations =( | 10023 // navigations =( |
| 9999 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 10024 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
| 10000 } | 10025 } |
| 10001 | 10026 |
| 10002 } // namespace content | 10027 } // namespace content |
| OLD | NEW |