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

Side by Side Diff: content/browser/renderer_host/render_view_host_manager_browsertest.cc

Issue 9325082: Create window in a new BrowsingInstance when opening a link in a new process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix line break Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 browser()->GetSelectedWebContents()); 91 browser()->GetSelectedWebContents());
92 EXPECT_FALSE(tab_contents->GetRenderManagerForTesting()-> 92 EXPECT_FALSE(tab_contents->GetRenderManagerForTesting()->
93 pending_render_view_host()); 93 pending_render_view_host());
94 94
95 // Should have a new SiteInstance. 95 // Should have a new SiteInstance.
96 scoped_refptr<SiteInstance> noref_blank_site_instance( 96 scoped_refptr<SiteInstance> noref_blank_site_instance(
97 browser()->GetSelectedWebContents()->GetSiteInstance()); 97 browser()->GetSelectedWebContents()->GetSiteInstance());
98 EXPECT_NE(orig_site_instance, noref_blank_site_instance); 98 EXPECT_NE(orig_site_instance, noref_blank_site_instance);
99 } 99 }
100 100
101 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance)
102 // for rel=noreferrer links in new windows, even to same site pages and named
103 // targets.
104 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
105 SwapProcessWithSameSiteRelNoreferrer) {
106 // Start two servers with different sites.
107 ASSERT_TRUE(test_server()->Start());
108 net::TestServer https_server(
109 net::TestServer::TYPE_HTTPS,
110 net::TestServer::kLocalhost,
111 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
112 ASSERT_TRUE(https_server.Start());
113
114 // Load a page with links that open in a new window.
115 std::string replacement_path;
116 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
117 "files/click-noreferrer-links.html",
118 https_server.host_port_pair(),
119 &replacement_path));
120 ui_test_utils::NavigateToURL(browser(),
121 test_server()->GetURL(replacement_path));
122
123 // Get the original SiteInstance for later comparison.
124 scoped_refptr<SiteInstance> orig_site_instance(
125 browser()->GetSelectedWebContents()->GetSiteInstance());
126 EXPECT_TRUE(orig_site_instance != NULL);
127
128 // Test clicking a same-site rel=noreferrer + target=foo link.
129 bool success = false;
130 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
131 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
132 L"window.domAutomationController.send(clickSameSiteNoRefTargetedLink());",
133 &success));
134 EXPECT_TRUE(success);
135
136 // Wait for the tab to open.
137 if (browser()->tab_count() < 2)
138 ui_test_utils::WaitForNewTab(browser());
139
140 // Opens in new tab.
141 EXPECT_EQ(2, browser()->tab_count());
142 EXPECT_EQ(1, browser()->active_index());
143 EXPECT_EQ("/files/title2.html",
144 browser()->GetSelectedWebContents()->GetURL().path());
145
146 // Wait for the cross-site transition in the new tab to finish.
147 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents());
148 TabContents* tab_contents = static_cast<TabContents*>(
149 browser()->GetSelectedWebContents());
150 EXPECT_FALSE(tab_contents->GetRenderManagerForTesting()->
151 pending_render_view_host());
152
153 // Should have a new SiteInstance (in a new BrowsingInstance).
154 scoped_refptr<SiteInstance> noref_blank_site_instance(
155 browser()->GetSelectedWebContents()->GetSiteInstance());
156 EXPECT_NE(orig_site_instance, noref_blank_site_instance);
157 }
158
101 // Test for crbug.com/24447. Following a cross-site link with just 159 // Test for crbug.com/24447. Following a cross-site link with just
102 // target=_blank should not create a new SiteInstance. 160 // target=_blank should not create a new SiteInstance.
103 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 161 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
104 DontSwapProcessWithOnlyTargetBlank) { 162 DontSwapProcessWithOnlyTargetBlank) {
105 // Start two servers with different sites. 163 // Start two servers with different sites.
106 ASSERT_TRUE(test_server()->Start()); 164 ASSERT_TRUE(test_server()->Start());
107 net::TestServer https_server( 165 net::TestServer https_server(
108 net::TestServer::TYPE_HTTPS, 166 net::TestServer::TYPE_HTTPS,
109 net::TestServer::kLocalhost, 167 net::TestServer::kLocalhost,
110 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 168 FilePath(FILE_PATH_LITERAL("chrome/test/data")));
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 // Now navigate to a different instance so that we swap out again. 522 // Now navigate to a different instance so that we swap out again.
465 ui_test_utils::NavigateToURL(browser(), 523 ui_test_utils::NavigateToURL(browser(),
466 https_server.GetURL("files/title2.html")); 524 https_server.GetURL("files/title2.html"));
467 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()-> 525 rvh_observers.AddObserverToRVH(browser()->GetSelectedWebContents()->
468 GetRenderViewHost()); 526 GetRenderViewHost());
469 527
470 // This used to leak a render view host. 528 // This used to leak a render view host.
471 browser()->CloseTabContents(browser()->GetSelectedWebContents()); 529 browser()->CloseTabContents(browser()->GetSelectedWebContents());
472 EXPECT_EQ(0U, rvh_observers.GetNumObservers()); 530 EXPECT_EQ(0U, rvh_observers.GetNumObservers());
473 } 531 }
OLDNEW
« no previous file with comments | « chrome/test/data/click-noreferrer-links.html ('k') | content/browser/renderer_host/render_widget_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698