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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 // Use an observer to avoid accessing a deleted renderer later on when the | 301 // Use an observer to avoid accessing a deleted renderer later on when the |
302 // state is being checked. | 302 // state is being checked. |
303 RenderFrameHostDeletedObserver rfh_observer(old_rfh); | 303 RenderFrameHostDeletedObserver rfh_observer(old_rfh); |
304 RenderViewHostDeletedObserver rvh_observer(old_rvh); | 304 RenderViewHostDeletedObserver rvh_observer(old_rvh); |
305 active_rfh->SendNavigate(max_page_id + 1, url); | 305 active_rfh->SendNavigate(max_page_id + 1, url); |
306 | 306 |
307 // Make sure that we start to run the unload handler at the time of commit. | 307 // Make sure that we start to run the unload handler at the time of commit. |
308 bool expecting_rfh_shutdown = false; | 308 bool expecting_rfh_shutdown = false; |
309 if (old_rfh != active_rfh && !rfh_observer.deleted()) { | 309 if (old_rfh != active_rfh && !rfh_observer.deleted()) { |
| 310 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, |
| 311 old_rfh->rfh_state()); |
310 if (!old_rfh->GetSiteInstance()->active_frame_count()) { | 312 if (!old_rfh->GetSiteInstance()->active_frame_count()) { |
311 expecting_rfh_shutdown = true; | 313 expecting_rfh_shutdown = true; |
312 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SHUTDOWN, | 314 EXPECT_TRUE( |
313 old_rfh->rfh_state()); | 315 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( |
314 } else { | 316 old_rfh)); |
315 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, | |
316 old_rfh->rfh_state()); | |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 // Simulate the swap out ACK coming from the pending renderer. This should | 320 // Simulate the swap out ACK coming from the pending renderer. This should |
321 // either shut down the old RFH or leave it in a swapped out state. | 321 // either shut down the old RFH or leave it in a swapped out state. |
322 if (old_rfh != active_rfh) { | 322 if (old_rfh != active_rfh) { |
323 old_rfh->OnSwappedOut(); | 323 old_rfh->OnSwappedOut(); |
324 if (expecting_rfh_shutdown) { | 324 if (expecting_rfh_shutdown) { |
325 EXPECT_TRUE(rfh_observer.deleted()); | 325 EXPECT_TRUE(rfh_observer.deleted()); |
326 EXPECT_TRUE(rvh_observer.deleted()); | 326 EXPECT_TRUE(rvh_observer.deleted()); |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 rfh1->OnSwappedOut(); | 1542 rfh1->OnSwappedOut(); |
1543 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1543 EXPECT_TRUE(contents()->cross_navigation_pending()); |
1544 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1544 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
1545 | 1545 |
1546 // The new page commits. | 1546 // The new page commits. |
1547 contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED); | 1547 contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED); |
1548 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1548 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1549 EXPECT_EQ(rfh2, contents()->GetMainFrame()); | 1549 EXPECT_EQ(rfh2, contents()->GetMainFrame()); |
1550 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); | 1550 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); |
1551 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); | 1551 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); |
1552 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SHUTDOWN, rfh1->rfh_state()); | 1552 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); |
| 1553 EXPECT_TRUE( |
| 1554 rfh1->frame_tree_node()->render_manager()->IsPendingDeletion(rfh1)); |
1553 | 1555 |
1554 // Simulate the swap out ack. | 1556 // Simulate the swap out ack. |
1555 rfh1->OnSwappedOut(); | 1557 rfh1->OnSwappedOut(); |
1556 | 1558 |
1557 // rfh1 should have been deleted. | 1559 // rfh1 should have been deleted. |
1558 EXPECT_TRUE(rfh_deleted_observer.deleted()); | 1560 EXPECT_TRUE(rfh_deleted_observer.deleted()); |
1559 rfh1 = NULL; | 1561 rfh1 = NULL; |
1560 } | 1562 } |
1561 | 1563 |
1562 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK | 1564 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 pending_rfh->GetSiteInstance()->increment_active_frame_count(); | 1692 pending_rfh->GetSiteInstance()->increment_active_frame_count(); |
1691 | 1693 |
1692 contents()->GetMainFrame()->OnMessageReceived( | 1694 contents()->GetMainFrame()->OnMessageReceived( |
1693 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1695 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
1694 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1696 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1695 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 1697 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
1696 } | 1698 } |
1697 } | 1699 } |
1698 | 1700 |
1699 } // namespace content | 1701 } // namespace content |
OLD | NEW |