| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/frame_host/cross_site_transferring_request.h" | 10 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 contents()->NavigateAndCommit(kUrl1); | 1147 contents()->NavigateAndCommit(kUrl1); |
| 1148 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1148 TestRenderFrameHost* rfh1 = main_test_rfh(); |
| 1149 | 1149 |
| 1150 // Keep active_frame_count nonzero so that no swapped out frames in | 1150 // Keep active_frame_count nonzero so that no swapped out frames in |
| 1151 // this SiteInstance get forcefully deleted. | 1151 // this SiteInstance get forcefully deleted. |
| 1152 rfh1->GetSiteInstance()->increment_active_frame_count(); | 1152 rfh1->GetSiteInstance()->increment_active_frame_count(); |
| 1153 | 1153 |
| 1154 contents()->NavigateAndCommit(kUrl2); | 1154 contents()->NavigateAndCommit(kUrl2); |
| 1155 TestRenderFrameHost* rfh2 = main_test_rfh(); | 1155 TestRenderFrameHost* rfh2 = main_test_rfh(); |
| 1156 rfh2->GetSiteInstance()->increment_active_frame_count(); | 1156 rfh2->GetSiteInstance()->increment_active_frame_count(); |
| 1157 rfh2->SendBeforeUnloadHandlersPresent(true); |
| 1157 | 1158 |
| 1158 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't | 1159 // Now go back, but suppose the SwapOut_ACK isn't received. This shouldn't |
| 1159 // happen, but we have seen it when going back quickly across many entries | 1160 // happen, but we have seen it when going back quickly across many entries |
| 1160 // (http://crbug.com/93427). | 1161 // (http://crbug.com/93427). |
| 1161 contents()->GetController().GoBack(); | 1162 contents()->GetController().GoBack(); |
| 1162 EXPECT_TRUE(rfh2->IsWaitingForBeforeUnloadACK()); | 1163 EXPECT_TRUE(rfh2->IsWaitingForBeforeUnloadACK()); |
| 1163 contents()->GetMainFrame()->PrepareForCommit(kUrl1); | 1164 contents()->GetMainFrame()->PrepareForCommit(kUrl1); |
| 1164 EXPECT_FALSE(rfh2->IsWaitingForBeforeUnloadACK()); | 1165 EXPECT_FALSE(rfh2->IsWaitingForBeforeUnloadACK()); |
| 1165 | 1166 |
| 1166 // The back navigation commits. | 1167 // The back navigation commits. |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 const GURL kUrl1("http://www.google.com/"); | 1788 const GURL kUrl1("http://www.google.com/"); |
| 1788 const GURL kUrl2("http://www.chromium.org/"); | 1789 const GURL kUrl2("http://www.chromium.org/"); |
| 1789 RenderFrameHostImpl* pending_rfh = NULL; | 1790 RenderFrameHostImpl* pending_rfh = NULL; |
| 1790 base::TimeTicks now = base::TimeTicks::Now(); | 1791 base::TimeTicks now = base::TimeTicks::Now(); |
| 1791 | 1792 |
| 1792 // Navigate to the first page. | 1793 // Navigate to the first page. |
| 1793 contents()->NavigateAndCommit(kUrl1); | 1794 contents()->NavigateAndCommit(kUrl1); |
| 1794 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1795 TestRenderFrameHost* rfh1 = main_test_rfh(); |
| 1795 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1796 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 1796 | 1797 |
| 1798 // Register a BeforeUnload handler. |
| 1799 rfh1->SendBeforeUnloadHandlersPresent(true); |
| 1800 |
| 1797 // Navigate to a new site, starting a cross-site navigation. | 1801 // Navigate to a new site, starting a cross-site navigation. |
| 1798 controller().LoadURL( | 1802 controller().LoadURL( |
| 1799 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1803 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 1800 { | 1804 { |
| 1801 pending_rfh = contents()->GetFrameTree()->root()->render_manager() | 1805 pending_rfh = contents()->GetFrameTree()->root()->render_manager() |
| 1802 ->pending_frame_host(); | 1806 ->pending_frame_host(); |
| 1803 RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh); | 1807 RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh); |
| 1804 | 1808 |
| 1805 // Cancel the navigation by simulating a declined beforeunload dialog. | 1809 // Cancel the navigation by simulating a declined beforeunload dialog. |
| 1806 contents()->GetMainFrame()->OnMessageReceived( | 1810 contents()->GetMainFrame()->OnMessageReceived( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 #if 0 | 1911 #if 0 |
| 1908 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. | 1912 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. |
| 1909 // Enable this assert below once the proxies to the subframe are correctly | 1913 // Enable this assert below once the proxies to the subframe are correctly |
| 1910 // cleaned up after detach. http://crbug.com/444955. | 1914 // cleaned up after detach. http://crbug.com/444955. |
| 1911 ASSERT_TRUE(site_instance->HasOneRef()) | 1915 ASSERT_TRUE(site_instance->HasOneRef()) |
| 1912 << "This SiteInstance should be destroyable now."; | 1916 << "This SiteInstance should be destroyable now."; |
| 1913 #endif | 1917 #endif |
| 1914 } | 1918 } |
| 1915 | 1919 |
| 1916 } // namespace content | 1920 } // namespace content |
| OLD | NEW |