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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Allow renderer-initiated reloads. Created 3 years, 11 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 ba1c812e470e081ec81e0cf068c26b7b2637463b..412686798db3f03e1c7b93d671fdecda685552af 100644
--- a/content/browser/frame_host/navigation_handle_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_handle_impl_browsertest.cc
@@ -904,4 +904,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

Powered by Google App Engine
This is Rietveld 408576698