Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_unittest.cc

Issue 1849343004: Remove RenderFrameHostImplState and convert it to boolean. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // committed immediately (since it is a new tab). Therefore the main frame 340 // committed immediately (since it is a new tab). Therefore the main frame
341 // is replaced without a pending frame being created, and we don't get the 341 // is replaced without a pending frame being created, and we don't get the
342 // right values for the RFH to navigate: we try to use the old one that has 342 // right values for the RFH to navigate: we try to use the old one that has
343 // been deleted in the meantime. 343 // been deleted in the meantime.
344 contents()->GetMainFrame()->PrepareForCommit(); 344 contents()->GetMainFrame()->PrepareForCommit();
345 345
346 TestRenderFrameHost* old_rfh = contents()->GetMainFrame(); 346 TestRenderFrameHost* old_rfh = contents()->GetMainFrame();
347 TestRenderFrameHost* active_rfh = contents()->GetPendingMainFrame() 347 TestRenderFrameHost* active_rfh = contents()->GetPendingMainFrame()
348 ? contents()->GetPendingMainFrame() 348 ? contents()->GetPendingMainFrame()
349 : old_rfh; 349 : old_rfh;
350 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, old_rfh->rfh_state()); 350 EXPECT_TRUE(old_rfh->is_active());
351 351
352 // Commit the navigation with a new page ID. 352 // Commit the navigation with a new page ID.
353 int32_t max_page_id = 353 int32_t max_page_id =
354 contents()->GetMaxPageIDForSiteInstance(active_rfh->GetSiteInstance()); 354 contents()->GetMaxPageIDForSiteInstance(active_rfh->GetSiteInstance());
355 355
356 // Use an observer to avoid accessing a deleted renderer later on when the 356 // Use an observer to avoid accessing a deleted renderer later on when the
357 // state is being checked. 357 // state is being checked.
358 RenderFrameDeletedObserver rfh_observer(old_rfh); 358 RenderFrameDeletedObserver rfh_observer(old_rfh);
359 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost()); 359 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost());
360 active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url); 360 active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url);
361 361
362 // Make sure that we start to run the unload handler at the time of commit. 362 // Make sure that we start to run the unload handler at the time of commit.
363 if (old_rfh != active_rfh && !rfh_observer.deleted()) { 363 if (old_rfh != active_rfh && !rfh_observer.deleted()) {
364 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, 364 EXPECT_FALSE(old_rfh->is_active());
365 old_rfh->rfh_state());
366 EXPECT_TRUE( 365 EXPECT_TRUE(
367 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion( 366 old_rfh->frame_tree_node()->render_manager()->IsPendingDeletion(
368 old_rfh)); 367 old_rfh));
369 } 368 }
370 369
371 // Simulate the swap out ACK coming from the pending renderer. This should 370 // Simulate the swap out ACK coming from the pending renderer. This should
372 // either shut down the old RFH or leave it in a swapped out state. 371 // either shut down the old RFH or leave it in a swapped out state.
373 if (old_rfh != active_rfh) { 372 if (old_rfh != active_rfh) {
374 old_rfh->OnSwappedOut(); 373 old_rfh->OnSwappedOut();
375 EXPECT_TRUE(rfh_observer.deleted()); 374 EXPECT_TRUE(rfh_observer.deleted());
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 rfh1->GetSiteInstance()->IncrementActiveFrameCount(); 655 rfh1->GetSiteInstance()->IncrementActiveFrameCount();
657 656
658 // Navigate to a cross-site URL and commit the new page. 657 // Navigate to a cross-site URL and commit the new page.
659 controller().LoadURL( 658 controller().LoadURL(
660 kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 659 kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
661 int entry_id = controller().GetPendingEntry()->GetUniqueID(); 660 int entry_id = controller().GetPendingEntry()->GetUniqueID();
662 contents()->GetMainFrame()->PrepareForCommit(); 661 contents()->GetMainFrame()->PrepareForCommit();
663 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); 662 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
664 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kDestUrl, 663 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kDestUrl,
665 ui::PAGE_TRANSITION_TYPED); 664 ui::PAGE_TRANSITION_TYPED);
666 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); 665 EXPECT_FALSE(rfh1->is_active());
667 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); 666 EXPECT_TRUE(rfh2->is_active());
668 667
669 // The new RVH should be able to update its favicons. 668 // The new RVH should be able to update its favicons.
670 { 669 {
671 PluginFaviconMessageObserver observer(contents()); 670 PluginFaviconMessageObserver observer(contents());
672 EXPECT_TRUE(rfh2->GetRenderViewHost()->GetWidget()->OnMessageReceived( 671 EXPECT_TRUE(rfh2->GetRenderViewHost()->GetWidget()->OnMessageReceived(
673 ViewHostMsg_UpdateFaviconURL(rfh2->GetRenderViewHost()->GetRoutingID(), 672 ViewHostMsg_UpdateFaviconURL(rfh2->GetRenderViewHost()->GetRoutingID(),
674 icons))); 673 icons)));
675 EXPECT_TRUE(observer.favicon_received()); 674 EXPECT_TRUE(observer.favicon_received());
676 } 675 }
677 676
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 contents()->GetController().GoBack(); 1278 contents()->GetController().GoBack();
1280 EXPECT_TRUE(rfh2->is_waiting_for_beforeunload_ack()); 1279 EXPECT_TRUE(rfh2->is_waiting_for_beforeunload_ack());
1281 contents()->GetMainFrame()->PrepareForCommit(); 1280 contents()->GetMainFrame()->PrepareForCommit();
1282 EXPECT_FALSE(rfh2->is_waiting_for_beforeunload_ack()); 1281 EXPECT_FALSE(rfh2->is_waiting_for_beforeunload_ack());
1283 1282
1284 // The back navigation commits. 1283 // The back navigation commits.
1285 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry(); 1284 const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
1286 contents()->GetPendingMainFrame()->SendNavigate( 1285 contents()->GetPendingMainFrame()->SendNavigate(
1287 entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL()); 1286 entry1->GetPageID(), entry1->GetUniqueID(), false, entry1->GetURL());
1288 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK()); 1287 EXPECT_TRUE(rfh2->IsWaitingForUnloadACK());
1289 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh2->rfh_state()); 1288 EXPECT_FALSE(rfh2->is_active());
1290 1289
1291 // We should be able to navigate forward. 1290 // We should be able to navigate forward.
1292 contents()->GetController().GoForward(); 1291 contents()->GetController().GoForward();
1293 contents()->GetMainFrame()->PrepareForCommit(); 1292 contents()->GetMainFrame()->PrepareForCommit();
1294 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry(); 1293 const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry();
1295 contents()->GetPendingMainFrame()->SendNavigate( 1294 contents()->GetPendingMainFrame()->SendNavigate(
1296 entry2->GetPageID(), entry2->GetUniqueID(), false, entry2->GetURL()); 1295 entry2->GetPageID(), entry2->GetUniqueID(), false, entry2->GetURL());
1297 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state()); 1296 EXPECT_TRUE(main_test_rfh()->is_active());
1298 } 1297 }
1299 1298
1300 // Test that we create swapped out RFHs for the opener chain when navigating an 1299 // Test that we create swapped out RFHs for the opener chain when navigating an
1301 // opened tab cross-process. This allows us to support certain cross-process 1300 // opened tab cross-process. This allows us to support certain cross-process
1302 // JavaScript calls (http://crbug.com/99202). 1301 // JavaScript calls (http://crbug.com/99202).
1303 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) { 1302 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) {
1304 const GURL kUrl1("http://www.google.com/"); 1303 const GURL kUrl1("http://www.google.com/");
1305 const GURL kUrl2("http://www.chromium.org/"); 1304 const GURL kUrl2("http://www.chromium.org/");
1306 const GURL kChromeUrl("chrome://foo"); 1305 const GURL kChromeUrl("chrome://foo");
1307 1306
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 // received. (SwapOut and the corresponding ACK always occur after commit.) 1758 // received. (SwapOut and the corresponding ACK always occur after commit.)
1760 // Also tests that an early SwapOutACK is properly ignored. 1759 // Also tests that an early SwapOutACK is properly ignored.
1761 TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) { 1760 TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) {
1762 const GURL kUrl1("http://www.google.com/"); 1761 const GURL kUrl1("http://www.google.com/");
1763 const GURL kUrl2("http://www.chromium.org/"); 1762 const GURL kUrl2("http://www.chromium.org/");
1764 1763
1765 // Navigate to the first page. 1764 // Navigate to the first page.
1766 contents()->NavigateAndCommit(kUrl1); 1765 contents()->NavigateAndCommit(kUrl1);
1767 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); 1766 TestRenderFrameHost* rfh1 = contents()->GetMainFrame();
1768 RenderFrameDeletedObserver rfh_deleted_observer(rfh1); 1767 RenderFrameDeletedObserver rfh_deleted_observer(rfh1);
1769 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1768 EXPECT_TRUE(rfh1->is_active());
1770 1769
1771 // Navigate to new site, simulating onbeforeunload approval. 1770 // Navigate to new site, simulating onbeforeunload approval.
1772 controller().LoadURL( 1771 controller().LoadURL(
1773 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 1772 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
1774 int entry_id = controller().GetPendingEntry()->GetUniqueID(); 1773 int entry_id = controller().GetPendingEntry()->GetUniqueID();
1775 contents()->GetMainFrame()->PrepareForCommit(); 1774 contents()->GetMainFrame()->PrepareForCommit();
1776 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1775 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1777 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1776 EXPECT_TRUE(rfh1->is_active());
1778 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); 1777 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
1779 1778
1780 // Simulate the swap out ack, unexpectedly early (before commit). It should 1779 // Simulate the swap out ack, unexpectedly early (before commit). It should
1781 // have no effect. 1780 // have no effect.
1782 rfh1->OnSwappedOut(); 1781 rfh1->OnSwappedOut();
1783 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1782 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1784 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1783 EXPECT_TRUE(rfh1->is_active());
1785 1784
1786 // The new page commits. 1785 // The new page commits.
1787 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2, 1786 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2,
1788 ui::PAGE_TRANSITION_TYPED); 1787 ui::PAGE_TRANSITION_TYPED);
1789 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1788 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1790 EXPECT_EQ(rfh2, contents()->GetMainFrame()); 1789 EXPECT_EQ(rfh2, contents()->GetMainFrame());
1791 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); 1790 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
1792 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); 1791 EXPECT_FALSE(rfh1->is_active());
1793 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); 1792 EXPECT_TRUE(rfh2->is_active());
1794 EXPECT_TRUE( 1793 EXPECT_TRUE(
1795 rfh1->frame_tree_node()->render_manager()->IsPendingDeletion(rfh1)); 1794 rfh1->frame_tree_node()->render_manager()->IsPendingDeletion(rfh1));
1796 1795
1797 // Simulate the swap out ack. 1796 // Simulate the swap out ack.
1798 rfh1->OnSwappedOut(); 1797 rfh1->OnSwappedOut();
1799 1798
1800 // rfh1 should have been deleted. 1799 // rfh1 should have been deleted.
1801 EXPECT_TRUE(rfh_deleted_observer.deleted()); 1800 EXPECT_TRUE(rfh_deleted_observer.deleted());
1802 rfh1 = NULL; 1801 rfh1 = NULL;
1803 } 1802 }
1804 1803
1805 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK 1804 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK
1806 // is received. (SwapOut and the corresponding ACK always occur after commit.) 1805 // is received. (SwapOut and the corresponding ACK always occur after commit.)
1807 TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) { 1806 TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) {
1808 const GURL kUrl1("http://www.google.com/"); 1807 const GURL kUrl1("http://www.google.com/");
1809 const GURL kUrl2("http://www.chromium.org/"); 1808 const GURL kUrl2("http://www.chromium.org/");
1810 1809
1811 // Navigate to the first page. 1810 // Navigate to the first page.
1812 contents()->NavigateAndCommit(kUrl1); 1811 contents()->NavigateAndCommit(kUrl1);
1813 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); 1812 TestRenderFrameHost* rfh1 = contents()->GetMainFrame();
1814 RenderFrameDeletedObserver rfh_deleted_observer(rfh1); 1813 RenderFrameDeletedObserver rfh_deleted_observer(rfh1);
1815 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1814 EXPECT_TRUE(rfh1->is_active());
1816 1815
1817 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is 1816 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is
1818 // not deleted on swap out. 1817 // not deleted on swap out.
1819 rfh1->GetSiteInstance()->IncrementActiveFrameCount(); 1818 rfh1->GetSiteInstance()->IncrementActiveFrameCount();
1820 1819
1821 // Navigate to new site, simulating onbeforeunload approval. 1820 // Navigate to new site, simulating onbeforeunload approval.
1822 controller().LoadURL( 1821 controller().LoadURL(
1823 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 1822 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
1824 int entry_id = controller().GetPendingEntry()->GetUniqueID(); 1823 int entry_id = controller().GetPendingEntry()->GetUniqueID();
1825 contents()->GetMainFrame()->PrepareForCommit(); 1824 contents()->GetMainFrame()->PrepareForCommit();
1826 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1825 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1827 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1826 EXPECT_TRUE(rfh1->is_active());
1828 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); 1827 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
1829 1828
1830 // The new page commits. 1829 // The new page commits.
1831 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2, 1830 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2,
1832 ui::PAGE_TRANSITION_TYPED); 1831 ui::PAGE_TRANSITION_TYPED);
1833 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1832 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1834 EXPECT_EQ(rfh2, contents()->GetMainFrame()); 1833 EXPECT_EQ(rfh2, contents()->GetMainFrame());
1835 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); 1834 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
1836 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); 1835 EXPECT_FALSE(rfh1->is_active());
1837 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); 1836 EXPECT_TRUE(rfh2->is_active());
1838 1837
1839 // Simulate the swap out ack. 1838 // Simulate the swap out ack.
1840 rfh1->OnSwappedOut(); 1839 rfh1->OnSwappedOut();
1841 1840
1842 // rfh1 should be deleted. 1841 // rfh1 should be deleted.
1843 EXPECT_TRUE(rfh_deleted_observer.deleted()); 1842 EXPECT_TRUE(rfh_deleted_observer.deleted());
1844 } 1843 }
1845 1844
1846 // Test that the RenderViewHost is properly swapped out if a navigation in the 1845 // Test that the RenderViewHost is properly swapped out if a navigation in the
1847 // new renderer commits before sending the SwapOut message to the old renderer. 1846 // new renderer commits before sending the SwapOut message to the old renderer.
1848 // This simulates a cross-site navigation to a synchronously committing URL 1847 // This simulates a cross-site navigation to a synchronously committing URL
1849 // (e.g., a data URL) and ensures it works properly. 1848 // (e.g., a data URL) and ensures it works properly.
1850 TEST_F(RenderFrameHostManagerTest, 1849 TEST_F(RenderFrameHostManagerTest,
1851 CommitNewNavigationBeforeSendingSwapOut) { 1850 CommitNewNavigationBeforeSendingSwapOut) {
1852 const GURL kUrl1("http://www.google.com/"); 1851 const GURL kUrl1("http://www.google.com/");
1853 const GURL kUrl2("http://www.chromium.org/"); 1852 const GURL kUrl2("http://www.chromium.org/");
1854 1853
1855 // Navigate to the first page. 1854 // Navigate to the first page.
1856 contents()->NavigateAndCommit(kUrl1); 1855 contents()->NavigateAndCommit(kUrl1);
1857 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); 1856 TestRenderFrameHost* rfh1 = contents()->GetMainFrame();
1858 RenderFrameDeletedObserver rfh_deleted_observer(rfh1); 1857 RenderFrameDeletedObserver rfh_deleted_observer(rfh1);
1859 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1858 EXPECT_TRUE(rfh1->is_active());
1860 1859
1861 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is 1860 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is
1862 // not deleted on swap out. 1861 // not deleted on swap out.
1863 scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance(); 1862 scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance();
1864 site_instance->IncrementActiveFrameCount(); 1863 site_instance->IncrementActiveFrameCount();
1865 1864
1866 // Navigate to new site, simulating onbeforeunload approval. 1865 // Navigate to new site, simulating onbeforeunload approval.
1867 controller().LoadURL( 1866 controller().LoadURL(
1868 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 1867 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
1869 int entry_id = controller().GetPendingEntry()->GetUniqueID(); 1868 int entry_id = controller().GetPendingEntry()->GetUniqueID();
1870 rfh1->PrepareForCommit(); 1869 rfh1->PrepareForCommit();
1871 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 1870 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
1872 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); 1871 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
1873 1872
1874 // The new page commits. 1873 // The new page commits.
1875 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2, 1874 contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2,
1876 ui::PAGE_TRANSITION_TYPED); 1875 ui::PAGE_TRANSITION_TYPED);
1877 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 1876 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
1878 EXPECT_EQ(rfh2, contents()->GetMainFrame()); 1877 EXPECT_EQ(rfh2, contents()->GetMainFrame());
1879 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL); 1878 EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
1880 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state()); 1879 EXPECT_FALSE(rfh1->is_active());
1881 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state()); 1880 EXPECT_TRUE(rfh2->is_active());
1882 1881
1883 // Simulate the swap out ack. 1882 // Simulate the swap out ack.
1884 rfh1->OnSwappedOut(); 1883 rfh1->OnSwappedOut();
1885 1884
1886 // rfh1 should be deleted. 1885 // rfh1 should be deleted.
1887 EXPECT_TRUE(rfh_deleted_observer.deleted()); 1886 EXPECT_TRUE(rfh_deleted_observer.deleted());
1888 EXPECT_TRUE(contents()->GetFrameTree()->root()->render_manager() 1887 EXPECT_TRUE(contents()->GetFrameTree()->root()->render_manager()
1889 ->GetRenderFrameProxyHost(site_instance.get())); 1888 ->GetRenderFrameProxyHost(site_instance.get()));
1890 } 1889 }
1891 1890
1892 // Test that a RenderFrameHost is properly deleted when a cross-site navigation 1891 // Test that a RenderFrameHost is properly deleted when a cross-site navigation
1893 // is cancelled. 1892 // is cancelled.
1894 TEST_F(RenderFrameHostManagerTest, 1893 TEST_F(RenderFrameHostManagerTest,
1895 CancelPendingProperlyDeletesOrSwaps) { 1894 CancelPendingProperlyDeletesOrSwaps) {
1896 const GURL kUrl1("http://www.google.com/"); 1895 const GURL kUrl1("http://www.google.com/");
1897 const GURL kUrl2("http://www.chromium.org/"); 1896 const GURL kUrl2("http://www.chromium.org/");
1898 RenderFrameHostImpl* pending_rfh = NULL; 1897 RenderFrameHostImpl* pending_rfh = NULL;
1899 base::TimeTicks now = base::TimeTicks::Now(); 1898 base::TimeTicks now = base::TimeTicks::Now();
1900 1899
1901 // Navigate to the first page. 1900 // Navigate to the first page.
1902 contents()->NavigateAndCommit(kUrl1); 1901 contents()->NavigateAndCommit(kUrl1);
1903 TestRenderFrameHost* rfh1 = main_test_rfh(); 1902 TestRenderFrameHost* rfh1 = main_test_rfh();
1904 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); 1903 EXPECT_TRUE(rfh1->is_active());
1905 1904
1906 // Navigate to a new site, starting a cross-site navigation. 1905 // Navigate to a new site, starting a cross-site navigation.
1907 controller().LoadURL( 1906 controller().LoadURL(
1908 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 1907 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
1909 { 1908 {
1910 pending_rfh = contents()->GetPendingMainFrame(); 1909 pending_rfh = contents()->GetPendingMainFrame();
1911 RenderFrameDeletedObserver rfh_deleted_observer(pending_rfh); 1910 RenderFrameDeletedObserver rfh_deleted_observer(pending_rfh);
1912 1911
1913 // Cancel the navigation by simulating a declined beforeunload dialog. 1912 // Cancel the navigation by simulating a declined beforeunload dialog.
1914 contents()->GetMainFrame()->OnMessageReceived( 1913 contents()->GetMainFrame()->OnMessageReceived(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 ui::PAGE_TRANSITION_LINK, 2000 ui::PAGE_TRANSITION_LINK,
2002 false /* is_renderer_init */); 2001 false /* is_renderer_init */);
2003 host1 = NavigateToEntry(iframe1, entryB); 2002 host1 = NavigateToEntry(iframe1, entryB);
2004 RenderFrameHostImpl* host2 = NavigateToEntry(iframe2, entryB); 2003 RenderFrameHostImpl* host2 = NavigateToEntry(iframe2, entryB);
2005 2004
2006 // A new, pending RenderFrameHost should be created in each FrameTreeNode. 2005 // A new, pending RenderFrameHost should be created in each FrameTreeNode.
2007 EXPECT_TRUE(GetPendingFrameHost(iframe1)); 2006 EXPECT_TRUE(GetPendingFrameHost(iframe1));
2008 EXPECT_TRUE(GetPendingFrameHost(iframe2)); 2007 EXPECT_TRUE(GetPendingFrameHost(iframe2));
2009 EXPECT_EQ(host1, GetPendingFrameHost(iframe1)); 2008 EXPECT_EQ(host1, GetPendingFrameHost(iframe1));
2010 EXPECT_EQ(host2, GetPendingFrameHost(iframe2)); 2009 EXPECT_EQ(host2, GetPendingFrameHost(iframe2));
2011 EXPECT_TRUE(RenderFrameHostImpl::IsRFHStateActive( 2010 EXPECT_TRUE(GetPendingFrameHost(iframe1)->is_active());
2012 GetPendingFrameHost(iframe1)->rfh_state())); 2011 EXPECT_TRUE(GetPendingFrameHost(iframe2)->is_active());
2013 EXPECT_TRUE(RenderFrameHostImpl::IsRFHStateActive(
2014 GetPendingFrameHost(iframe2)->rfh_state()));
2015 EXPECT_NE(GetPendingFrameHost(iframe1), GetPendingFrameHost(iframe2)); 2012 EXPECT_NE(GetPendingFrameHost(iframe1), GetPendingFrameHost(iframe2));
2016 EXPECT_EQ(GetPendingFrameHost(iframe1)->GetSiteInstance(), 2013 EXPECT_EQ(GetPendingFrameHost(iframe1)->GetSiteInstance(),
2017 GetPendingFrameHost(iframe2)->GetSiteInstance()); 2014 GetPendingFrameHost(iframe2)->GetSiteInstance());
2018 EXPECT_NE(iframe1->current_frame_host(), GetPendingFrameHost(iframe1)); 2015 EXPECT_NE(iframe1->current_frame_host(), GetPendingFrameHost(iframe1));
2019 EXPECT_NE(iframe2->current_frame_host(), GetPendingFrameHost(iframe2)); 2016 EXPECT_NE(iframe2->current_frame_host(), GetPendingFrameHost(iframe2));
2020 EXPECT_FALSE(contents()->CrossProcessNavigationPending()) 2017 EXPECT_FALSE(contents()->CrossProcessNavigationPending())
2021 << "There should be no top-level pending navigation."; 2018 << "There should be no top-level pending navigation.";
2022 2019
2023 RenderFrameDeletedObserver delete_watcher1(GetPendingFrameHost(iframe1)); 2020 RenderFrameDeletedObserver delete_watcher1(GetPendingFrameHost(iframe1));
2024 RenderFrameDeletedObserver delete_watcher2(GetPendingFrameHost(iframe2)); 2021 RenderFrameDeletedObserver delete_watcher2(GetPendingFrameHost(iframe2));
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 commit_params.should_enforce_strict_mixed_content_checking = false; 3103 commit_params.should_enforce_strict_mixed_content_checking = false;
3107 child_host->SendNavigateWithParams(&commit_params); 3104 child_host->SendNavigateWithParams(&commit_params);
3108 EXPECT_NO_FATAL_FAILURE(CheckMixedContentIPC( 3105 EXPECT_NO_FATAL_FAILURE(CheckMixedContentIPC(
3109 main_test_rfh(), false, proxy_to_parent->GetRoutingID())); 3106 main_test_rfh(), false, proxy_to_parent->GetRoutingID()));
3110 EXPECT_FALSE(root->child_at(0) 3107 EXPECT_FALSE(root->child_at(0)
3111 ->current_replication_state() 3108 ->current_replication_state()
3112 .should_enforce_strict_mixed_content_checking); 3109 .should_enforce_strict_mixed_content_checking);
3113 } 3110 }
3114 3111
3115 } // namespace content 3112 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698