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

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

Powered by Google App Engine
This is Rietveld 408576698