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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/frame_host/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 #include "content/browser/web_contents/web_contents_impl.h" 6 #include "content/browser/web_contents/web_contents_impl.h"
7 #include "content/public/browser/web_contents.h" 7 #include "content/public/browser/web_contents.h"
8 #include "content/public/browser/web_contents_observer.h" 8 #include "content/public/browser/web_contents_observer.h"
9 #include "content/public/common/request_context_type.h" 9 #include "content/public/common/request_context_type.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 // Tests that the start URL is HTTPS upgraded for a cross site navigation. 897 // Tests that the start URL is HTTPS upgraded for a cross site navigation.
898 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest, 898 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest,
899 StartUrlIsHttpsUpgradedCrossSite) { 899 StartUrlIsHttpsUpgradedCrossSite) {
900 GURL start_url( 900 GURL start_url(
901 embedded_test_server()->GetURL("/https_upgrade_cross_site.html")); 901 embedded_test_server()->GetURL("/https_upgrade_cross_site.html"));
902 GURL cross_site_iframe_secure_url("https://other.com/title1.html"); 902 GURL cross_site_iframe_secure_url("https://other.com/title1.html");
903 903
904 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url); 904 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url);
905 } 905 }
906 906
907 // Ensure that browser-initiated same-document navigations are detected and
908 // don't issue network requests. See crbug.com/663777.
909 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
910 SamePageBrowserInitiatedNoReload) {
911 GURL url(embedded_test_server()->GetURL("/title1.html"));
912 GURL url_fragment_1(embedded_test_server()->GetURL("/title1.html#id_1"));
913 GURL url_fragment_2(embedded_test_server()->GetURL("/title1.html#id_2"));
914
915 // 1) Perform a new-document navigation.
916 {
917 TestNavigationThrottleInstaller installer(
918 shell()->web_contents(), NavigationThrottle::PROCEED,
919 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
920 NavigationHandleObserver observer(shell()->web_contents(), url);
921 EXPECT_TRUE(NavigateToURL(shell(), url));
922 EXPECT_EQ(1, installer.will_start_called());
923 EXPECT_EQ(1, installer.will_process_called());
924 EXPECT_FALSE(observer.is_same_page());
925 }
926
927 // 2) Perform a same-document navigation by adding a fragment.
928 {
929 TestNavigationThrottleInstaller installer(
930 shell()->web_contents(), NavigationThrottle::PROCEED,
931 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
932 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_1);
933 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_1));
934 EXPECT_EQ(0, installer.will_start_called());
935 EXPECT_EQ(0, installer.will_process_called());
936 EXPECT_TRUE(observer.is_same_page());
937 }
938
939 // 3) Perform a same-document navigation by modifying the fragment.
940 {
941 TestNavigationThrottleInstaller installer(
942 shell()->web_contents(), NavigationThrottle::PROCEED,
943 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
944 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2);
945 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2));
946 EXPECT_EQ(0, installer.will_start_called());
947 EXPECT_EQ(0, installer.will_process_called());
948 EXPECT_TRUE(observer.is_same_page());
949 }
950
951 // 4) Redo the last navigation, but this time it should trigger a reload.
952 {
953 TestNavigationThrottleInstaller installer(
954 shell()->web_contents(), NavigationThrottle::PROCEED,
955 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
956 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2);
957 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2));
958 EXPECT_EQ(1, installer.will_start_called());
959 EXPECT_EQ(1, installer.will_process_called());
960 EXPECT_FALSE(observer.is_same_page());
961 }
962
963 // 5) Perform a new-document navigation by removing the fragment.
964 {
965 TestNavigationThrottleInstaller installer(
966 shell()->web_contents(), NavigationThrottle::PROCEED,
967 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
968 NavigationHandleObserver observer(shell()->web_contents(), url);
969 EXPECT_TRUE(NavigateToURL(shell(), url));
970 EXPECT_EQ(1, installer.will_start_called());
971 EXPECT_EQ(1, installer.will_process_called());
972 EXPECT_FALSE(observer.is_same_page());
973 }
974 }
975
907 } // namespace content 976 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698