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

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

Issue 1309323004: Create a NavigationEntry for the initial blank page. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix GetEntryCount, more tests Created 5 years, 2 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
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 <set> 5 #include <set>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 GetCrossSiteURL("nocontent"))); 1000 GetCrossSiteURL("nocontent")));
1001 1001
1002 // We should still be looking at the normal page. Because we started from a 1002 // We should still be looking at the normal page. Because we started from a
1003 // blank new tab, the typed URL will still be visible until the user clears it 1003 // blank new tab, the typed URL will still be visible until the user clears it
1004 // manually. The last committed URL will be the previous page. 1004 // manually. The last committed URL will be the previous page.
1005 scoped_refptr<SiteInstance> post_nav_site_instance( 1005 scoped_refptr<SiteInstance> post_nav_site_instance(
1006 shell()->web_contents()->GetSiteInstance()); 1006 shell()->web_contents()->GetSiteInstance());
1007 EXPECT_EQ(orig_site_instance, post_nav_site_instance); 1007 EXPECT_EQ(orig_site_instance, post_nav_site_instance);
1008 EXPECT_EQ("/nocontent", 1008 EXPECT_EQ("/nocontent",
1009 shell()->web_contents()->GetVisibleURL().path()); 1009 shell()->web_contents()->GetVisibleURL().path());
1010 EXPECT_FALSE( 1010 EXPECT_TRUE(shell()->web_contents()->GetController().IsInitialNavigation());
1011 shell()->web_contents()->GetController().GetLastCommittedEntry());
1012 1011
1013 // Renderer-initiated navigations should work. 1012 // Renderer-initiated navigations should work.
1014 base::string16 expected_title = ASCIIToUTF16("Title Of Awesomeness"); 1013 base::string16 expected_title = ASCIIToUTF16("Title Of Awesomeness");
1015 TitleWatcher title_watcher(shell()->web_contents(), expected_title); 1014 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
1016 GURL url = test_server()->GetURL("files/title2.html"); 1015 GURL url = test_server()->GetURL("files/title2.html");
1017 EXPECT_TRUE(ExecuteScript( 1016 EXPECT_TRUE(ExecuteScript(
1018 shell()->web_contents(), 1017 shell()->web_contents(),
1019 base::StringPrintf("location.href = '%s'", url.spec().c_str()))); 1018 base::StringPrintf("location.href = '%s'", url.spec().c_str())));
1020 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 1019 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
1021 1020
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 EXPECT_TRUE(ExecuteScriptAndExtractBool( 1068 EXPECT_TRUE(ExecuteScriptAndExtractBool(
1070 orig_contents, 1069 orig_contents,
1071 "window.domAutomationController.send(modifyNewWindow());", 1070 "window.domAutomationController.send(modifyNewWindow());",
1072 &success)); 1071 &success));
1073 EXPECT_TRUE(success); 1072 EXPECT_TRUE(success);
1074 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 1073 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
1075 1074
1076 // At this point, we should no longer be showing the destination URL. 1075 // At this point, we should no longer be showing the destination URL.
1077 // The visible entry should be null, resulting in about:blank in the address 1076 // The visible entry should be null, resulting in about:blank in the address
1078 // bar. 1077 // bar.
1079 EXPECT_FALSE(contents->GetController().GetVisibleEntry()); 1078 EXPECT_FALSE(contents->GetController().GetPendingEntry());
1079 EXPECT_EQ(GURL(url::kAboutBlankURL),
1080 contents->GetController().GetVisibleEntry()->GetURL());
1080 } 1081 }
1081 1082
1082 // Test for crbug.com/9682. We should not show the URL for a pending renderer- 1083 // Test for crbug.com/9682. We should not show the URL for a pending renderer-
1083 // initiated navigation in a new tab if it is not the initial navigation. In 1084 // initiated navigation in a new tab if it is not the initial navigation. In
1084 // this case, the renderer will not notify us of a modification, so we cannot 1085 // this case, the renderer will not notify us of a modification, so we cannot
1085 // show the pending URL without allowing a spoof. 1086 // show the pending URL without allowing a spoof.
1086 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 1087 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
1087 DontShowLoadingURLIfNotInitialNav) { 1088 DontShowLoadingURLIfNotInitialNav) {
1088 ASSERT_TRUE(test_server()->Start()); 1089 ASSERT_TRUE(test_server()->Start());
1089 1090
(...skipping 12 matching lines...) Expand all
1102 "window.domAutomationController.send(" 1103 "window.domAutomationController.send("
1103 "clickNoContentScriptedTargetedLink());", 1104 "clickNoContentScriptedTargetedLink());",
1104 &success)); 1105 &success));
1105 EXPECT_TRUE(success); 1106 EXPECT_TRUE(success);
1106 1107
1107 // Wait for the window to open. 1108 // Wait for the window to open.
1108 Shell* new_shell = new_shell_observer.GetShell(); 1109 Shell* new_shell = new_shell_observer.GetShell();
1109 1110
1110 // Ensure the destination URL is not visible, because it is not the initial 1111 // Ensure the destination URL is not visible, because it is not the initial
1111 // navigation. 1112 // navigation.
1113 // TODO(creis): It is, right?
1112 WebContents* contents = new_shell->web_contents(); 1114 WebContents* contents = new_shell->web_contents();
1113 EXPECT_FALSE(contents->GetController().IsInitialNavigation()); 1115 EXPECT_FALSE(contents->GetController().IsInitialNavigation());
1114 EXPECT_FALSE(contents->GetController().GetVisibleEntry()); 1116
1117 // TODO(creis): There's definitely a regression right now, since we're not
1118 // receiving DidAccessInitialDocument. Can we verify that happens, and then
1119 // check that the omnibox shows about:blank?
1120 EXPECT_FALSE(contents->GetController().GetPendingEntry());
1121 EXPECT_EQ(GURL(url::kAboutBlankURL),
1122 contents->GetController().GetVisibleEntry()->GetURL());
1115 } 1123 }
1116 1124
1117 // Crashes under ThreadSanitizer, http://crbug.com/356758. 1125 // Crashes under ThreadSanitizer, http://crbug.com/356758.
1118 #if defined(THREAD_SANITIZER) 1126 #if defined(THREAD_SANITIZER)
1119 #define MAYBE_BackForwardNotStale DISABLED_BackForwardNotStale 1127 #define MAYBE_BackForwardNotStale DISABLED_BackForwardNotStale
1120 #else 1128 #else
1121 #define MAYBE_BackForwardNotStale BackForwardNotStale 1129 #define MAYBE_BackForwardNotStale BackForwardNotStale
1122 #endif 1130 #endif
1123 // Test for http://crbug.com/93427. Ensure that cross-site navigations 1131 // Test for http://crbug.com/93427. Ensure that cross-site navigations
1124 // do not cause back/forward navigations to be considered stale by the 1132 // do not cause back/forward navigations to be considered stale by the
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 RenderViewHostDestructionObserver rvh_observers(shell()->web_contents()); 1315 RenderViewHostDestructionObserver rvh_observers(shell()->web_contents());
1308 1316
1309 GURL navigated_url(embedded_test_server()->GetURL("/title2.html")); 1317 GURL navigated_url(embedded_test_server()->GetURL("/title2.html"));
1310 GURL view_source_url(kViewSourceScheme + std::string(":") + 1318 GURL view_source_url(kViewSourceScheme + std::string(":") +
1311 navigated_url.spec()); 1319 navigated_url.spec());
1312 1320
1313 // Let's ensure that when we start with a blank window, navigating away to a 1321 // Let's ensure that when we start with a blank window, navigating away to a
1314 // view-source URL, we create a new SiteInstance. 1322 // view-source URL, we create a new SiteInstance.
1315 RenderViewHost* blank_rvh = shell()->web_contents()->GetRenderViewHost(); 1323 RenderViewHost* blank_rvh = shell()->web_contents()->GetRenderViewHost();
1316 SiteInstance* blank_site_instance = blank_rvh->GetSiteInstance(); 1324 SiteInstance* blank_site_instance = blank_rvh->GetSiteInstance();
1317 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), GURL::EmptyGURL()); 1325 EXPECT_EQ(GURL(url::kAboutBlankURL),
1318 EXPECT_EQ(blank_site_instance->GetSiteURL(), GURL::EmptyGURL()); 1326 shell()->web_contents()->GetLastCommittedURL());
1327 EXPECT_EQ(GURL::EmptyGURL(), blank_site_instance->GetSiteURL());
1319 rvh_observers.EnsureRVHGetsDestructed(blank_rvh); 1328 rvh_observers.EnsureRVHGetsDestructed(blank_rvh);
1320 1329
1321 // Now navigate to the view-source URL and ensure we got a different 1330 // Now navigate to the view-source URL and ensure we got a different
1322 // SiteInstance and RenderViewHost. 1331 // SiteInstance and RenderViewHost.
1323 NavigateToURL(shell(), view_source_url); 1332 NavigateToURL(shell(), view_source_url);
1324 EXPECT_NE(blank_rvh, shell()->web_contents()->GetRenderViewHost()); 1333 EXPECT_NE(blank_rvh, shell()->web_contents()->GetRenderViewHost());
1325 EXPECT_NE(blank_site_instance, shell()->web_contents()-> 1334 EXPECT_NE(blank_site_instance, shell()->web_contents()->
1326 GetRenderViewHost()->GetSiteInstance()); 1335 GetRenderViewHost()->GetSiteInstance());
1327 rvh_observers.EnsureRVHGetsDestructed( 1336 rvh_observers.EnsureRVHGetsDestructed(
1328 shell()->web_contents()->GetRenderViewHost()); 1337 shell()->web_contents()->GetRenderViewHost());
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 std::string result; 2080 std::string result;
2072 EXPECT_TRUE(ExecuteScriptAndExtractString( 2081 EXPECT_TRUE(ExecuteScriptAndExtractString(
2073 shell()->web_contents(), 2082 shell()->web_contents(),
2074 "window.domAutomationController.send(getLastOpenedWindowLocation());", 2083 "window.domAutomationController.send(getLastOpenedWindowLocation());",
2075 &result)); 2084 &result));
2076 EXPECT_EQ(expected_url.spec(), result); 2085 EXPECT_EQ(expected_url.spec(), result);
2077 } 2086 }
2078 2087
2079 2088
2080 } // namespace content 2089 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698