| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 8 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1203 EXPECT_TRUE(contents()->cross_navigation_pending()); |
| 1204 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | 1204 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); |
| 1205 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | 1205 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); |
| 1206 | 1206 |
| 1207 // The pending navigation should be able to commit successfully. | 1207 // The pending navigation should be able to commit successfully. |
| 1208 contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); | 1208 contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); |
| 1209 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1209 EXPECT_FALSE(contents()->cross_navigation_pending()); |
| 1210 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); | 1210 EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 // Test that a cross-site navigation that doesn't commit after the unload | |
| 1214 // handler doesn't leave the contents in a stuck state. http://crbug.com/88562 | |
| 1215 TEST_F(WebContentsImplTest, CrossSiteNavigationCanceled) { | |
| 1216 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | |
| 1217 SiteInstance* instance1 = contents()->GetSiteInstance(); | |
| 1218 | |
| 1219 // Navigate to URL. First URL should use original RenderFrameHost. | |
| 1220 const GURL url("http://www.google.com"); | |
| 1221 controller().LoadURL( | |
| 1222 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
| 1223 contents()->GetMainFrame()->PrepareForCommit(); | |
| 1224 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); | |
| 1225 EXPECT_FALSE(contents()->cross_navigation_pending()); | |
| 1226 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | |
| 1227 | |
| 1228 // Navigate to new site, simulating an onbeforeunload approval. | |
| 1229 const GURL url2("http://www.yahoo.com"); | |
| 1230 controller().LoadURL( | |
| 1231 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
| 1232 EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); | |
| 1233 contents()->GetMainFrame()->PrepareForCommit(); | |
| 1234 EXPECT_TRUE(contents()->cross_navigation_pending()); | |
| 1235 | |
| 1236 // Simulate swap out message when the response arrives. | |
| 1237 orig_rfh->OnSwappedOut(); | |
| 1238 | |
| 1239 // Suppose the navigation doesn't get a chance to commit, and the user | |
| 1240 // navigates in the current RFH's SiteInstance. | |
| 1241 controller().LoadURL( | |
| 1242 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | |
| 1243 | |
| 1244 // Verify that the pending navigation is cancelled and the renderer is no | |
| 1245 // longer swapped out. | |
| 1246 EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); | |
| 1247 SiteInstance* instance2 = contents()->GetSiteInstance(); | |
| 1248 EXPECT_FALSE(contents()->cross_navigation_pending()); | |
| 1249 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); | |
| 1250 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, orig_rfh->rfh_state()); | |
| 1251 EXPECT_EQ(instance1, instance2); | |
| 1252 EXPECT_EQ(nullptr, contents()->GetPendingMainFrame()); | |
| 1253 } | |
| 1254 | |
| 1255 // Test that NavigationEntries have the correct page state after going | 1213 // Test that NavigationEntries have the correct page state after going |
| 1256 // forward and back. Prevents regression for bug 1116137. | 1214 // forward and back. Prevents regression for bug 1116137. |
| 1257 TEST_F(WebContentsImplTest, NavigationEntryContentState) { | 1215 TEST_F(WebContentsImplTest, NavigationEntryContentState) { |
| 1258 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); | 1216 TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); |
| 1259 | 1217 |
| 1260 // Navigate to URL. There should be no committed entry yet. | 1218 // Navigate to URL. There should be no committed entry yet. |
| 1261 const GURL url("http://www.google.com"); | 1219 const GURL url("http://www.google.com"); |
| 1262 controller().LoadURL( | 1220 controller().LoadURL( |
| 1263 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 1221 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 1264 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 1222 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 contents()->GetMainFrame()->OnMessageReceived( | 3014 contents()->GetMainFrame()->OnMessageReceived( |
| 3057 FrameHostMsg_RenderProcessGone( | 3015 FrameHostMsg_RenderProcessGone( |
| 3058 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 3016 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
| 3059 | 3017 |
| 3060 // Verify that all the power save blockers have been released. | 3018 // Verify that all the power save blockers have been released. |
| 3061 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3019 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
| 3062 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3020 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
| 3063 } | 3021 } |
| 3064 | 3022 |
| 3065 } // namespace content | 3023 } // namespace content |
| OLD | NEW |