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

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

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Fix some includes Created 5 years, 5 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 "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 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 } else { 2031 } else {
2031 EXPECT_FALSE(rfh_deleted_observer.deleted()); 2032 EXPECT_FALSE(rfh_deleted_observer.deleted());
2032 } 2033 }
2033 } 2034 }
2034 } 2035 }
2035 2036
2036 // Test that a pending RenderFrameHost in a non-root frame tree node is properly 2037 // Test that a pending RenderFrameHost in a non-root frame tree node is properly
2037 // deleted when the node is detached. Motivated by http://crbug.com/441357 and 2038 // deleted when the node is detached. Motivated by http://crbug.com/441357 and
2038 // http://crbug.com/444955. 2039 // http://crbug.com/444955.
2039 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { 2040 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) {
2040 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2041 IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
2041 switches::kSitePerProcess);
2042 2042
2043 const GURL kUrlA("http://www.google.com/"); 2043 const GURL kUrlA("http://www.google.com/");
2044 const GURL kUrlB("http://webkit.org/"); 2044 const GURL kUrlB("http://webkit.org/");
2045 2045
2046 // Create a page with two child frames. 2046 // Create a page with two child frames.
2047 contents()->NavigateAndCommit(kUrlA); 2047 contents()->NavigateAndCommit(kUrlA);
2048 contents()->GetMainFrame()->OnCreateChildFrame( 2048 contents()->GetMainFrame()->OnCreateChildFrame(
2049 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), 2049 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(),
2050 blink::WebTreeScopeType::Document, "frame_name", 2050 blink::WebTreeScopeType::Document, "frame_name",
2051 blink::WebSandboxFlags::None); 2051 blink::WebSandboxFlags::None);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 root_manager->GetRenderFrameProxyHost(site_instance.get())) 2154 root_manager->GetRenderFrameProxyHost(site_instance.get()))
2155 << "Proxies should have been cleaned up"; 2155 << "Proxies should have been cleaned up";
2156 EXPECT_TRUE(site_instance->HasOneRef()) 2156 EXPECT_TRUE(site_instance->HasOneRef())
2157 << "This SiteInstance should be destroyable now."; 2157 << "This SiteInstance should be destroyable now.";
2158 } 2158 }
2159 2159
2160 // Two tabs in the same process crash. The first tab is reloaded, and the second 2160 // Two tabs in the same process crash. The first tab is reloaded, and the second
2161 // tab navigates away without reloading. The second tab's navigation shouldn't 2161 // tab navigates away without reloading. The second tab's navigation shouldn't
2162 // mess with the first tab's content. Motivated by http://crbug.com/473714. 2162 // mess with the first tab's content. Motivated by http://crbug.com/473714.
2163 TEST_F(RenderFrameHostManagerTest, TwoTabsCrashOneReloadsOneLeaves) { 2163 TEST_F(RenderFrameHostManagerTest, TwoTabsCrashOneReloadsOneLeaves) {
2164 base::CommandLine::ForCurrentProcess()->AppendSwitch( 2164 IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
2165 switches::kSitePerProcess);
2166 2165
2167 const GURL kUrl1("http://www.google.com/"); 2166 const GURL kUrl1("http://www.google.com/");
2168 const GURL kUrl2("http://webkit.org/"); 2167 const GURL kUrl2("http://webkit.org/");
2169 const GURL kUrl3("http://whatwg.org/"); 2168 const GURL kUrl3("http://whatwg.org/");
2170 2169
2171 // |contents1| and |contents2| navigate to the same page and then crash. 2170 // |contents1| and |contents2| navigate to the same page and then crash.
2172 TestWebContents* contents1 = contents(); 2171 TestWebContents* contents1 = contents();
2173 scoped_ptr<TestWebContents> contents2( 2172 scoped_ptr<TestWebContents> contents2(
2174 TestWebContents::Create(browser_context(), contents1->GetSiteInstance())); 2173 TestWebContents::Create(browser_context(), contents1->GetSiteInstance()));
2175 contents1->NavigateAndCommit(kUrl1); 2174 contents1->NavigateAndCommit(kUrl1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); 2215 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive());
2217 contents2->NavigateAndCommit(kUrl3); 2216 contents2->NavigateAndCommit(kUrl3);
2218 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); 2217 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive());
2219 EXPECT_NE(nullptr, 2218 EXPECT_NE(nullptr,
2220 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); 2219 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance()));
2221 EXPECT_EQ(nullptr, 2220 EXPECT_EQ(nullptr,
2222 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); 2221 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance()));
2223 } 2222 }
2224 2223
2225 } // namespace content 2224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698