| 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 SwapProcessWithRelNopenerAndTargetBlank) { | 263 SwapProcessWithRelNoopenerAndTargetBlank) { |
| 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 |
| 294 // Wait for the cross-site transition in the new tab to finish. | 304 // Wait for the cross-site transition in the new tab to finish. |
| 295 WaitForLoadStop(new_shell->web_contents()); | 305 WaitForLoadStop(new_shell->web_contents()); |
| 296 WebContentsImpl* web_contents = | 306 WebContentsImpl* web_contents = |
| 297 static_cast<WebContentsImpl*>(new_shell->web_contents()); | 307 static_cast<WebContentsImpl*>(new_shell->web_contents()); |
| 298 EXPECT_FALSE( | 308 EXPECT_FALSE( |
| 299 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); | 309 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); |
| 300 | 310 |
| 301 // Should have a new SiteInstance. | 311 // Should have a new SiteInstance. |
| 302 scoped_refptr<SiteInstance> noopener_blank_site_instance( | 312 scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| 303 new_shell->web_contents()->GetSiteInstance()); | 313 new_shell->web_contents()->GetSiteInstance()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 EXPECT_EQ("/title2.html", | 351 EXPECT_EQ("/title2.html", |
| 342 new_shell->web_contents()->GetLastCommittedURL().path()); | 352 new_shell->web_contents()->GetLastCommittedURL().path()); |
| 343 | 353 |
| 344 // Check that `window.opener` is not set. | 354 // Check that `window.opener` is not set. |
| 345 bool success = false; | 355 bool success = false; |
| 346 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 356 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 347 new_shell->web_contents(), | 357 new_shell->web_contents(), |
| 348 "window.domAutomationController.send(window.opener == null);", &success)); | 358 "window.domAutomationController.send(window.opener == null);", &success)); |
| 349 EXPECT_TRUE(success); | 359 EXPECT_TRUE(success); |
| 350 | 360 |
| 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 |
| 351 // Should have a new SiteInstance. | 371 // Should have a new SiteInstance. |
| 352 scoped_refptr<SiteInstance> noopener_blank_site_instance( | 372 scoped_refptr<SiteInstance> noopener_blank_site_instance( |
| 353 new_shell->web_contents()->GetSiteInstance()); | 373 new_shell->web_contents()->GetSiteInstance()); |
| 354 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); | 374 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); |
| 355 } | 375 } |
| 356 | 376 |
| 357 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) | 377 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) |
| 358 // for rel=noreferrer links in new windows, even to same site pages and named | 378 // for rel=noreferrer links in new windows, even to same site pages and named |
| 359 // targets. | 379 // targets. |
| 360 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 380 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| (...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2750 TestNavigationObserver commit_observer(web_contents); | 2770 TestNavigationObserver commit_observer(web_contents); |
| 2751 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); | 2771 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); |
| 2752 commit_observer.Wait(); | 2772 commit_observer.Wait(); |
| 2753 exit_observer.Wait(); | 2773 exit_observer.Wait(); |
| 2754 | 2774 |
| 2755 // Ensure the entry's title hasn't changed after the ignored commit. | 2775 // Ensure the entry's title hasn't changed after the ignored commit. |
| 2756 EXPECT_EQ(title, entry->GetTitle()); | 2776 EXPECT_EQ(title, entry->GetTitle()); |
| 2757 } | 2777 } |
| 2758 | 2778 |
| 2759 } // namespace content | 2779 } // namespace content |
| OLD | NEW |