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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 // Use an observer to avoid accessing a deleted renderer later on when the | 305 // Use an observer to avoid accessing a deleted renderer later on when the |
306 // state is being checked. | 306 // state is being checked. |
307 RenderFrameHostDeletedObserver rfh_observer(old_rfh); | 307 RenderFrameHostDeletedObserver rfh_observer(old_rfh); |
308 RenderViewHostDeletedObserver rvh_observer(old_rvh); | 308 RenderViewHostDeletedObserver rvh_observer(old_rvh); |
309 active_rfh->SendNavigate(max_page_id + 1, url); | 309 active_rfh->SendNavigate(max_page_id + 1, url); |
310 | 310 |
311 // Make sure that we start to run the unload handler at the time of commit. | 311 // Make sure that we start to run the unload handler at the time of commit. |
312 bool expecting_rfh_shutdown = false; | 312 bool expecting_rfh_shutdown = false; |
313 if (old_rfh != active_rfh && !rfh_observer.deleted()) { | 313 if (old_rfh != active_rfh && !rfh_observer.deleted()) { |
| 314 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, |
| 315 old_rfh->rfh_state()); |
314 if (!old_rfh->GetSiteInstance()->active_frame_count()) { | 316 if (!old_rfh->GetSiteInstance()->active_frame_count()) { |
315 expecting_rfh_shutdown = true; | 317 expecting_rfh_shutdown = true; |
316 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SHUTDOWN, | 318 EXPECT_TRUE( |
317 old_rfh->rfh_state()); | 319 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( |
318 } else { | 320 old_rfh)); |
319 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, | |
320 old_rfh->rfh_state()); | |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 // Simulate the swap out ACK coming from the pending renderer. This should | 324 // Simulate the swap out ACK coming from the pending renderer. This should |
325 // either shut down the old RFH or leave it in a swapped out state. | 325 // either shut down the old RFH or leave it in a swapped out state. |
326 if (old_rfh != active_rfh) { | 326 if (old_rfh != active_rfh) { |
327 old_rfh->OnSwappedOut(); | 327 old_rfh->OnSwappedOut(); |
328 if (expecting_rfh_shutdown) { | 328 if (expecting_rfh_shutdown) { |
329 EXPECT_TRUE(rfh_observer.deleted()); | 329 EXPECT_TRUE(rfh_observer.deleted()); |
330 EXPECT_TRUE(rvh_observer.deleted()); | 330 EXPECT_TRUE(rvh_observer.deleted()); |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 rfh1->OnSwappedOut(); | 1596 rfh1->OnSwappedOut(); |
1597 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1597 EXPECT_TRUE(contents()->cross_navigation_pending()); |
1598 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1598 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
1599 | 1599 |
1600 // The new page commits. | 1600 // The new page commits. |
1601 contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED); | 1601 contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED); |
1602 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1602 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1603 EXPECT_EQ(rfh2, contents()->GetMainFrame()); | 1603 EXPECT_EQ(rfh2, contents()->GetMainFrame()); |
1604 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); | 1604 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); |
1605 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); | 1605 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); |
1606 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SHUTDOWN, rfh1->rfh_state()); | 1606 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); |
| 1607 EXPECT_TRUE( |
| 1608 rfh1->frame_tree_node()->render_manager()->IsPendingDeletion(rfh1)); |
1607 | 1609 |
1608 // Simulate the swap out ack. | 1610 // Simulate the swap out ack. |
1609 rfh1->OnSwappedOut(); | 1611 rfh1->OnSwappedOut(); |
1610 | 1612 |
1611 // rfh1 should have been deleted. | 1613 // rfh1 should have been deleted. |
1612 EXPECT_TRUE(rfh_deleted_observer.deleted()); | 1614 EXPECT_TRUE(rfh_deleted_observer.deleted()); |
1613 rfh1 = NULL; | 1615 rfh1 = NULL; |
1614 } | 1616 } |
1615 | 1617 |
1616 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK | 1618 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1977 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1976 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); | 1978 contents()->GetMainFrame()->SendBeginNavigationWithURL(kUrl); |
1977 // A NavigationRequest should have been generated. | 1979 // A NavigationRequest should have been generated. |
1978 main_request = GetNavigationRequestForRenderFrameManager(render_manager); | 1980 main_request = GetNavigationRequestForRenderFrameManager(render_manager); |
1979 ASSERT_TRUE(main_request != NULL); | 1981 ASSERT_TRUE(main_request != NULL); |
1980 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, | 1982 EXPECT_EQ(FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE, |
1981 main_request->common_params().navigation_type); | 1983 main_request->common_params().navigation_type); |
1982 } | 1984 } |
1983 | 1985 |
1984 } // namespace content | 1986 } // namespace content |
OLD | NEW |