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

Side by Side Diff: content/browser/renderer_host/render_view_host_manager_browsertest.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/browser/renderer_host/render_view_host_impl.h" 10 #include "content/browser/renderer_host/render_view_host_impl.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 std::string replacement_path; 62 std::string replacement_path;
63 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 63 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
64 "files/click-noreferrer-links.html", 64 "files/click-noreferrer-links.html",
65 https_server.host_port_pair(), 65 https_server.host_port_pair(),
66 &replacement_path)); 66 &replacement_path));
67 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 67 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
68 68
69 // Get the original SiteInstance for later comparison. 69 // Get the original SiteInstance for later comparison.
70 scoped_refptr<SiteInstance> orig_site_instance( 70 scoped_refptr<SiteInstance> orig_site_instance(
71 shell()->web_contents()->GetSiteInstance()); 71 shell()->web_contents()->GetSiteInstance());
72 EXPECT_TRUE(orig_site_instance != NULL); 72 EXPECT_TRUE(orig_site_instance.get() != NULL);
73 73
74 // Open a same-site link in a new window. 74 // Open a same-site link in a new window.
75 ShellAddedObserver new_shell_observer; 75 ShellAddedObserver new_shell_observer;
76 bool success = false; 76 bool success = false;
77 EXPECT_TRUE(ExecuteScriptAndExtractBool( 77 EXPECT_TRUE(ExecuteScriptAndExtractBool(
78 shell()->web_contents(), 78 shell()->web_contents(),
79 "window.domAutomationController.send(clickSameSiteTargetedLink());", 79 "window.domAutomationController.send(clickSameSiteTargetedLink());",
80 &success)); 80 &success));
81 EXPECT_TRUE(success); 81 EXPECT_TRUE(success);
82 Shell* new_shell = new_shell_observer.GetShell(); 82 Shell* new_shell = new_shell_observer.GetShell();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 std::string replacement_path; 130 std::string replacement_path;
131 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 131 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
132 "files/click-noreferrer-links.html", 132 "files/click-noreferrer-links.html",
133 https_server.host_port_pair(), 133 https_server.host_port_pair(),
134 &replacement_path)); 134 &replacement_path));
135 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 135 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
136 136
137 // Get the original SiteInstance for later comparison. 137 // Get the original SiteInstance for later comparison.
138 scoped_refptr<SiteInstance> orig_site_instance( 138 scoped_refptr<SiteInstance> orig_site_instance(
139 shell()->web_contents()->GetSiteInstance()); 139 shell()->web_contents()->GetSiteInstance());
140 EXPECT_TRUE(orig_site_instance != NULL); 140 EXPECT_TRUE(orig_site_instance.get() != NULL);
141 141
142 // Test clicking a rel=noreferrer + target=blank link. 142 // Test clicking a rel=noreferrer + target=blank link.
143 ShellAddedObserver new_shell_observer; 143 ShellAddedObserver new_shell_observer;
144 bool success = false; 144 bool success = false;
145 EXPECT_TRUE(ExecuteScriptAndExtractBool( 145 EXPECT_TRUE(ExecuteScriptAndExtractBool(
146 shell()->web_contents(), 146 shell()->web_contents(),
147 "window.domAutomationController.send(clickNoRefTargetBlankLink());", 147 "window.domAutomationController.send(clickNoRefTargetBlankLink());",
148 &success)); 148 &success));
149 EXPECT_TRUE(success); 149 EXPECT_TRUE(success);
150 150
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 std::string replacement_path; 183 std::string replacement_path;
184 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 184 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
185 "files/click-noreferrer-links.html", 185 "files/click-noreferrer-links.html",
186 https_server.host_port_pair(), 186 https_server.host_port_pair(),
187 &replacement_path)); 187 &replacement_path));
188 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 188 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
189 189
190 // Get the original SiteInstance for later comparison. 190 // Get the original SiteInstance for later comparison.
191 scoped_refptr<SiteInstance> orig_site_instance( 191 scoped_refptr<SiteInstance> orig_site_instance(
192 shell()->web_contents()->GetSiteInstance()); 192 shell()->web_contents()->GetSiteInstance());
193 EXPECT_TRUE(orig_site_instance != NULL); 193 EXPECT_TRUE(orig_site_instance.get() != NULL);
194 194
195 // Test clicking a same-site rel=noreferrer + target=foo link. 195 // Test clicking a same-site rel=noreferrer + target=foo link.
196 ShellAddedObserver new_shell_observer; 196 ShellAddedObserver new_shell_observer;
197 bool success = false; 197 bool success = false;
198 EXPECT_TRUE(ExecuteScriptAndExtractBool( 198 EXPECT_TRUE(ExecuteScriptAndExtractBool(
199 shell()->web_contents(), 199 shell()->web_contents(),
200 "window.domAutomationController.send(clickSameSiteNoRefTargetedLink());", 200 "window.domAutomationController.send(clickSameSiteNoRefTargetedLink());",
201 &success)); 201 &success));
202 EXPECT_TRUE(success); 202 EXPECT_TRUE(success);
203 203
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 std::string replacement_path; 236 std::string replacement_path;
237 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 237 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
238 "files/click-noreferrer-links.html", 238 "files/click-noreferrer-links.html",
239 https_server.host_port_pair(), 239 https_server.host_port_pair(),
240 &replacement_path)); 240 &replacement_path));
241 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 241 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
242 242
243 // Get the original SiteInstance for later comparison. 243 // Get the original SiteInstance for later comparison.
244 scoped_refptr<SiteInstance> orig_site_instance( 244 scoped_refptr<SiteInstance> orig_site_instance(
245 shell()->web_contents()->GetSiteInstance()); 245 shell()->web_contents()->GetSiteInstance());
246 EXPECT_TRUE(orig_site_instance != NULL); 246 EXPECT_TRUE(orig_site_instance.get() != NULL);
247 247
248 // Test clicking a target=blank link. 248 // Test clicking a target=blank link.
249 ShellAddedObserver new_shell_observer; 249 ShellAddedObserver new_shell_observer;
250 bool success = false; 250 bool success = false;
251 EXPECT_TRUE(ExecuteScriptAndExtractBool( 251 EXPECT_TRUE(ExecuteScriptAndExtractBool(
252 shell()->web_contents(), 252 shell()->web_contents(),
253 "window.domAutomationController.send(clickTargetBlankLink());", 253 "window.domAutomationController.send(clickTargetBlankLink());",
254 &success)); 254 &success));
255 EXPECT_TRUE(success); 255 EXPECT_TRUE(success);
256 256
(...skipping 27 matching lines...) Expand all
284 std::string replacement_path; 284 std::string replacement_path;
285 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 285 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
286 "files/click-noreferrer-links.html", 286 "files/click-noreferrer-links.html",
287 https_server.host_port_pair(), 287 https_server.host_port_pair(),
288 &replacement_path)); 288 &replacement_path));
289 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 289 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
290 290
291 // Get the original SiteInstance for later comparison. 291 // Get the original SiteInstance for later comparison.
292 scoped_refptr<SiteInstance> orig_site_instance( 292 scoped_refptr<SiteInstance> orig_site_instance(
293 shell()->web_contents()->GetSiteInstance()); 293 shell()->web_contents()->GetSiteInstance());
294 EXPECT_TRUE(orig_site_instance != NULL); 294 EXPECT_TRUE(orig_site_instance.get() != NULL);
295 295
296 // Test clicking a rel=noreferrer link. 296 // Test clicking a rel=noreferrer link.
297 bool success = false; 297 bool success = false;
298 EXPECT_TRUE(ExecuteScriptAndExtractBool( 298 EXPECT_TRUE(ExecuteScriptAndExtractBool(
299 shell()->web_contents(), 299 shell()->web_contents(),
300 "window.domAutomationController.send(clickNoRefLink());", 300 "window.domAutomationController.send(clickNoRefLink());",
301 &success)); 301 &success));
302 EXPECT_TRUE(success); 302 EXPECT_TRUE(success);
303 303
304 // Wait for the cross-site transition in the current tab to finish. 304 // Wait for the cross-site transition in the current tab to finish.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 std::string replacement_path; 352 std::string replacement_path;
353 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 353 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
354 "files/click-noreferrer-links.html", 354 "files/click-noreferrer-links.html",
355 https_server.host_port_pair(), 355 https_server.host_port_pair(),
356 &replacement_path)); 356 &replacement_path));
357 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 357 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
358 358
359 // Get the original SiteInstance for later comparison. 359 // Get the original SiteInstance for later comparison.
360 scoped_refptr<SiteInstance> orig_site_instance( 360 scoped_refptr<SiteInstance> orig_site_instance(
361 shell()->web_contents()->GetSiteInstance()); 361 shell()->web_contents()->GetSiteInstance());
362 EXPECT_TRUE(orig_site_instance != NULL); 362 EXPECT_TRUE(orig_site_instance.get() != NULL);
363 363
364 // Test clicking a target=foo link. 364 // Test clicking a target=foo link.
365 ShellAddedObserver new_shell_observer; 365 ShellAddedObserver new_shell_observer;
366 bool success = false; 366 bool success = false;
367 EXPECT_TRUE(ExecuteScriptAndExtractBool( 367 EXPECT_TRUE(ExecuteScriptAndExtractBool(
368 shell()->web_contents(), 368 shell()->web_contents(),
369 "window.domAutomationController.send(clickSameSiteTargetedLink());", 369 "window.domAutomationController.send(clickSameSiteTargetedLink());",
370 &success)); 370 &success));
371 EXPECT_TRUE(success); 371 EXPECT_TRUE(success);
372 Shell* new_shell = new_shell_observer.GetShell(); 372 Shell* new_shell = new_shell_observer.GetShell();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 std::string replacement_path; 435 std::string replacement_path;
436 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 436 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
437 "files/click-noreferrer-links.html", 437 "files/click-noreferrer-links.html",
438 https_server.host_port_pair(), 438 https_server.host_port_pair(),
439 &replacement_path)); 439 &replacement_path));
440 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 440 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
441 441
442 // Get the original SiteInstance for later comparison. 442 // Get the original SiteInstance for later comparison.
443 scoped_refptr<SiteInstance> orig_site_instance( 443 scoped_refptr<SiteInstance> orig_site_instance(
444 shell()->web_contents()->GetSiteInstance()); 444 shell()->web_contents()->GetSiteInstance());
445 EXPECT_TRUE(orig_site_instance != NULL); 445 EXPECT_TRUE(orig_site_instance.get() != NULL);
446 446
447 // Test clicking a target=_blank link. 447 // Test clicking a target=_blank link.
448 ShellAddedObserver new_shell_observer; 448 ShellAddedObserver new_shell_observer;
449 bool success = false; 449 bool success = false;
450 EXPECT_TRUE(ExecuteScriptAndExtractBool( 450 EXPECT_TRUE(ExecuteScriptAndExtractBool(
451 shell()->web_contents(), 451 shell()->web_contents(),
452 "window.domAutomationController.send(clickSameSiteTargetBlankLink());", 452 "window.domAutomationController.send(clickSameSiteTargetBlankLink());",
453 &success)); 453 &success));
454 EXPECT_TRUE(success); 454 EXPECT_TRUE(success);
455 Shell* new_shell = new_shell_observer.GetShell(); 455 Shell* new_shell = new_shell_observer.GetShell();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 538 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
539 "files/click-noreferrer-links.html", 539 "files/click-noreferrer-links.html",
540 https_server.host_port_pair(), 540 https_server.host_port_pair(),
541 &replacement_path)); 541 &replacement_path));
542 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 542 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
543 543
544 // Get the original SiteInstance and RVHM for later comparison. 544 // Get the original SiteInstance and RVHM for later comparison.
545 WebContents* opener_contents = shell()->web_contents(); 545 WebContents* opener_contents = shell()->web_contents();
546 scoped_refptr<SiteInstance> orig_site_instance( 546 scoped_refptr<SiteInstance> orig_site_instance(
547 opener_contents->GetSiteInstance()); 547 opener_contents->GetSiteInstance());
548 EXPECT_TRUE(orig_site_instance != NULL); 548 EXPECT_TRUE(orig_site_instance.get() != NULL);
549 RenderViewHostManager* opener_manager = 549 RenderViewHostManager* opener_manager = static_cast<WebContentsImpl*>(
550 static_cast<WebContentsImpl*>(opener_contents)-> 550 opener_contents)->GetRenderManagerForTesting();
551 GetRenderManagerForTesting();
552 551
553 // 1) Open two more windows, one named. These initially have openers but no 552 // 1) Open two more windows, one named. These initially have openers but no
554 // reference to each other. We will later post a message between them. 553 // reference to each other. We will later post a message between them.
555 554
556 // First, a named target=foo window. 555 // First, a named target=foo window.
557 ShellAddedObserver new_shell_observer; 556 ShellAddedObserver new_shell_observer;
558 bool success = false; 557 bool success = false;
559 EXPECT_TRUE(ExecuteScriptAndExtractBool( 558 EXPECT_TRUE(ExecuteScriptAndExtractBool(
560 opener_contents, 559 opener_contents,
561 "window.domAutomationController.send(clickSameSiteTargetedLink());", 560 "window.domAutomationController.send(clickSameSiteTargetedLink());",
(...skipping 26 matching lines...) Expand all
588 WaitForLoadStop(new_contents); 587 WaitForLoadStop(new_contents);
589 EXPECT_EQ("/files/title2.html", new_contents->GetURL().path()); 588 EXPECT_EQ("/files/title2.html", new_contents->GetURL().path());
590 NavigateToURL(new_shell2, test_server()->GetURL("files/post_message.html")); 589 NavigateToURL(new_shell2, test_server()->GetURL("files/post_message.html"));
591 EXPECT_EQ(orig_site_instance, new_contents->GetSiteInstance()); 590 EXPECT_EQ(orig_site_instance, new_contents->GetSiteInstance());
592 RenderViewHostManager* new_manager = 591 RenderViewHostManager* new_manager =
593 static_cast<WebContentsImpl*>(new_contents)->GetRenderManagerForTesting(); 592 static_cast<WebContentsImpl*>(new_contents)->GetRenderManagerForTesting();
594 593
595 // We now have three windows. The opener should have a swapped out RVH 594 // We now have three windows. The opener should have a swapped out RVH
596 // for the new SiteInstance, but the _blank window should not. 595 // for the new SiteInstance, but the _blank window should not.
597 EXPECT_EQ(3u, Shell::windows().size()); 596 EXPECT_EQ(3u, Shell::windows().size());
598 EXPECT_TRUE(opener_manager->GetSwappedOutRenderViewHost(foo_site_instance)); 597 EXPECT_TRUE(
599 EXPECT_FALSE(new_manager->GetSwappedOutRenderViewHost(foo_site_instance)); 598 opener_manager->GetSwappedOutRenderViewHost(foo_site_instance.get()));
599 EXPECT_FALSE(
600 new_manager->GetSwappedOutRenderViewHost(foo_site_instance.get()));
600 601
601 // 2) Fail to post a message from the foo window to the opener if the target 602 // 2) Fail to post a message from the foo window to the opener if the target
602 // origin is wrong. We won't see an error, but we can check for the right 603 // origin is wrong. We won't see an error, but we can check for the right
603 // number of received messages below. 604 // number of received messages below.
604 EXPECT_TRUE(ExecuteScriptAndExtractBool( 605 EXPECT_TRUE(ExecuteScriptAndExtractBool(
605 foo_contents, 606 foo_contents,
606 "window.domAutomationController.send(postToOpener('msg'," 607 "window.domAutomationController.send(postToOpener('msg',"
607 " 'http://google.com'));", 608 " 'http://google.com'));",
608 &success)); 609 &success));
609 EXPECT_TRUE(success); 610 EXPECT_TRUE(success);
610 ASSERT_FALSE(opener_manager->GetSwappedOutRenderViewHost(orig_site_instance)); 611 ASSERT_FALSE(
612 opener_manager->GetSwappedOutRenderViewHost(orig_site_instance.get()));
611 613
612 // 3) Post a message from the foo window to the opener. The opener will 614 // 3) Post a message from the foo window to the opener. The opener will
613 // reply, causing the foo window to update its own title. 615 // reply, causing the foo window to update its own title.
614 WindowedNotificationObserver title_observer( 616 WindowedNotificationObserver title_observer(
615 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, 617 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
616 Source<WebContents>(foo_contents)); 618 Source<WebContents>(foo_contents));
617 EXPECT_TRUE(ExecuteScriptAndExtractBool( 619 EXPECT_TRUE(ExecuteScriptAndExtractBool(
618 foo_contents, 620 foo_contents,
619 "window.domAutomationController.send(postToOpener('msg','*'));", 621 "window.domAutomationController.send(postToOpener('msg','*'));",
620 &success)); 622 &success));
621 EXPECT_TRUE(success); 623 EXPECT_TRUE(success);
622 ASSERT_FALSE(opener_manager->GetSwappedOutRenderViewHost(orig_site_instance)); 624 ASSERT_FALSE(
625 opener_manager->GetSwappedOutRenderViewHost(orig_site_instance.get()));
623 title_observer.Wait(); 626 title_observer.Wait();
624 627
625 // We should have received only 1 message in the opener and "foo" tabs, 628 // We should have received only 1 message in the opener and "foo" tabs,
626 // and updated the title. 629 // and updated the title.
627 int opener_received_messages = 0; 630 int opener_received_messages = 0;
628 EXPECT_TRUE(ExecuteScriptAndExtractInt( 631 EXPECT_TRUE(ExecuteScriptAndExtractInt(
629 opener_contents, 632 opener_contents,
630 "window.domAutomationController.send(window.receivedMessages);", 633 "window.domAutomationController.send(window.receivedMessages);",
631 &opener_received_messages)); 634 &opener_received_messages));
632 int foo_received_messages = 0; 635 int foo_received_messages = 0;
(...skipping 13 matching lines...) Expand all
646 EXPECT_TRUE(ExecuteScriptAndExtractBool( 649 EXPECT_TRUE(ExecuteScriptAndExtractBool(
647 new_contents, 650 new_contents,
648 "window.domAutomationController.send(postToFoo('msg2'));", 651 "window.domAutomationController.send(postToFoo('msg2'));",
649 &success)); 652 &success));
650 EXPECT_TRUE(success); 653 EXPECT_TRUE(success);
651 title_observer2.Wait(); 654 title_observer2.Wait();
652 EXPECT_EQ(ASCIIToUTF16("msg2"), foo_contents->GetTitle()); 655 EXPECT_EQ(ASCIIToUTF16("msg2"), foo_contents->GetTitle());
653 656
654 // This postMessage should have created a swapped out RVH for the new 657 // This postMessage should have created a swapped out RVH for the new
655 // SiteInstance in the target=_blank window. 658 // SiteInstance in the target=_blank window.
656 EXPECT_TRUE(new_manager->GetSwappedOutRenderViewHost(foo_site_instance)); 659 EXPECT_TRUE(
660 new_manager->GetSwappedOutRenderViewHost(foo_site_instance.get()));
657 661
658 // TODO(nasko): Test subframe targeting of postMessage once 662 // TODO(nasko): Test subframe targeting of postMessage once
659 // http://crbug.com/153701 is fixed. 663 // http://crbug.com/153701 is fixed.
660 } 664 }
661 665
662 // Test for crbug.com/116192. Navigations to a window's opener should 666 // Test for crbug.com/116192. Navigations to a window's opener should
663 // still work after a process swap. 667 // still work after a process swap.
664 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 668 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
665 AllowTargetedNavigationsInOpenerAfterSwap) { 669 AllowTargetedNavigationsInOpenerAfterSwap) {
666 // Start two servers with different sites. 670 // Start two servers with different sites.
667 ASSERT_TRUE(test_server()->Start()); 671 ASSERT_TRUE(test_server()->Start());
668 net::SpawnedTestServer https_server( 672 net::SpawnedTestServer https_server(
669 net::SpawnedTestServer::TYPE_HTTPS, 673 net::SpawnedTestServer::TYPE_HTTPS,
670 net::SpawnedTestServer::kLocalhost, 674 net::SpawnedTestServer::kLocalhost,
671 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 675 base::FilePath(FILE_PATH_LITERAL("content/test/data")));
672 ASSERT_TRUE(https_server.Start()); 676 ASSERT_TRUE(https_server.Start());
673 677
674 // Load a page with links that open in a new window. 678 // Load a page with links that open in a new window.
675 std::string replacement_path; 679 std::string replacement_path;
676 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 680 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
677 "files/click-noreferrer-links.html", 681 "files/click-noreferrer-links.html",
678 https_server.host_port_pair(), 682 https_server.host_port_pair(),
679 &replacement_path)); 683 &replacement_path));
680 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 684 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
681 685
682 // Get the original tab and SiteInstance for later comparison. 686 // Get the original tab and SiteInstance for later comparison.
683 WebContents* orig_contents = shell()->web_contents(); 687 WebContents* orig_contents = shell()->web_contents();
684 scoped_refptr<SiteInstance> orig_site_instance( 688 scoped_refptr<SiteInstance> orig_site_instance(
685 orig_contents->GetSiteInstance()); 689 orig_contents->GetSiteInstance());
686 EXPECT_TRUE(orig_site_instance != NULL); 690 EXPECT_TRUE(orig_site_instance.get() != NULL);
687 691
688 // Test clicking a target=foo link. 692 // Test clicking a target=foo link.
689 ShellAddedObserver new_shell_observer; 693 ShellAddedObserver new_shell_observer;
690 bool success = false; 694 bool success = false;
691 EXPECT_TRUE(ExecuteScriptAndExtractBool( 695 EXPECT_TRUE(ExecuteScriptAndExtractBool(
692 orig_contents, 696 orig_contents,
693 "window.domAutomationController.send(clickSameSiteTargetedLink());", 697 "window.domAutomationController.send(clickSameSiteTargetedLink());",
694 &success)); 698 &success));
695 EXPECT_TRUE(success); 699 EXPECT_TRUE(success);
696 Shell* new_shell = new_shell_observer.GetShell(); 700 Shell* new_shell = new_shell_observer.GetShell();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 std::string replacement_path; 750 std::string replacement_path;
747 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 751 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
748 "files/click-noreferrer-links.html", 752 "files/click-noreferrer-links.html",
749 https_server.host_port_pair(), 753 https_server.host_port_pair(),
750 &replacement_path)); 754 &replacement_path));
751 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 755 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
752 756
753 // Get the original SiteInstance for later comparison. 757 // Get the original SiteInstance for later comparison.
754 scoped_refptr<SiteInstance> orig_site_instance( 758 scoped_refptr<SiteInstance> orig_site_instance(
755 shell()->web_contents()->GetSiteInstance()); 759 shell()->web_contents()->GetSiteInstance());
756 EXPECT_TRUE(orig_site_instance != NULL); 760 EXPECT_TRUE(orig_site_instance.get() != NULL);
757 761
758 // Test clicking a target=foo link. 762 // Test clicking a target=foo link.
759 ShellAddedObserver new_shell_observer; 763 ShellAddedObserver new_shell_observer;
760 bool success = false; 764 bool success = false;
761 EXPECT_TRUE(ExecuteScriptAndExtractBool( 765 EXPECT_TRUE(ExecuteScriptAndExtractBool(
762 shell()->web_contents(), 766 shell()->web_contents(),
763 "window.domAutomationController.send(clickSameSiteTargetedLink());", 767 "window.domAutomationController.send(clickSameSiteTargetedLink());",
764 &success)); 768 &success));
765 EXPECT_TRUE(success); 769 EXPECT_TRUE(success);
766 Shell* new_shell = new_shell_observer.GetShell(); 770 Shell* new_shell = new_shell_observer.GetShell();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 std::string replacement_path; 818 std::string replacement_path;
815 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 819 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
816 "files/click-noreferrer-links.html", 820 "files/click-noreferrer-links.html",
817 https_server.host_port_pair(), 821 https_server.host_port_pair(),
818 &replacement_path)); 822 &replacement_path));
819 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); 823 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
820 824
821 // Get the original SiteInstance for later comparison. 825 // Get the original SiteInstance for later comparison.
822 scoped_refptr<SiteInstance> orig_site_instance( 826 scoped_refptr<SiteInstance> orig_site_instance(
823 shell()->web_contents()->GetSiteInstance()); 827 shell()->web_contents()->GetSiteInstance());
824 EXPECT_TRUE(orig_site_instance != NULL); 828 EXPECT_TRUE(orig_site_instance.get() != NULL);
825 829
826 // Load a cross-site page that fails with a 204 error. 830 // Load a cross-site page that fails with a 204 error.
827 NavigateToURL(shell(), https_server.GetURL("nocontent")); 831 NavigateToURL(shell(), https_server.GetURL("nocontent"));
828 832
829 // We should still be looking at the normal page. The typed URL will 833 // We should still be looking at the normal page. The typed URL will
830 // still be visible until the user clears it manually, but the last 834 // still be visible until the user clears it manually, but the last
831 // committed URL will be the previous page. 835 // committed URL will be the previous page.
832 scoped_refptr<SiteInstance> post_nav_site_instance( 836 scoped_refptr<SiteInstance> post_nav_site_instance(
833 shell()->web_contents()->GetSiteInstance()); 837 shell()->web_contents()->GetSiteInstance());
834 EXPECT_EQ(orig_site_instance, post_nav_site_instance); 838 EXPECT_EQ(orig_site_instance, post_nav_site_instance);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); 1226 NavigateToURL(shell(), https_server.GetURL("files/title1.html"));
1223 1227
1224 // Make sure it ends up at the right page. 1228 // Make sure it ends up at the right page.
1225 WaitForLoadStop(shell()->web_contents()); 1229 WaitForLoadStop(shell()->web_contents());
1226 EXPECT_EQ(https_server.GetURL("files/title1.html"), 1230 EXPECT_EQ(https_server.GetURL("files/title1.html"),
1227 shell()->web_contents()->GetURL()); 1231 shell()->web_contents()->GetURL());
1228 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); 1232 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance());
1229 } 1233 }
1230 1234
1231 } // namespace content 1235 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/browser/renderer_host/render_widget_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698