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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 2067993002: Revert of Do not suppress referrers for '<a ... rel="noopener">'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 SwapProcessWithRelNoopenerAndTargetBlank) { 315 SwapProcessWithRelNopenerAndTargetBlank) {
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
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
356 // Wait for the cross-site transition in the new tab to finish. 346 // Wait for the cross-site transition in the new tab to finish.
357 WaitForLoadStop(new_shell->web_contents()); 347 WaitForLoadStop(new_shell->web_contents());
358 WebContentsImpl* web_contents = 348 WebContentsImpl* web_contents =
359 static_cast<WebContentsImpl*>(new_shell->web_contents()); 349 static_cast<WebContentsImpl*>(new_shell->web_contents());
360 EXPECT_FALSE( 350 EXPECT_FALSE(
361 web_contents->GetRenderManagerForTesting()->pending_render_view_host()); 351 web_contents->GetRenderManagerForTesting()->pending_render_view_host());
362 352
363 // Should have a new SiteInstance. 353 // Should have a new SiteInstance.
364 scoped_refptr<SiteInstance> noopener_blank_site_instance( 354 scoped_refptr<SiteInstance> noopener_blank_site_instance(
365 new_shell->web_contents()->GetSiteInstance()); 355 new_shell->web_contents()->GetSiteInstance());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 EXPECT_EQ("/title2.html", 393 EXPECT_EQ("/title2.html",
404 new_shell->web_contents()->GetLastCommittedURL().path()); 394 new_shell->web_contents()->GetLastCommittedURL().path());
405 395
406 // Check that `window.opener` is not set. 396 // Check that `window.opener` is not set.
407 bool success = false; 397 bool success = false;
408 EXPECT_TRUE(ExecuteScriptAndExtractBool( 398 EXPECT_TRUE(ExecuteScriptAndExtractBool(
409 new_shell, "window.domAutomationController.send(window.opener == null);", 399 new_shell, "window.domAutomationController.send(window.opener == null);",
410 &success)); 400 &success));
411 EXPECT_TRUE(success); 401 EXPECT_TRUE(success);
412 402
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
423 // Should have a new SiteInstance. 403 // Should have a new SiteInstance.
424 scoped_refptr<SiteInstance> noopener_blank_site_instance( 404 scoped_refptr<SiteInstance> noopener_blank_site_instance(
425 new_shell->web_contents()->GetSiteInstance()); 405 new_shell->web_contents()->GetSiteInstance());
426 EXPECT_NE(orig_site_instance, noopener_blank_site_instance); 406 EXPECT_NE(orig_site_instance, noopener_blank_site_instance);
427 } 407 }
428 408
429 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance) 409 // As of crbug.com/69267, we create a new BrowsingInstance (and SiteInstance)
430 // for rel=noreferrer links in new windows, even to same site pages and named 410 // for rel=noreferrer links in new windows, even to same site pages and named
431 // targets. 411 // targets.
432 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 412 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 TestNavigationObserver commit_observer(web_contents); 2790 TestNavigationObserver commit_observer(web_contents);
2811 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html")); 2791 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title1.html"));
2812 commit_observer.Wait(); 2792 commit_observer.Wait();
2813 exit_observer.Wait(); 2793 exit_observer.Wait();
2814 2794
2815 // Ensure the entry's title hasn't changed after the ignored commit. 2795 // Ensure the entry's title hasn't changed after the ignored commit.
2816 EXPECT_EQ(title, entry->GetTitle()); 2796 EXPECT_EQ(title, entry->GetTitle());
2817 } 2797 }
2818 2798
2819 } // namespace content 2799 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698