| 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 27 matching lines...) Expand all Loading... |
| 38 #include "content/public/browser/web_ui_message_handler.h" | 38 #include "content/public/browser/web_ui_message_handler.h" |
| 39 #include "content/public/common/bindings_policy.h" | 39 #include "content/public/common/bindings_policy.h" |
| 40 #include "content/public/common/browser_side_navigation_policy.h" | 40 #include "content/public/common/browser_side_navigation_policy.h" |
| 41 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
| 42 #include "content/public/common/page_state.h" | 42 #include "content/public/common/page_state.h" |
| 43 #include "content/public/common/url_constants.h" | 43 #include "content/public/common/url_constants.h" |
| 44 #include "content/public/common/web_preferences.h" | 44 #include "content/public/common/web_preferences.h" |
| 45 #include "content/public/test/browser_test_utils.h" | 45 #include "content/public/test/browser_test_utils.h" |
| 46 #include "content/public/test/content_browser_test.h" | 46 #include "content/public/test/content_browser_test.h" |
| 47 #include "content/public/test/content_browser_test_utils.h" | 47 #include "content/public/test/content_browser_test_utils.h" |
| 48 #include "content/public/test/test_frame_navigation_observer.h" |
| 48 #include "content/public/test/test_navigation_observer.h" | 49 #include "content/public/test/test_navigation_observer.h" |
| 49 #include "content/public/test/test_utils.h" | 50 #include "content/public/test/test_utils.h" |
| 50 #include "content/shell/browser/shell.h" | 51 #include "content/shell/browser/shell.h" |
| 51 #include "content/test/content_browser_test_utils_internal.h" | 52 #include "content/test/content_browser_test_utils_internal.h" |
| 52 #include "content/test/test_frame_navigation_observer.h" | |
| 53 #include "net/dns/mock_host_resolver.h" | 53 #include "net/dns/mock_host_resolver.h" |
| 54 #include "net/test/embedded_test_server/embedded_test_server.h" | 54 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 55 #include "net/test/embedded_test_server/request_handler_util.h" | 55 #include "net/test/embedded_test_server/request_handler_util.h" |
| 56 #include "testing/gmock/include/gmock/gmock-matchers.h" | 56 #include "testing/gmock/include/gmock/gmock-matchers.h" |
| 57 | 57 |
| 58 using base::ASCIIToUTF16; | 58 using base::ASCIIToUTF16; |
| 59 | 59 |
| 60 namespace content { | 60 namespace content { |
| 61 | 61 |
| 62 namespace { | 62 namespace { |
| (...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1905 EXPECT_TRUE(handler->IsJavascriptAllowed()); | 1905 EXPECT_TRUE(handler->IsJavascriptAllowed()); |
| 1906 | 1906 |
| 1907 rfh->DisableSwapOutTimerForTesting(); | 1907 rfh->DisableSwapOutTimerForTesting(); |
| 1908 RenderFrameHostDestructionObserver rfh_observer(rfh); | 1908 RenderFrameHostDestructionObserver rfh_observer(rfh); |
| 1909 | 1909 |
| 1910 // Navigate, but wait for commit, not the actual load to finish. | 1910 // Navigate, but wait for commit, not the actual load to finish. |
| 1911 SiteInstanceImpl* web_ui_site_instance = rfh->GetSiteInstance(); | 1911 SiteInstanceImpl* web_ui_site_instance = rfh->GetSiteInstance(); |
| 1912 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1912 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 1913 ->GetFrameTree() | 1913 ->GetFrameTree() |
| 1914 ->root(); | 1914 ->root(); |
| 1915 TestFrameNavigationObserver commit_observer(root); | 1915 TestFrameNavigationObserver commit_observer(root->current_frame_host()); |
| 1916 shell()->LoadURL(GURL(url::kAboutBlankURL)); | 1916 shell()->LoadURL(GURL(url::kAboutBlankURL)); |
| 1917 commit_observer.WaitForCommit(); | 1917 commit_observer.WaitForCommit(); |
| 1918 EXPECT_NE(web_ui_site_instance, shell()->web_contents()->GetSiteInstance()); | 1918 EXPECT_NE(web_ui_site_instance, shell()->web_contents()->GetSiteInstance()); |
| 1919 EXPECT_TRUE( | 1919 EXPECT_TRUE( |
| 1920 root->render_manager()->GetRenderFrameProxyHost(web_ui_site_instance)); | 1920 root->render_manager()->GetRenderFrameProxyHost(web_ui_site_instance)); |
| 1921 | 1921 |
| 1922 // The previous RFH should still be pending deletion, as we wait for either | 1922 // The previous RFH should still be pending deletion, as we wait for either |
| 1923 // the SwapOut ACK or a timeout. | 1923 // the SwapOut ACK or a timeout. |
| 1924 ASSERT_TRUE(rfh->IsRenderFrameLive()); | 1924 ASSERT_TRUE(rfh->IsRenderFrameLive()); |
| 1925 ASSERT_FALSE(rfh->is_active()); | 1925 ASSERT_FALSE(rfh->is_active()); |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 ->GetFrameTree() | 2502 ->GetFrameTree() |
| 2503 ->root(); | 2503 ->root(); |
| 2504 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 2504 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| 2505 new_shell->web_contents()->GetSiteInstance()); | 2505 new_shell->web_contents()->GetSiteInstance()); |
| 2506 | 2506 |
| 2507 // Navigate the first tab to a different site, and only wait for commit, not | 2507 // Navigate the first tab to a different site, and only wait for commit, not |
| 2508 // load stop. | 2508 // load stop. |
| 2509 RenderFrameHostImpl* rfh_a = root->current_frame_host(); | 2509 RenderFrameHostImpl* rfh_a = root->current_frame_host(); |
| 2510 rfh_a->DisableSwapOutTimerForTesting(); | 2510 rfh_a->DisableSwapOutTimerForTesting(); |
| 2511 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); | 2511 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); |
| 2512 TestFrameNavigationObserver commit_observer(root); | 2512 TestFrameNavigationObserver commit_observer(root->current_frame_host()); |
| 2513 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); | 2513 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); |
| 2514 commit_observer.WaitForCommit(); | 2514 commit_observer.WaitForCommit(); |
| 2515 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 2515 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 2516 new_shell->web_contents()->GetSiteInstance()); | 2516 new_shell->web_contents()->GetSiteInstance()); |
| 2517 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); | 2517 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
| 2518 | 2518 |
| 2519 // The previous RFH should still be pending deletion, as we wait for either | 2519 // The previous RFH should still be pending deletion, as we wait for either |
| 2520 // the SwapOut ACK or a timeout. | 2520 // the SwapOut ACK or a timeout. |
| 2521 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); | 2521 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); |
| 2522 ASSERT_FALSE(rfh_a->is_active()); | 2522 ASSERT_FALSE(rfh_a->is_active()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2573 EXPECT_TRUE(NavigateToURL( | 2573 EXPECT_TRUE(NavigateToURL( |
| 2574 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); | 2574 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); |
| 2575 EXPECT_TRUE( | 2575 EXPECT_TRUE( |
| 2576 ExecuteScript(root, "window.onunload=function(e){ while(1); };\n")); | 2576 ExecuteScript(root, "window.onunload=function(e){ while(1); };\n")); |
| 2577 | 2577 |
| 2578 // Navigate the tab to a different site, and only wait for commit, not load | 2578 // Navigate the tab to a different site, and only wait for commit, not load |
| 2579 // stop. | 2579 // stop. |
| 2580 RenderFrameHostImpl* rfh_a = root->current_frame_host(); | 2580 RenderFrameHostImpl* rfh_a = root->current_frame_host(); |
| 2581 rfh_a->DisableSwapOutTimerForTesting(); | 2581 rfh_a->DisableSwapOutTimerForTesting(); |
| 2582 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); | 2582 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); |
| 2583 TestFrameNavigationObserver commit_observer(root); | 2583 TestFrameNavigationObserver commit_observer(root->current_frame_host()); |
| 2584 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); | 2584 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); |
| 2585 commit_observer.WaitForCommit(); | 2585 commit_observer.WaitForCommit(); |
| 2586 EXPECT_NE(site_instance_a, shell()->web_contents()->GetSiteInstance()); | 2586 EXPECT_NE(site_instance_a, shell()->web_contents()->GetSiteInstance()); |
| 2587 | 2587 |
| 2588 // The previous RFH should still be pending deletion, as we wait for either | 2588 // The previous RFH should still be pending deletion, as we wait for either |
| 2589 // the SwapOut ACK or a timeout. | 2589 // the SwapOut ACK or a timeout. |
| 2590 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); | 2590 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); |
| 2591 ASSERT_FALSE(rfh_a->is_active()); | 2591 ASSERT_FALSE(rfh_a->is_active()); |
| 2592 | 2592 |
| 2593 // When the previous RFH was swapped out, it should have still gotten a | 2593 // When the previous RFH was swapped out, it should have still gotten a |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2941 // In the bug, after the back navigation the popup was still showing | 2941 // In the bug, after the back navigation the popup was still showing |
| 2942 // the sad tab. Ensure this is not the case. | 2942 // the sad tab. Ensure this is not the case. |
| 2943 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, | 2943 EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING, |
| 2944 popup->web_contents()->GetCrashedStatus()); | 2944 popup->web_contents()->GetCrashedStatus()); |
| 2945 EXPECT_TRUE(popup->web_contents()->GetMainFrame()->IsRenderFrameLive()); | 2945 EXPECT_TRUE(popup->web_contents()->GetMainFrame()->IsRenderFrameLive()); |
| 2946 EXPECT_EQ(popup->web_contents()->GetMainFrame()->GetSiteInstance(), | 2946 EXPECT_EQ(popup->web_contents()->GetMainFrame()->GetSiteInstance(), |
| 2947 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); | 2947 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); |
| 2948 } | 2948 } |
| 2949 | 2949 |
| 2950 } // namespace content | 2950 } // namespace content |
| OLD | NEW |