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

Unified Diff: content/browser/frame_host/navigation_handle_impl_browsertest.cc

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Rebase. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_handle_impl_browsertest.cc
diff --git a/content/browser/frame_host/navigation_handle_impl_browsertest.cc b/content/browser/frame_host/navigation_handle_impl_browsertest.cc
index abb4502aff2f08bebf60a2541d75a3a4d79246cd..bdda50802e101c2336fed8dc37a344c7414a91ce 100644
--- a/content/browser/frame_host/navigation_handle_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_handle_impl_browsertest.cc
@@ -980,4 +980,73 @@ IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest,
CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url);
}
+// Ensure that browser-initiated same-document navigations are detected and
+// don't issue network requests. See crbug.com/663777.
+IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
+ SamePageBrowserInitiatedNoReload) {
+ GURL url(embedded_test_server()->GetURL("/title1.html"));
+ GURL url_fragment_1(embedded_test_server()->GetURL("/title1.html#id_1"));
+ GURL url_fragment_2(embedded_test_server()->GetURL("/title1.html#id_2"));
+
+ // 1) Perform a new-document navigation.
+ {
+ TestNavigationThrottleInstaller installer(
+ shell()->web_contents(), NavigationThrottle::PROCEED,
+ NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
+ NavigationHandleObserver observer(shell()->web_contents(), url);
+ EXPECT_TRUE(NavigateToURL(shell(), url));
+ EXPECT_EQ(1, installer.will_start_called());
+ EXPECT_EQ(1, installer.will_process_called());
+ EXPECT_FALSE(observer.is_same_page());
+ }
+
+ // 2) Perform a same-document navigation by adding a fragment.
+ {
+ TestNavigationThrottleInstaller installer(
+ shell()->web_contents(), NavigationThrottle::PROCEED,
+ NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
+ NavigationHandleObserver observer(shell()->web_contents(), url_fragment_1);
+ EXPECT_TRUE(NavigateToURL(shell(), url_fragment_1));
+ EXPECT_EQ(0, installer.will_start_called());
+ EXPECT_EQ(0, installer.will_process_called());
+ EXPECT_TRUE(observer.is_same_page());
+ }
+
+ // 3) Perform a same-document navigation by modifying the fragment.
+ {
+ TestNavigationThrottleInstaller installer(
+ shell()->web_contents(), NavigationThrottle::PROCEED,
+ NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
+ NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2);
+ EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2));
+ EXPECT_EQ(0, installer.will_start_called());
+ EXPECT_EQ(0, installer.will_process_called());
+ EXPECT_TRUE(observer.is_same_page());
+ }
+
+ // 4) Redo the last navigation, but this time it should trigger a reload.
+ {
+ TestNavigationThrottleInstaller installer(
+ shell()->web_contents(), NavigationThrottle::PROCEED,
+ NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
+ NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2);
+ EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2));
+ EXPECT_EQ(1, installer.will_start_called());
+ EXPECT_EQ(1, installer.will_process_called());
+ EXPECT_FALSE(observer.is_same_page());
+ }
+
+ // 5) Perform a new-document navigation by removing the fragment.
+ {
+ TestNavigationThrottleInstaller installer(
+ shell()->web_contents(), NavigationThrottle::PROCEED,
+ NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
+ NavigationHandleObserver observer(shell()->web_contents(), url);
+ EXPECT_TRUE(NavigateToURL(shell(), url));
+ EXPECT_EQ(1, installer.will_start_called());
+ EXPECT_EQ(1, installer.will_process_called());
+ EXPECT_FALSE(observer.is_same_page());
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | content/browser/frame_host/navigation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698