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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.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: Partial fixes to Nasko's comments. 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 <set> 5 #include <set>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/public/browser/navigation_controller.h" 23 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_observer.h" 27 #include "content/public/browser/web_contents_observer.h"
28 #include "content/public/common/bindings_policy.h" 28 #include "content/public/common/bindings_policy.h"
29 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
30 #include "content/public/common/file_chooser_file_info.h" 30 #include "content/public/common/file_chooser_file_info.h"
31 #include "content/public/common/file_chooser_params.h" 31 #include "content/public/common/file_chooser_params.h"
32 #include "content/public/common/page_state.h" 32 #include "content/public/common/page_state.h"
33 #include "content/public/common/site_isolation_policy.h"
33 #include "content/public/common/url_constants.h" 34 #include "content/public/common/url_constants.h"
34 #include "content/public/test/browser_test_utils.h" 35 #include "content/public/test/browser_test_utils.h"
35 #include "content/public/test/content_browser_test.h" 36 #include "content/public/test/content_browser_test.h"
36 #include "content/public/test/content_browser_test_utils.h" 37 #include "content/public/test/content_browser_test_utils.h"
37 #include "content/public/test/test_navigation_observer.h" 38 #include "content/public/test/test_navigation_observer.h"
38 #include "content/public/test/test_utils.h" 39 #include "content/public/test/test_utils.h"
39 #include "content/shell/browser/shell.h" 40 #include "content/shell/browser/shell.h"
40 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
41 #include "net/dns/mock_host_resolver.h" 42 #include "net/dns/mock_host_resolver.h"
42 #include "net/test/embedded_test_server/embedded_test_server.h" 43 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 Shell* new_shell = new_shell_observer.GetShell(); 335 Shell* new_shell = new_shell_observer.GetShell();
335 336
336 // Wait for the cross-site transition in the new tab to finish. 337 // Wait for the cross-site transition in the new tab to finish.
337 EXPECT_TRUE(WaitForLoadStop(new_shell->web_contents())); 338 EXPECT_TRUE(WaitForLoadStop(new_shell->web_contents()));
338 EXPECT_EQ("/files/title2.html", 339 EXPECT_EQ("/files/title2.html",
339 new_shell->web_contents()->GetLastCommittedURL().path()); 340 new_shell->web_contents()->GetLastCommittedURL().path());
340 341
341 // Should have the same SiteInstance unless we're in site-per-process mode. 342 // Should have the same SiteInstance unless we're in site-per-process mode.
342 scoped_refptr<SiteInstance> blank_site_instance( 343 scoped_refptr<SiteInstance> blank_site_instance(
343 new_shell->web_contents()->GetSiteInstance()); 344 new_shell->web_contents()->GetSiteInstance());
344 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 345 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting())
345 switches::kSitePerProcess)) 346 EXPECT_NE(orig_site_instance, blank_site_instance);
347 else
346 EXPECT_EQ(orig_site_instance, blank_site_instance); 348 EXPECT_EQ(orig_site_instance, blank_site_instance);
347 else
348 EXPECT_NE(orig_site_instance, blank_site_instance);
349 } 349 }
350 350
351 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer 351 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
352 // and no target=_blank should not create a new SiteInstance. 352 // and no target=_blank should not create a new SiteInstance.
353 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 353 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
354 DontSwapProcessWithOnlyRelNoreferrer) { 354 DontSwapProcessWithOnlyRelNoreferrer) {
355 StartServer(); 355 StartServer();
356 356
357 // Load a page with links that open in a new window. 357 // Load a page with links that open in a new window.
358 std::string replacement_path; 358 std::string replacement_path;
(...skipping 20 matching lines...) Expand all
379 WaitForLoadStop(shell()->web_contents()); 379 WaitForLoadStop(shell()->web_contents());
380 380
381 // Opens in same window. 381 // Opens in same window.
382 EXPECT_EQ(1u, Shell::windows().size()); 382 EXPECT_EQ(1u, Shell::windows().size());
383 EXPECT_EQ("/files/title2.html", 383 EXPECT_EQ("/files/title2.html",
384 shell()->web_contents()->GetLastCommittedURL().path()); 384 shell()->web_contents()->GetLastCommittedURL().path());
385 385
386 // Should have the same SiteInstance unless we're in site-per-process mode. 386 // Should have the same SiteInstance unless we're in site-per-process mode.
387 scoped_refptr<SiteInstance> noref_site_instance( 387 scoped_refptr<SiteInstance> noref_site_instance(
388 shell()->web_contents()->GetSiteInstance()); 388 shell()->web_contents()->GetSiteInstance());
389 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 389 if (SiteIsolationPolicy::AreAllSitesIsolatedForTesting())
390 switches::kSitePerProcess)) 390 EXPECT_NE(orig_site_instance, noref_site_instance);
391 else
391 EXPECT_EQ(orig_site_instance, noref_site_instance); 392 EXPECT_EQ(orig_site_instance, noref_site_instance);
392 else
393 EXPECT_NE(orig_site_instance, noref_site_instance);
394 } 393 }
395 394
396 // Test for crbug.com/116192. Targeted links should still work after the 395 // Test for crbug.com/116192. Targeted links should still work after the
397 // named target window has swapped processes. 396 // named target window has swapped processes.
398 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 397 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
399 AllowTargetedNavigationsAfterSwap) { 398 AllowTargetedNavigationsAfterSwap) {
400 StartServer(); 399 StartServer();
401 400
402 // Load a page with links that open in a new window. 401 // Load a page with links that open in a new window.
403 std::string replacement_path; 402 std::string replacement_path;
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 EXPECT_FALSE(opener_rfph->is_render_frame_proxy_live()); 1922 EXPECT_FALSE(opener_rfph->is_render_frame_proxy_live());
1924 1923
1925 // Re-navigate the popup to the same URL and check that this recreates the 1924 // Re-navigate the popup to the same URL and check that this recreates the
1926 // opener's swapped out RVH and proxy in the foo.com SiteInstance. 1925 // opener's swapped out RVH and proxy in the foo.com SiteInstance.
1927 EXPECT_TRUE(NavigateToURL(new_shell, cross_site_url)); 1926 EXPECT_TRUE(NavigateToURL(new_shell, cross_site_url));
1928 EXPECT_TRUE(opener_rvh->IsRenderViewLive()); 1927 EXPECT_TRUE(opener_rvh->IsRenderViewLive());
1929 EXPECT_TRUE(opener_rfph->is_render_frame_proxy_live()); 1928 EXPECT_TRUE(opener_rfph->is_render_frame_proxy_live());
1930 } 1929 }
1931 1930
1932 } // namespace content 1931 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698