| 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
" |
| 11 #include "content/browser/frame_host/cross_site_transferring_request.h" | 11 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 12 #include "content/browser/frame_host/navigation_controller_impl.h" | 12 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 13 #include "content/browser/frame_host/navigation_entry_impl.h" | 13 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 14 #include "content/browser/frame_host/navigation_request.h" | 14 #include "content/browser/frame_host/navigation_request.h" |
| 15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
| 16 #include "content/browser/frame_host/render_frame_host_manager.h" | 16 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 17 #include "content/browser/frame_host/render_frame_proxy_host.h" | 17 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 18 #include "content/browser/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
| 19 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 19 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 20 #include "content/common/frame_messages.h" | 20 #include "content/common/frame_messages.h" |
| 21 #include "content/common/site_isolation_policy.h" |
| 21 #include "content/common/view_messages.h" | 22 #include "content/common/view_messages.h" |
| 22 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/render_widget_host_iterator.h" | 28 #include "content/public/browser/render_widget_host_iterator.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 29 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "content/public/browser/web_contents_observer.h" | 30 #include "content/public/browser/web_contents_observer.h" |
| 30 #include "content/public/browser/web_ui_controller.h" | 31 #include "content/public/browser/web_ui_controller.h" |
| (...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 } else { | 2029 } else { |
| 2029 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 2030 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
| 2030 } | 2031 } |
| 2031 } | 2032 } |
| 2032 } | 2033 } |
| 2033 | 2034 |
| 2034 // Test that a pending RenderFrameHost in a non-root frame tree node is properly | 2035 // Test that a pending RenderFrameHost in a non-root frame tree node is properly |
| 2035 // deleted when the node is detached. Motivated by http://crbug.com/441357 and | 2036 // deleted when the node is detached. Motivated by http://crbug.com/441357 and |
| 2036 // http://crbug.com/444955. | 2037 // http://crbug.com/444955. |
| 2037 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { | 2038 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { |
| 2038 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 2039 IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess()); |
| 2039 switches::kSitePerProcess); | |
| 2040 | 2040 |
| 2041 const GURL kUrlA("http://www.google.com/"); | 2041 const GURL kUrlA("http://www.google.com/"); |
| 2042 const GURL kUrlB("http://webkit.org/"); | 2042 const GURL kUrlB("http://webkit.org/"); |
| 2043 | 2043 |
| 2044 // Create a page with two child frames. | 2044 // Create a page with two child frames. |
| 2045 contents()->NavigateAndCommit(kUrlA); | 2045 contents()->NavigateAndCommit(kUrlA); |
| 2046 contents()->GetMainFrame()->OnCreateChildFrame( | 2046 contents()->GetMainFrame()->OnCreateChildFrame( |
| 2047 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), | 2047 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), |
| 2048 blink::WebTreeScopeType::Document, "frame_name", | 2048 blink::WebTreeScopeType::Document, "frame_name", |
| 2049 blink::WebSandboxFlags::None); | 2049 blink::WebSandboxFlags::None); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 root_manager->GetRenderFrameProxyHost(site_instance.get())) | 2152 root_manager->GetRenderFrameProxyHost(site_instance.get())) |
| 2153 << "Proxies should have been cleaned up"; | 2153 << "Proxies should have been cleaned up"; |
| 2154 EXPECT_TRUE(site_instance->HasOneRef()) | 2154 EXPECT_TRUE(site_instance->HasOneRef()) |
| 2155 << "This SiteInstance should be destroyable now."; | 2155 << "This SiteInstance should be destroyable now."; |
| 2156 } | 2156 } |
| 2157 | 2157 |
| 2158 // Two tabs in the same process crash. The first tab is reloaded, and the second | 2158 // Two tabs in the same process crash. The first tab is reloaded, and the second |
| 2159 // tab navigates away without reloading. The second tab's navigation shouldn't | 2159 // tab navigates away without reloading. The second tab's navigation shouldn't |
| 2160 // mess with the first tab's content. Motivated by http://crbug.com/473714. | 2160 // mess with the first tab's content. Motivated by http://crbug.com/473714. |
| 2161 TEST_F(RenderFrameHostManagerTest, TwoTabsCrashOneReloadsOneLeaves) { | 2161 TEST_F(RenderFrameHostManagerTest, TwoTabsCrashOneReloadsOneLeaves) { |
| 2162 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 2162 IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess()); |
| 2163 switches::kSitePerProcess); | |
| 2164 | 2163 |
| 2165 const GURL kUrl1("http://www.google.com/"); | 2164 const GURL kUrl1("http://www.google.com/"); |
| 2166 const GURL kUrl2("http://webkit.org/"); | 2165 const GURL kUrl2("http://webkit.org/"); |
| 2167 const GURL kUrl3("http://whatwg.org/"); | 2166 const GURL kUrl3("http://whatwg.org/"); |
| 2168 | 2167 |
| 2169 // |contents1| and |contents2| navigate to the same page and then crash. | 2168 // |contents1| and |contents2| navigate to the same page and then crash. |
| 2170 TestWebContents* contents1 = contents(); | 2169 TestWebContents* contents1 = contents(); |
| 2171 scoped_ptr<TestWebContents> contents2( | 2170 scoped_ptr<TestWebContents> contents2( |
| 2172 TestWebContents::Create(browser_context(), contents1->GetSiteInstance())); | 2171 TestWebContents::Create(browser_context(), contents1->GetSiteInstance())); |
| 2173 contents1->NavigateAndCommit(kUrl1); | 2172 contents1->NavigateAndCommit(kUrl1); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2213 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); |
| 2215 contents2->NavigateAndCommit(kUrl3); | 2214 contents2->NavigateAndCommit(kUrl3); |
| 2216 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2215 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); |
| 2217 EXPECT_NE(nullptr, | 2216 EXPECT_NE(nullptr, |
| 2218 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); | 2217 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); |
| 2219 EXPECT_EQ(nullptr, | 2218 EXPECT_EQ(nullptr, |
| 2220 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); | 2219 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); |
| 2221 } | 2220 } |
| 2222 | 2221 |
| 2223 } // namespace content | 2222 } // namespace content |
| OLD | NEW |