| 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/compositor/test/no_transport_image_transport_factory.h
" | 10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/render_widget_host_iterator.h" | 27 #include "content/public/browser/render_widget_host_iterator.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 28 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
| 30 #include "content/public/browser/web_ui_controller.h" | 30 #include "content/public/browser/web_ui_controller.h" |
| 31 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
| 32 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 33 #include "content/public/common/javascript_message_type.h" | 33 #include "content/public/common/javascript_message_type.h" |
| 34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 35 #include "content/public/common/url_utils.h" | 35 #include "content/public/common/url_utils.h" |
| 36 #include "content/public/test/browser_test_utils.h" |
| 36 #include "content/public/test/mock_render_process_host.h" | 37 #include "content/public/test/mock_render_process_host.h" |
| 37 #include "content/public/test/test_notification_tracker.h" | 38 #include "content/public/test/test_notification_tracker.h" |
| 38 #include "content/test/test_content_browser_client.h" | 39 #include "content/test/test_content_browser_client.h" |
| 39 #include "content/test/test_content_client.h" | 40 #include "content/test/test_content_client.h" |
| 40 #include "content/test/test_render_frame_host.h" | 41 #include "content/test/test_render_frame_host.h" |
| 41 #include "content/test/test_render_view_host.h" | 42 #include "content/test/test_render_view_host.h" |
| 42 #include "content/test/test_web_contents.h" | 43 #include "content/test/test_web_contents.h" |
| 43 #include "net/base/load_flags.h" | 44 #include "net/base/load_flags.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 46 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 bool created() { | 168 bool created() { |
| 168 return created_; | 169 return created_; |
| 169 } | 170 } |
| 170 | 171 |
| 171 private: | 172 private: |
| 172 bool created_; | 173 bool created_; |
| 173 | 174 |
| 174 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostCreatedObserver); | 175 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostCreatedObserver); |
| 175 }; | 176 }; |
| 176 | 177 |
| 177 // This observer keeps track of the last deleted RenderFrameHost to avoid | |
| 178 // accessing it and causing use-after-free condition. | |
| 179 class RenderFrameHostDeletedObserver : public WebContentsObserver { | |
| 180 public: | |
| 181 RenderFrameHostDeletedObserver(RenderFrameHost* rfh) | |
| 182 : WebContentsObserver(WebContents::FromRenderFrameHost(rfh)), | |
| 183 process_id_(rfh->GetProcess()->GetID()), | |
| 184 routing_id_(rfh->GetRoutingID()), | |
| 185 deleted_(false) { | |
| 186 } | |
| 187 | |
| 188 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override { | |
| 189 if (render_frame_host->GetProcess()->GetID() == process_id_ && | |
| 190 render_frame_host->GetRoutingID() == routing_id_) { | |
| 191 deleted_ = true; | |
| 192 } | |
| 193 } | |
| 194 | |
| 195 bool deleted() { | |
| 196 return deleted_; | |
| 197 } | |
| 198 | |
| 199 private: | |
| 200 int process_id_; | |
| 201 int routing_id_; | |
| 202 bool deleted_; | |
| 203 | |
| 204 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostDeletedObserver); | |
| 205 }; | |
| 206 | |
| 207 // This WebContents observer keep track of its RVH change. | 178 // This WebContents observer keep track of its RVH change. |
| 208 class RenderViewHostChangedObserver : public WebContentsObserver { | 179 class RenderViewHostChangedObserver : public WebContentsObserver { |
| 209 public: | 180 public: |
| 210 RenderViewHostChangedObserver(WebContents* web_contents) | 181 RenderViewHostChangedObserver(WebContents* web_contents) |
| 211 : WebContentsObserver(web_contents), host_changed_(false) {} | 182 : WebContentsObserver(web_contents), host_changed_(false) {} |
| 212 | 183 |
| 213 // WebContentsObserver. | 184 // WebContentsObserver. |
| 214 void RenderViewHostChanged(RenderViewHost* old_host, | 185 void RenderViewHostChanged(RenderViewHost* old_host, |
| 215 RenderViewHost* new_host) override { | 186 RenderViewHost* new_host) override { |
| 216 host_changed_ = true; | 187 host_changed_ = true; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ? contents()->GetPendingMainFrame() | 285 ? contents()->GetPendingMainFrame() |
| 315 : old_rfh; | 286 : old_rfh; |
| 316 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, old_rfh->rfh_state()); | 287 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, old_rfh->rfh_state()); |
| 317 | 288 |
| 318 // Commit the navigation with a new page ID. | 289 // Commit the navigation with a new page ID. |
| 319 int32 max_page_id = contents()->GetMaxPageIDForSiteInstance( | 290 int32 max_page_id = contents()->GetMaxPageIDForSiteInstance( |
| 320 active_rfh->GetSiteInstance()); | 291 active_rfh->GetSiteInstance()); |
| 321 | 292 |
| 322 // Use an observer to avoid accessing a deleted renderer later on when the | 293 // Use an observer to avoid accessing a deleted renderer later on when the |
| 323 // state is being checked. | 294 // state is being checked. |
| 324 RenderFrameHostDeletedObserver rfh_observer(old_rfh); | 295 RenderFrameDeletedObserver rfh_observer(old_rfh); |
| 325 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost()); | 296 RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost()); |
| 326 active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url); | 297 active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url); |
| 327 | 298 |
| 328 // Make sure that we start to run the unload handler at the time of commit. | 299 // Make sure that we start to run the unload handler at the time of commit. |
| 329 bool expecting_rfh_shutdown = false; | 300 bool expecting_rfh_shutdown = false; |
| 330 if (old_rfh != active_rfh && !rfh_observer.deleted()) { | 301 if (old_rfh != active_rfh && !rfh_observer.deleted()) { |
| 331 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, | 302 EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, |
| 332 old_rfh->rfh_state()); | 303 old_rfh->rfh_state()); |
| 333 if (!old_rfh->GetSiteInstance()->active_frame_count() || | 304 if (!old_rfh->GetSiteInstance()->active_frame_count() || |
| 334 RenderFrameHostManager::IsSwappedOutStateForbidden()) { | 305 RenderFrameHostManager::IsSwappedOutStateForbidden()) { |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) { | 1346 TEST_F(RenderFrameHostManagerTest, CreateSwappedOutOpenerRFHs) { |
| 1376 const GURL kUrl1("http://www.google.com/"); | 1347 const GURL kUrl1("http://www.google.com/"); |
| 1377 const GURL kUrl2("http://www.chromium.org/"); | 1348 const GURL kUrl2("http://www.chromium.org/"); |
| 1378 const GURL kChromeUrl("chrome://foo"); | 1349 const GURL kChromeUrl("chrome://foo"); |
| 1379 | 1350 |
| 1380 // Navigate to an initial URL. | 1351 // Navigate to an initial URL. |
| 1381 contents()->NavigateAndCommit(kUrl1); | 1352 contents()->NavigateAndCommit(kUrl1); |
| 1382 RenderFrameHostManager* manager = contents()->GetRenderManagerForTesting(); | 1353 RenderFrameHostManager* manager = contents()->GetRenderManagerForTesting(); |
| 1383 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1354 TestRenderFrameHost* rfh1 = main_test_rfh(); |
| 1384 scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance(); | 1355 scoped_refptr<SiteInstanceImpl> site_instance1 = rfh1->GetSiteInstance(); |
| 1385 RenderFrameHostDeletedObserver rfh1_deleted_observer(rfh1); | 1356 RenderFrameDeletedObserver rfh1_deleted_observer(rfh1); |
| 1386 TestRenderViewHost* rvh1 = test_rvh(); | 1357 TestRenderViewHost* rvh1 = test_rvh(); |
| 1387 | 1358 |
| 1388 // Create 2 new tabs and simulate them being the opener chain for the main | 1359 // Create 2 new tabs and simulate them being the opener chain for the main |
| 1389 // tab. They should be in the same SiteInstance. | 1360 // tab. They should be in the same SiteInstance. |
| 1390 scoped_ptr<TestWebContents> opener1( | 1361 scoped_ptr<TestWebContents> opener1( |
| 1391 TestWebContents::Create(browser_context(), site_instance1.get())); | 1362 TestWebContents::Create(browser_context(), site_instance1.get())); |
| 1392 RenderFrameHostManager* opener1_manager = | 1363 RenderFrameHostManager* opener1_manager = |
| 1393 opener1->GetRenderManagerForTesting(); | 1364 opener1->GetRenderManagerForTesting(); |
| 1394 contents()->SetOpener(opener1.get()); | 1365 contents()->SetOpener(opener1.get()); |
| 1395 | 1366 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 // Tests that the RenderFrameHost is properly deleted when the SwapOutACK is | 1821 // Tests that the RenderFrameHost is properly deleted when the SwapOutACK is |
| 1851 // received. (SwapOut and the corresponding ACK always occur after commit.) | 1822 // received. (SwapOut and the corresponding ACK always occur after commit.) |
| 1852 // Also tests that an early SwapOutACK is properly ignored. | 1823 // Also tests that an early SwapOutACK is properly ignored. |
| 1853 TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) { | 1824 TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) { |
| 1854 const GURL kUrl1("http://www.google.com/"); | 1825 const GURL kUrl1("http://www.google.com/"); |
| 1855 const GURL kUrl2("http://www.chromium.org/"); | 1826 const GURL kUrl2("http://www.chromium.org/"); |
| 1856 | 1827 |
| 1857 // Navigate to the first page. | 1828 // Navigate to the first page. |
| 1858 contents()->NavigateAndCommit(kUrl1); | 1829 contents()->NavigateAndCommit(kUrl1); |
| 1859 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); | 1830 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); |
| 1860 RenderFrameHostDeletedObserver rfh_deleted_observer(rfh1); | 1831 RenderFrameDeletedObserver rfh_deleted_observer(rfh1); |
| 1861 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1832 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 1862 | 1833 |
| 1863 // Navigate to new site, simulating onbeforeunload approval. | 1834 // Navigate to new site, simulating onbeforeunload approval. |
| 1864 controller().LoadURL( | 1835 controller().LoadURL( |
| 1865 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1836 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 1866 int entry_id = controller().GetPendingEntry()->GetUniqueID(); | 1837 int entry_id = controller().GetPendingEntry()->GetUniqueID(); |
| 1867 contents()->GetMainFrame()->PrepareForCommit(); | 1838 contents()->GetMainFrame()->PrepareForCommit(); |
| 1868 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); | 1839 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
| 1869 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1840 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 1870 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); | 1841 TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1896 | 1867 |
| 1897 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK | 1868 // Tests that the RenderFrameHost is properly swapped out when the SwapOut ACK |
| 1898 // is received. (SwapOut and the corresponding ACK always occur after commit.) | 1869 // is received. (SwapOut and the corresponding ACK always occur after commit.) |
| 1899 TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) { | 1870 TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) { |
| 1900 const GURL kUrl1("http://www.google.com/"); | 1871 const GURL kUrl1("http://www.google.com/"); |
| 1901 const GURL kUrl2("http://www.chromium.org/"); | 1872 const GURL kUrl2("http://www.chromium.org/"); |
| 1902 | 1873 |
| 1903 // Navigate to the first page. | 1874 // Navigate to the first page. |
| 1904 contents()->NavigateAndCommit(kUrl1); | 1875 contents()->NavigateAndCommit(kUrl1); |
| 1905 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); | 1876 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); |
| 1906 RenderFrameHostDeletedObserver rfh_deleted_observer(rfh1); | 1877 RenderFrameDeletedObserver rfh_deleted_observer(rfh1); |
| 1907 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1878 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 1908 | 1879 |
| 1909 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is | 1880 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is |
| 1910 // not deleted on swap out. | 1881 // not deleted on swap out. |
| 1911 rfh1->GetSiteInstance()->increment_active_frame_count(); | 1882 rfh1->GetSiteInstance()->increment_active_frame_count(); |
| 1912 | 1883 |
| 1913 // Navigate to new site, simulating onbeforeunload approval. | 1884 // Navigate to new site, simulating onbeforeunload approval. |
| 1914 controller().LoadURL( | 1885 controller().LoadURL( |
| 1915 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1886 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 1916 int entry_id = controller().GetPendingEntry()->GetUniqueID(); | 1887 int entry_id = controller().GetPendingEntry()->GetUniqueID(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1945 // This simulates a cross-site navigation to a synchronously committing URL | 1916 // This simulates a cross-site navigation to a synchronously committing URL |
| 1946 // (e.g., a data URL) and ensures it works properly. | 1917 // (e.g., a data URL) and ensures it works properly. |
| 1947 TEST_F(RenderFrameHostManagerTest, | 1918 TEST_F(RenderFrameHostManagerTest, |
| 1948 CommitNewNavigationBeforeSendingSwapOut) { | 1919 CommitNewNavigationBeforeSendingSwapOut) { |
| 1949 const GURL kUrl1("http://www.google.com/"); | 1920 const GURL kUrl1("http://www.google.com/"); |
| 1950 const GURL kUrl2("http://www.chromium.org/"); | 1921 const GURL kUrl2("http://www.chromium.org/"); |
| 1951 | 1922 |
| 1952 // Navigate to the first page. | 1923 // Navigate to the first page. |
| 1953 contents()->NavigateAndCommit(kUrl1); | 1924 contents()->NavigateAndCommit(kUrl1); |
| 1954 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); | 1925 TestRenderFrameHost* rfh1 = contents()->GetMainFrame(); |
| 1955 RenderFrameHostDeletedObserver rfh_deleted_observer(rfh1); | 1926 RenderFrameDeletedObserver rfh_deleted_observer(rfh1); |
| 1956 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1927 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 1957 | 1928 |
| 1958 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is | 1929 // Increment the number of active frames in SiteInstanceImpl so that rfh1 is |
| 1959 // not deleted on swap out. | 1930 // not deleted on swap out. |
| 1960 scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance(); | 1931 scoped_refptr<SiteInstanceImpl> site_instance = rfh1->GetSiteInstance(); |
| 1961 site_instance->increment_active_frame_count(); | 1932 site_instance->increment_active_frame_count(); |
| 1962 | 1933 |
| 1963 // Navigate to new site, simulating onbeforeunload approval. | 1934 // Navigate to new site, simulating onbeforeunload approval. |
| 1964 controller().LoadURL( | 1935 controller().LoadURL( |
| 1965 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1936 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 contents()->NavigateAndCommit(kUrl1); | 1975 contents()->NavigateAndCommit(kUrl1); |
| 2005 TestRenderFrameHost* rfh1 = main_test_rfh(); | 1976 TestRenderFrameHost* rfh1 = main_test_rfh(); |
| 2006 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 1977 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
| 2007 | 1978 |
| 2008 // Navigate to a new site, starting a cross-site navigation. | 1979 // Navigate to a new site, starting a cross-site navigation. |
| 2009 controller().LoadURL( | 1980 controller().LoadURL( |
| 2010 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1981 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 2011 { | 1982 { |
| 2012 pending_rfh = contents()->GetFrameTree()->root()->render_manager() | 1983 pending_rfh = contents()->GetFrameTree()->root()->render_manager() |
| 2013 ->pending_frame_host(); | 1984 ->pending_frame_host(); |
| 2014 RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh); | 1985 RenderFrameDeletedObserver rfh_deleted_observer(pending_rfh); |
| 2015 | 1986 |
| 2016 // Cancel the navigation by simulating a declined beforeunload dialog. | 1987 // Cancel the navigation by simulating a declined beforeunload dialog. |
| 2017 contents()->GetMainFrame()->OnMessageReceived( | 1988 contents()->GetMainFrame()->OnMessageReceived( |
| 2018 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 1989 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
| 2019 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 1990 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
| 2020 | 1991 |
| 2021 // Since the pending RFH is the only one for the new SiteInstance, it should | 1992 // Since the pending RFH is the only one for the new SiteInstance, it should |
| 2022 // be deleted. | 1993 // be deleted. |
| 2023 EXPECT_TRUE(rfh_deleted_observer.deleted()); | 1994 EXPECT_TRUE(rfh_deleted_observer.deleted()); |
| 2024 } | 1995 } |
| 2025 | 1996 |
| 2026 // Start another cross-site navigation. | 1997 // Start another cross-site navigation. |
| 2027 controller().LoadURL( | 1998 controller().LoadURL( |
| 2028 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1999 kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 2029 { | 2000 { |
| 2030 pending_rfh = contents()->GetFrameTree()->root()->render_manager() | 2001 pending_rfh = contents()->GetFrameTree()->root()->render_manager() |
| 2031 ->pending_frame_host(); | 2002 ->pending_frame_host(); |
| 2032 RenderFrameHostDeletedObserver rfh_deleted_observer(pending_rfh); | 2003 RenderFrameDeletedObserver rfh_deleted_observer(pending_rfh); |
| 2033 | 2004 |
| 2034 // Increment the number of active frames in the new SiteInstance, which will | 2005 // Increment the number of active frames in the new SiteInstance, which will |
| 2035 // cause the pending RFH to be deleted and a RenderFrameProxyHost to be | 2006 // cause the pending RFH to be deleted and a RenderFrameProxyHost to be |
| 2036 // created. | 2007 // created. |
| 2037 scoped_refptr<SiteInstanceImpl> site_instance = | 2008 scoped_refptr<SiteInstanceImpl> site_instance = |
| 2038 pending_rfh->GetSiteInstance(); | 2009 pending_rfh->GetSiteInstance(); |
| 2039 site_instance->increment_active_frame_count(); | 2010 site_instance->increment_active_frame_count(); |
| 2040 | 2011 |
| 2041 contents()->GetMainFrame()->OnMessageReceived( | 2012 contents()->GetMainFrame()->OnMessageReceived( |
| 2042 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); | 2013 FrameHostMsg_BeforeUnload_ACK(0, false, now, now)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 EXPECT_TRUE(RenderFrameHostImpl::IsRFHStateActive( | 2087 EXPECT_TRUE(RenderFrameHostImpl::IsRFHStateActive( |
| 2117 GetPendingFrameHost(iframe2)->rfh_state())); | 2088 GetPendingFrameHost(iframe2)->rfh_state())); |
| 2118 EXPECT_NE(GetPendingFrameHost(iframe1), GetPendingFrameHost(iframe2)); | 2089 EXPECT_NE(GetPendingFrameHost(iframe1), GetPendingFrameHost(iframe2)); |
| 2119 EXPECT_EQ(GetPendingFrameHost(iframe1)->GetSiteInstance(), | 2090 EXPECT_EQ(GetPendingFrameHost(iframe1)->GetSiteInstance(), |
| 2120 GetPendingFrameHost(iframe2)->GetSiteInstance()); | 2091 GetPendingFrameHost(iframe2)->GetSiteInstance()); |
| 2121 EXPECT_NE(iframe1->current_frame_host(), GetPendingFrameHost(iframe1)); | 2092 EXPECT_NE(iframe1->current_frame_host(), GetPendingFrameHost(iframe1)); |
| 2122 EXPECT_NE(iframe2->current_frame_host(), GetPendingFrameHost(iframe2)); | 2093 EXPECT_NE(iframe2->current_frame_host(), GetPendingFrameHost(iframe2)); |
| 2123 EXPECT_FALSE(contents()->CrossProcessNavigationPending()) | 2094 EXPECT_FALSE(contents()->CrossProcessNavigationPending()) |
| 2124 << "There should be no top-level pending navigation."; | 2095 << "There should be no top-level pending navigation."; |
| 2125 | 2096 |
| 2126 RenderFrameHostDeletedObserver delete_watcher1(GetPendingFrameHost(iframe1)); | 2097 RenderFrameDeletedObserver delete_watcher1(GetPendingFrameHost(iframe1)); |
| 2127 RenderFrameHostDeletedObserver delete_watcher2(GetPendingFrameHost(iframe2)); | 2098 RenderFrameDeletedObserver delete_watcher2(GetPendingFrameHost(iframe2)); |
| 2128 EXPECT_FALSE(delete_watcher1.deleted()); | 2099 EXPECT_FALSE(delete_watcher1.deleted()); |
| 2129 EXPECT_FALSE(delete_watcher2.deleted()); | 2100 EXPECT_FALSE(delete_watcher2.deleted()); |
| 2130 | 2101 |
| 2131 // Keep the SiteInstance alive for testing. | 2102 // Keep the SiteInstance alive for testing. |
| 2132 scoped_refptr<SiteInstanceImpl> site_instance = | 2103 scoped_refptr<SiteInstanceImpl> site_instance = |
| 2133 GetPendingFrameHost(iframe1)->GetSiteInstance(); | 2104 GetPendingFrameHost(iframe1)->GetSiteInstance(); |
| 2134 EXPECT_TRUE(site_instance->HasSite()); | 2105 EXPECT_TRUE(site_instance->HasSite()); |
| 2135 EXPECT_NE(site_instance, contents()->GetSiteInstance()); | 2106 EXPECT_NE(site_instance, contents()->GetSiteInstance()); |
| 2136 EXPECT_EQ(2U, site_instance->active_frame_count()); | 2107 EXPECT_EQ(2U, site_instance->active_frame_count()); |
| 2137 | 2108 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2206 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); |
| 2236 contents2->NavigateAndCommit(kUrl3); | 2207 contents2->NavigateAndCommit(kUrl3); |
| 2237 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2208 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); |
| 2238 EXPECT_NE(nullptr, | 2209 EXPECT_NE(nullptr, |
| 2239 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); | 2210 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); |
| 2240 EXPECT_EQ(nullptr, | 2211 EXPECT_EQ(nullptr, |
| 2241 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); | 2212 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); |
| 2242 } | 2213 } |
| 2243 | 2214 |
| 2244 } // namespace content | 2215 } // namespace content |
| OLD | NEW |