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 <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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 EXPECT_FALSE(web_contents->GetRenderManagerForTesting()-> | 246 EXPECT_FALSE(web_contents->GetRenderManagerForTesting()-> |
247 pending_render_view_host()); | 247 pending_render_view_host()); |
248 | 248 |
249 // Should have a new SiteInstance (in a new BrowsingInstance). | 249 // Should have a new SiteInstance (in a new BrowsingInstance). |
250 scoped_refptr<SiteInstance> noref_blank_site_instance( | 250 scoped_refptr<SiteInstance> noref_blank_site_instance( |
251 new_shell->web_contents()->GetSiteInstance()); | 251 new_shell->web_contents()->GetSiteInstance()); |
252 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 252 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
253 } | 253 } |
254 | 254 |
255 // Test for crbug.com/24447. Following a cross-site link with just | 255 // Test for crbug.com/24447. Following a cross-site link with just |
256 // target=_blank should not create a new SiteInstance. | 256 // target=_blank should not create a new SiteInstance, unless we |
| 257 // are running in --site-per-process mode. |
257 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 258 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
258 DontSwapProcessWithOnlyTargetBlank) { | 259 DontSwapProcessWithOnlyTargetBlank) { |
259 StartServer(); | 260 StartServer(); |
260 | 261 |
261 // Load a page with links that open in a new window. | 262 // Load a page with links that open in a new window. |
262 std::string replacement_path; | 263 std::string replacement_path; |
263 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 264 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
264 "files/click-noreferrer-links.html", | 265 "files/click-noreferrer-links.html", |
265 foo_host_port_, | 266 foo_host_port_, |
266 &replacement_path)); | 267 &replacement_path)); |
(...skipping 14 matching lines...) Expand all Loading... |
281 EXPECT_TRUE(success); | 282 EXPECT_TRUE(success); |
282 | 283 |
283 // Wait for the window to open. | 284 // Wait for the window to open. |
284 Shell* new_shell = new_shell_observer.GetShell(); | 285 Shell* new_shell = new_shell_observer.GetShell(); |
285 | 286 |
286 // Wait for the cross-site transition in the new tab to finish. | 287 // Wait for the cross-site transition in the new tab to finish. |
287 WaitForLoadStop(new_shell->web_contents()); | 288 WaitForLoadStop(new_shell->web_contents()); |
288 EXPECT_EQ("/files/title2.html", | 289 EXPECT_EQ("/files/title2.html", |
289 new_shell->web_contents()->GetLastCommittedURL().path()); | 290 new_shell->web_contents()->GetLastCommittedURL().path()); |
290 | 291 |
291 // Should have the same SiteInstance. | 292 // Should have the same SiteInstance unless we're in site-per-process mode. |
292 scoped_refptr<SiteInstance> blank_site_instance( | 293 scoped_refptr<SiteInstance> blank_site_instance( |
293 new_shell->web_contents()->GetSiteInstance()); | 294 new_shell->web_contents()->GetSiteInstance()); |
294 EXPECT_EQ(orig_site_instance, blank_site_instance); | 295 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 296 switches::kSitePerProcess)) |
| 297 EXPECT_EQ(orig_site_instance, blank_site_instance); |
| 298 else |
| 299 EXPECT_NE(orig_site_instance, blank_site_instance); |
295 } | 300 } |
296 | 301 |
297 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 302 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
298 // and no target=_blank should not create a new SiteInstance. | 303 // and no target=_blank should not create a new SiteInstance. |
299 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 304 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
300 DontSwapProcessWithOnlyRelNoreferrer) { | 305 DontSwapProcessWithOnlyRelNoreferrer) { |
301 StartServer(); | 306 StartServer(); |
302 | 307 |
303 // Load a page with links that open in a new window. | 308 // Load a page with links that open in a new window. |
304 std::string replacement_path; | 309 std::string replacement_path; |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 // Navigate to url1 and check bindings. | 1467 // Navigate to url1 and check bindings. |
1463 NavigateToURL(new_shell, url1); | 1468 NavigateToURL(new_shell, url1); |
1464 // The navigation should have used the first SiteInstance, otherwise | 1469 // The navigation should have used the first SiteInstance, otherwise |
1465 // |initial_rvh| did not have a chance to be used. | 1470 // |initial_rvh| did not have a chance to be used. |
1466 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); | 1471 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); |
1467 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, | 1472 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, |
1468 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); | 1473 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); |
1469 } | 1474 } |
1470 | 1475 |
1471 } // namespace content | 1476 } // namespace content |
OLD | NEW |