| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 2750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2761 | 2761 |
| 2762 // Simulate a ctrl click on the link. This won't actually create a new Shell | 2762 // Simulate a ctrl click on the link. This won't actually create a new Shell |
| 2763 // because Shell::OpenURLFromTab only supports CURRENT_TAB, but it's enough to | 2763 // because Shell::OpenURLFromTab only supports CURRENT_TAB, but it's enough to |
| 2764 // trigger the crash from https://crbug.com/605055. | 2764 // trigger the crash from https://crbug.com/605055. |
| 2765 EXPECT_TRUE(ExecuteScript( | 2765 EXPECT_TRUE(ExecuteScript( |
| 2766 shell(), "window.domAutomationController.send(ctrlClickLink());")); | 2766 shell(), "window.domAutomationController.send(ctrlClickLink());")); |
| 2767 } | 2767 } |
| 2768 | 2768 |
| 2769 // Ensure that we don't update the wrong NavigationEntry's title after an | 2769 // Ensure that we don't update the wrong NavigationEntry's title after an |
| 2770 // ignored commit during a cross-process navigation. | 2770 // ignored commit during a cross-process navigation. |
| 2771 // See https://crbug.con/577449. | 2771 // See https://crbug.com/577449. |
| 2772 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 2772 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 2773 UnloadPushStateOnCrossProcessNavigation) { | 2773 UnloadPushStateOnCrossProcessNavigation) { |
| 2774 StartEmbeddedServer(); | 2774 StartEmbeddedServer(); |
| 2775 WebContentsImpl* web_contents = | 2775 WebContentsImpl* web_contents = |
| 2776 static_cast<WebContentsImpl*>(shell()->web_contents()); | 2776 static_cast<WebContentsImpl*>(shell()->web_contents()); |
| 2777 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | 2777 FrameTreeNode* root = web_contents->GetFrameTree()->root(); |
| 2778 | 2778 |
| 2779 // Give an initial page an unload handler that does a pushState, which will be | 2779 // Give an initial page an unload handler that does a pushState, which will be |
| 2780 // ignored by the browser process. It then does a title update which is | 2780 // ignored by the browser process. It then does a title update which is |
| 2781 // meant for a NavigationEntry that will never be created. | 2781 // meant for a NavigationEntry that will never be created. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2828 | 2828 |
| 2829 GURL file_url = GetTestUrl("", "title1.html"); | 2829 GURL file_url = GetTestUrl("", "title1.html"); |
| 2830 ASSERT_TRUE(NavigateToURL(shell(), file_url)); | 2830 ASSERT_TRUE(NavigateToURL(shell(), file_url)); |
| 2831 EXPECT_EQ(1, web_contents->GetController().GetEntryCount()); | 2831 EXPECT_EQ(1, web_contents->GetController().GetEntryCount()); |
| 2832 EXPECT_TRUE(ExecuteScript( | 2832 EXPECT_TRUE(ExecuteScript( |
| 2833 root, "window.history.pushState({}, '', 'https://chromium.org');")); | 2833 root, "window.history.pushState({}, '', 'https://chromium.org');")); |
| 2834 EXPECT_EQ(2, web_contents->GetController().GetEntryCount()); | 2834 EXPECT_EQ(2, web_contents->GetController().GetEntryCount()); |
| 2835 EXPECT_TRUE(web_contents->GetMainFrame()->IsRenderFrameLive()); | 2835 EXPECT_TRUE(web_contents->GetMainFrame()->IsRenderFrameLive()); |
| 2836 } | 2836 } |
| 2837 | 2837 |
| 2838 // Ensure that navigating back from a sad tab to an existing process works |
| 2839 // correctly. See https://crbug.com/591984. |
| 2840 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 2841 NavigateBackToExistingProcessFromSadTab) { |
| 2842 StartEmbeddedServer(); |
| 2843 EXPECT_TRUE(NavigateToURL( |
| 2844 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); |
| 2845 |
| 2846 // Open a popup and navigate it to b.com. |
| 2847 Shell* popup = OpenPopup( |
| 2848 shell(), embedded_test_server()->GetURL("a.com", "/title2.html"), "foo"); |
| 2849 EXPECT_TRUE(NavigateToURL( |
| 2850 popup, embedded_test_server()->GetURL("b.com", "/title3.html"))); |
| 2851 |
| 2852 // Kill the b.com process. |
| 2853 RenderProcessHost* b_process = |
| 2854 popup->web_contents()->GetMainFrame()->GetProcess(); |
| 2855 RenderProcessHostWatcher crash_observer( |
| 2856 b_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 2857 b_process->Shutdown(0, false); |
| 2858 crash_observer.Wait(); |
| 2859 |
| 2860 // The popup should now be showing the sad tab. Main tab should not be. |
| 2861 EXPECT_NE(base::TERMINATION_STATUS_STILL_RUNNING, |
| 2862 popup->web_contents()->GetCrashedStatus()); |
| 2863 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, |
| 2864 shell()->web_contents()->GetCrashedStatus()); |
| 2865 |
| 2866 // Go back in the popup from b.com to a.com/title2.html. |
| 2867 TestNavigationObserver back_observer(popup->web_contents()); |
| 2868 popup->web_contents()->GetController().GoBack(); |
| 2869 back_observer.Wait(); |
| 2870 |
| 2871 // In the bug, after the back navigation the popup was still showing |
| 2872 // the sad tab. Ensure this is not the case. |
| 2873 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, |
| 2874 popup->web_contents()->GetCrashedStatus()); |
| 2875 EXPECT_TRUE(popup->web_contents()->GetMainFrame()->IsRenderFrameLive()); |
| 2876 EXPECT_EQ(popup->web_contents()->GetMainFrame()->GetSiteInstance(), |
| 2877 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); |
| 2878 } |
| 2879 |
| 2838 } // namespace content | 2880 } // namespace content |
| OLD | NEW |