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

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

Issue 13966012: Revert 195553 "Allow showing pending URL for new tab navigations..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/json/json_reader.h" 6 #include "base/json/json_reader.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // Opens in same tab. 829 // Opens in same tab.
830 EXPECT_EQ(1u, Shell::windows().size()); 830 EXPECT_EQ(1u, Shell::windows().size());
831 EXPECT_EQ("/files/title2.html", shell()->web_contents()->GetURL().path()); 831 EXPECT_EQ("/files/title2.html", shell()->web_contents()->GetURL().path());
832 832
833 // Should have the same SiteInstance. 833 // Should have the same SiteInstance.
834 scoped_refptr<SiteInstance> noref_site_instance( 834 scoped_refptr<SiteInstance> noref_site_instance(
835 shell()->web_contents()->GetSiteInstance()); 835 shell()->web_contents()->GetSiteInstance());
836 EXPECT_EQ(orig_site_instance, noref_site_instance); 836 EXPECT_EQ(orig_site_instance, noref_site_instance);
837 } 837 }
838 838
839 // Test for crbug.com/9682. We should show the URL for a pending renderer-
840 // initiated navigation in a new tab, until the content of the initial
841 // about:blank page is modified by another window. At that point, we should
842 // revert to showing about:blank to prevent a URL spoof.
843 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ShowLoadingURLUntilSpoof) {
844 ASSERT_TRUE(test_server()->Start());
845
846 // Load a page that can open a URL that won't commit in a new window.
847 NavigateToURL(
848 shell(), test_server()->GetURL("files/click-nocontent-link.html"));
849 WebContents* orig_contents = shell()->web_contents();
850
851 // Click a /nocontent link that opens in a new window but never commits.
852 ShellAddedObserver new_shell_observer;
853 bool success = false;
854 EXPECT_TRUE(ExecuteScriptAndExtractBool(
855 orig_contents,
856 "window.domAutomationController.send(clickNoContentTargetedLink());",
857 &success));
858 EXPECT_TRUE(success);
859
860 // Wait for the window to open.
861 Shell* new_shell = new_shell_observer.GetShell();
862
863 // Ensure the destination URL is visible, because it is considered the
864 // initial navigation.
865 WebContents* contents = new_shell->web_contents();
866 EXPECT_TRUE(contents->GetController().IsInitialNavigation());
867 EXPECT_EQ("/nocontent",
868 contents->GetController().GetVisibleEntry()->GetURL().path());
869
870 // Now modify the contents of the new window from the opener. This will also
871 // modify the title of the document to give us something to listen for.
872 WindowedNotificationObserver title_observer(
873 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
874 Source<WebContents>(contents));
875 success = false;
876 EXPECT_TRUE(ExecuteScriptAndExtractBool(
877 orig_contents,
878 "window.domAutomationController.send(modifyNewWindow());",
879 &success));
880 EXPECT_TRUE(success);
881 title_observer.Wait();
882 EXPECT_EQ(ASCIIToUTF16("Modified Title"), contents->GetTitle());
883
884 // At this point, we should no longer be showing the destination URL.
885 // The visible entry should be null, resulting in about:blank in the address
886 // bar.
887 EXPECT_FALSE(contents->GetController().GetVisibleEntry());
888 }
889
890 // Test for crbug.com/9682. We should not show the URL for a pending renderer-
891 // initiated navigation in a new tab if it is not the initial navigation. In
892 // this case, the renderer will not notify us of a modification, so we cannot
893 // show the pending URL without allowing a spoof.
894 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
895 DontShowLoadingURLIfNotInitialNav) {
896 ASSERT_TRUE(test_server()->Start());
897
898 // Load a page that can open a URL that won't commit in a new window.
899 NavigateToURL(
900 shell(), test_server()->GetURL("files/click-nocontent-link.html"));
901 WebContents* orig_contents = shell()->web_contents();
902
903 // Click a /nocontent link that opens in a new window but never commits.
904 // By using an onclick handler that first creates the window, the slow
905 // navigation is not considered an initial navigation.
906 ShellAddedObserver new_shell_observer;
907 bool success = false;
908 EXPECT_TRUE(ExecuteScriptAndExtractBool(
909 orig_contents,
910 "window.domAutomationController.send("
911 "clickNoContentScriptedTargetedLink());",
912 &success));
913 EXPECT_TRUE(success);
914
915 // Wait for the window to open.
916 Shell* new_shell = new_shell_observer.GetShell();
917
918 // Ensure the destination URL is not visible, because it is not the initial
919 // navigation.
920 WebContents* contents = new_shell->web_contents();
921 EXPECT_FALSE(contents->GetController().IsInitialNavigation());
922 EXPECT_FALSE(contents->GetController().GetVisibleEntry());
923 }
924
925 // Test for http://crbug.com/93427. Ensure that cross-site navigations 839 // Test for http://crbug.com/93427. Ensure that cross-site navigations
926 // do not cause back/forward navigations to be considered stale by the 840 // do not cause back/forward navigations to be considered stale by the
927 // renderer. 841 // renderer.
928 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, BackForwardNotStale) { 842 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, BackForwardNotStale) {
929 NavigateToURL(shell(), GURL(chrome::kAboutBlankURL)); 843 NavigateToURL(shell(), GURL(chrome::kAboutBlankURL));
930 844
931 // Start two servers with different sites. 845 // Start two servers with different sites.
932 ASSERT_TRUE(test_server()->Start()); 846 ASSERT_TRUE(test_server()->Start());
933 net::TestServer https_server( 847 net::TestServer https_server(
934 net::TestServer::TYPE_HTTPS, 848 net::TestServer::TYPE_HTTPS,
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 NavigateToURL(shell(), https_server.GetURL("files/title1.html")); 1200 NavigateToURL(shell(), https_server.GetURL("files/title1.html"));
1287 1201
1288 // Make sure it ends up at the right page. 1202 // Make sure it ends up at the right page.
1289 WaitForLoadStop(shell()->web_contents()); 1203 WaitForLoadStop(shell()->web_contents());
1290 EXPECT_EQ(https_server.GetURL("files/title1.html"), 1204 EXPECT_EQ(https_server.GetURL("files/title1.html"),
1291 shell()->web_contents()->GetURL()); 1205 shell()->web_contents()->GetURL());
1292 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); 1206 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance());
1293 } 1207 }
1294 1208
1295 } // namespace content 1209 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698