| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 pending_render_view_host()); | 253 pending_render_view_host()); |
| 254 | 254 |
| 255 // Should have a new SiteInstance. | 255 // Should have a new SiteInstance. |
| 256 scoped_refptr<SiteInstance> noref_blank_site_instance( | 256 scoped_refptr<SiteInstance> noref_blank_site_instance( |
| 257 new_shell->web_contents()->GetSiteInstance()); | 257 new_shell->web_contents()->GetSiteInstance()); |
| 258 EXPECT_NE(orig_site_instance, noref_blank_site_instance); | 258 EXPECT_NE(orig_site_instance, noref_blank_site_instance); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Same as above, but for 'noopener' | 261 // Same as above, but for 'noopener' |
| 262 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 262 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 263 SwapProcessWithRelNoopenerAndTargetBlank) { | 263 SwapProcessWithRelNopenerAndTargetBlank) { |
| 264 StartEmbeddedServer(); | 264 StartEmbeddedServer(); |
| 265 | 265 |
| 266 NavigateToPageWithLinks(shell()); | 266 NavigateToPageWithLinks(shell()); |
| 267 | 267 |
| 268 // Get the original SiteInstance for later comparison. | 268 // Get the original SiteInstance for later comparison. |
| 269 scoped_refptr<SiteInstance> orig_site_instance( | 269 scoped_refptr<SiteInstance> orig_site_instance( |
| 270 shell()->web_contents()->GetSiteInstance()); | 270 shell()->web_contents()->GetSiteInstance()); |
| 271 EXPECT_TRUE(orig_site_instance.get() != NULL); | 271 EXPECT_TRUE(orig_site_instance.get() != NULL); |
| 272 | 272 |
| 273 // Test clicking a rel=noreferrer + target=blank link. | 273 // Test clicking a rel=noreferrer + target=blank link. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 284 | 284 |
| 285 EXPECT_EQ("/title2.html", new_shell->web_contents()->GetVisibleURL().path()); | 285 EXPECT_EQ("/title2.html", new_shell->web_contents()->GetVisibleURL().path()); |
| 286 | 286 |
| 287 // Check that `window.opener` is not set. | 287 // Check that `window.opener` is not set. |
| 288 success = false; | 288 success = false; |
| 289 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 289 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 290 new_shell->web_contents(), | 290 new_shell->web_contents(), |
| 291 "window.domAutomationController.send(window.opener == null);", &success)); | 291 "window.domAutomationController.send(window.opener == null);", &success)); |
| 292 EXPECT_TRUE(success); | 292 EXPECT_TRUE(success); |
| 293 | 293 |
| 294 // Check that the referrer is set correctly. | |
| 295 std::string expected_referrer = | |
| 296 embedded_test_server()->GetURL("/click-noreferrer-links.html").spec(); | |
| 297 success = false; | |
| 298 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 299 new_shell, "window.domAutomationController.send(document.referrer == '" + | |
| 300 expected_referrer + "');", | |
| 301 &success)); | |
| 302 EXPECT_TRUE(success); | |
| 303 | |
| 304 // Wait for the cross-site transition in the new tab to finish. | 294 // Wait for the cross-site transition in the new tab to finish. |
| 305 WaitForLoadStop(new_shell->web_contents()); | 295 WaitForLoadStop(new_shell->web_contents()); |
| 306 WebContentsImpl* web_contents = | 296 WebContentsImpl* web_contents = |
| 307 static_cast<WebContentsImpl*>(new_shell->web_contents()); | 297 static_cast<WebContentsImpl*>(new_shell->web_contents()); |
| 308 EXPECT_FALSE( | 298 EXPECT_FALSE( |
| 309 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); | 299 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); |
| 310 | 300 |
| 311 // Should have a new SiteInstance. | 301 // Should have a new SiteInstance. |
| 312 scoped_refptr<SiteInstance> noopener_blank_site_instance( | 302 scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| 313 new_shell->web_contents()->GetSiteInstance()); | 303 new_shell->web_contents()->GetSiteInstance()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 EXPECT_EQ("/title2.html", | 341 EXPECT_EQ("/title2.html", |
| 352 new_shell->web_contents()->GetLastCommittedURL().path()); | 342 new_shell->web_contents()->GetLastCommittedURL().path()); |
| 353 | 343 |
| 354 // Check that `window.opener` is not set. | 344 // Check that `window.opener` is not set. |
| 355 bool success = false; | 345 bool success = false; |
| 356 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 346 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 357 new_shell->web_contents(), | 347 new_shell->web_contents(), |
| 358 "window.domAutomationController.send(window.opener == null);", &success)); | 348 "window.domAutomationController.send(window.opener == null);", &success)); |
| 359 EXPECT_TRUE(success); | 349 EXPECT_TRUE(success); |
| 360 | 350 |
| 361 // Check that the referrer is set correctly. | |
| 362 std::string expected_referrer = | |
| 363 embedded_test_server()->GetURL("/click-noreferrer-links.html").spec(); | |
| 364 success = false; | |
| 365 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 366 new_shell, "window.domAutomationController.send(document.referrer == '" + | |
| 367 expected_referrer + "');", | |
| 368 &success)); | |
| 369 EXPECT_TRUE(success); | |
| 370 | |
| 371 // Should have a new SiteInstance. | 351 // Should have a new SiteInstance. |
| 372 scoped_refptr<SiteInstance> noopener_blank_site_instance( | 352 scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| 373 new_shell->web_contents()->GetSiteInstance()); | 353 new_shell->web_contents()->GetSiteInstance()); |
| 374 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); | 354 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); |
| 375 } | 355 } |
| 376 | 356 |
| 377 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) | 357 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) |
| 378 // for rel=noreferrer links in new windows, even to same site pages and named | 358 // for rel=noreferrer links in new windows, even to same site pages and named |
| 379 // targets. | 359 // targets. |
| 380 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 360 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| (...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 TestNavigationObserver commit_observer(web_contents); | 2750 TestNavigationObserver commit_observer(web_contents); |
| 2771 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); | 2751 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); |
| 2772 commit_observer.Wait(); | 2752 commit_observer.Wait(); |
| 2773 exit_observer.Wait(); | 2753 exit_observer.Wait(); |
| 2774 | 2754 |
| 2775 // Ensure the entry's title hasn't changed after the ignored commit. | 2755 // Ensure the entry's title hasn't changed after the ignored commit. |
| 2776 EXPECT_EQ(title, entry->GetTitle()); | 2756 EXPECT_EQ(title, entry->GetTitle()); |
| 2777 } | 2757 } |
| 2778 | 2758 |
| 2779 } // namespace content | 2759 } // namespace content |
| OLD | NEW |