| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 pending_render_view_host()); | 305 pending_render_view_host()); |
| 306 | 306 |
| 307 // Should have a new SiteInstance. | 307 // Should have a new SiteInstance. |
| 308 scoped_refptr<SiteInstance> noref_blank_site_instance( | 308 scoped_refptr<SiteInstance> noref_blank_site_instance( |
| 309 new_shell->web_contents()->GetSiteInstance()); | 309 new_shell->web_contents()->GetSiteInstance()); |
| 310 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 310 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // Same as above, but for 'noopener' | 313 // Same as above, but for 'noopener' |
| 314 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 314 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 315 SwapProcessWithRelNopenerAndTargetBlank) { | 315 SwapProcessWithRelNoopenerAndTargetBlank) { |
| 316 StartEmbeddedServer(); | 316 StartEmbeddedServer(); |
| 317 | 317 |
| 318 NavigateToPageWithLinks(shell()); | 318 NavigateToPageWithLinks(shell()); |
| 319 | 319 |
| 320 // Get the original SiteInstance for later comparison. | 320 // Get the original SiteInstance for later comparison. |
| 321 scoped_refptr<SiteInstance> orig_site_instance( | 321 scoped_refptr<SiteInstance> orig_site_instance( |
| 322 shell()->web_contents()->GetSiteInstance()); | 322 shell()->web_contents()->GetSiteInstance()); |
| 323 EXPECT_TRUE(orig_site_instance.get() != NULL); | 323 EXPECT_TRUE(orig_site_instance.get() != NULL); |
| 324 | 324 |
| 325 // Test clicking a rel=noreferrer + target=blank link. | 325 // Test clicking a rel=noreferrer + target=blank link. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 336 | 336 |
| 337 EXPECT_EQ("/title2.html", new_shell->web_contents()->GetVisibleURL().path()); | 337 EXPECT_EQ("/title2.html", new_shell->web_contents()->GetVisibleURL().path()); |
| 338 | 338 |
| 339 // Check that `window.opener` is not set. | 339 // Check that `window.opener` is not set. |
| 340 success = false; | 340 success = false; |
| 341 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 341 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 342 new_shell, "window.domAutomationController.send(window.opener == null);", | 342 new_shell, "window.domAutomationController.send(window.opener == null);", |
| 343 &success)); | 343 &success)); |
| 344 EXPECT_TRUE(success); | 344 EXPECT_TRUE(success); |
| 345 | 345 |
| 346 // Check that the referrer is set correctly. |
| 347 std::string expected_referrer = |
| 348 embedded_test_server()->GetURL("/click-noreferrer-links.html").spec(); |
| 349 success = false; |
| 350 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 351 new_shell, "window.domAutomationController.send(document.referrer == '" + |
| 352 expected_referrer + "');", |
| 353 &success)); |
| 354 EXPECT_TRUE(success); |
| 355 |
| 346 // Wait for the cross-site transition in the new tab to finish. | 356 // Wait for the cross-site transition in the new tab to finish. |
| 347 WaitForLoadStop(new_shell->web_contents()); | 357 WaitForLoadStop(new_shell->web_contents()); |
| 348 WebContentsImpl* web_contents = | 358 WebContentsImpl* web_contents = |
| 349 static_cast<WebContentsImpl*>(new_shell->web_contents()); | 359 static_cast<WebContentsImpl*>(new_shell->web_contents()); |
| 350 EXPECT_FALSE( | 360 EXPECT_FALSE( |
| 351 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); | 361 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); |
| 352 | 362 |
| 353 // Should have a new SiteInstance. | 363 // Should have a new SiteInstance. |
| 354 scoped_refptr<SiteInstance> noopener_blank_site_instance( | 364 scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| 355 new_shell->web_contents()->GetSiteInstance()); | 365 new_shell->web_contents()->GetSiteInstance()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 EXPECT_EQ("/title2.html", | 403 EXPECT_EQ("/title2.html", |
| 394 new_shell->web_contents()->GetLastCommittedURL().path()); | 404 new_shell->web_contents()->GetLastCommittedURL().path()); |
| 395 | 405 |
| 396 // Check that `window.opener` is not set. | 406 // Check that `window.opener` is not set. |
| 397 bool success = false; | 407 bool success = false; |
| 398 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 408 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 399 new_shell, "window.domAutomationController.send(window.opener == null);", | 409 new_shell, "window.domAutomationController.send(window.opener == null);", |
| 400 &success)); | 410 &success)); |
| 401 EXPECT_TRUE(success); | 411 EXPECT_TRUE(success); |
| 402 | 412 |
| 413 // Check that the referrer is set correctly. |
| 414 std::string expected_referrer = |
| 415 embedded_test_server()->GetURL("/click-noreferrer-links.html").spec(); |
| 416 success = false; |
| 417 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 418 new_shell, "window.domAutomationController.send(document.referrer == '" + |
| 419 expected_referrer + "');", |
| 420 &success)); |
| 421 EXPECT_TRUE(success); |
| 422 |
| 403 // Should have a new SiteInstance. | 423 // Should have a new SiteInstance. |
| 404 scoped_refptr<SiteInstance> noopener_blank_site_instance( | 424 scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| 405 new_shell->web_contents()->GetSiteInstance()); | 425 new_shell->web_contents()->GetSiteInstance()); |
| 406 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); | 426 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); |
| 407 } | 427 } |
| 408 | 428 |
| 409 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) | 429 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) |
| 410 // for rel=noreferrer links in new windows, even to same site pages and named | 430 // for rel=noreferrer links in new windows, even to same site pages and named |
| 411 // targets. | 431 // targets. |
| 412 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 432 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| (...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2790 TestNavigationObserver commit_observer(web_contents); | 2810 TestNavigationObserver commit_observer(web_contents); |
| 2791 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); | 2811 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); |
| 2792 commit_observer.Wait(); | 2812 commit_observer.Wait(); |
| 2793 exit_observer.Wait(); | 2813 exit_observer.Wait(); |
| 2794 | 2814 |
| 2795 // Ensure the entry's title hasn't changed after the ignored commit. | 2815 // Ensure the entry's title hasn't changed after the ignored commit. |
| 2796 EXPECT_EQ(title, entry->GetTitle()); | 2816 EXPECT_EQ(title, entry->GetTitle()); |
| 2797 } | 2817 } |
| 2798 | 2818 |
| 2799 } // namespace content | 2819 } // namespace content |
| OLD | NEW |