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

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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 // Tests that the start URL is HTTPS upgraded for a cross site navigation. 973 // Tests that the start URL is HTTPS upgraded for a cross site navigation.
974 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest, 974 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest,
975 StartUrlIsHttpsUpgradedCrossSite) { 975 StartUrlIsHttpsUpgradedCrossSite) {
976 GURL start_url( 976 GURL start_url(
977 embedded_test_server()->GetURL("/https_upgrade_cross_site.html")); 977 embedded_test_server()->GetURL("/https_upgrade_cross_site.html"));
978 GURL cross_site_iframe_secure_url("https://other.com/title1.html"); 978 GURL cross_site_iframe_secure_url("https://other.com/title1.html");
979 979
980 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url); 980 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url);
981 } 981 }
982 982
983 // Ensure that browser-initiated same-document navigations are detected and
984 // don't issue network requests. See crbug.com/663777.
985 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
986 SamePageBrowserInitiatedNoReload) {
987 GURL url(embedded_test_server()->GetURL("/title1.html"));
988 GURL url_fragment_1(embedded_test_server()->GetURL("/title1.html#id_1"));
989 GURL url_fragment_2(embedded_test_server()->GetURL("/title1.html#id_2"));
990
991 // 1) Perform a new-document navigation.
992 {
993 TestNavigationThrottleInstaller installer(
994 shell()->web_contents(), NavigationThrottle::PROCEED,
995 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
996 NavigationHandleObserver observer(shell()->web_contents(), url);
997 EXPECT_TRUE(NavigateToURL(shell(), url));
998 EXPECT_EQ(1, installer.will_start_called());
999 EXPECT_EQ(1, installer.will_process_called());
1000 EXPECT_FALSE(observer.is_same_page());
1001 }
1002
1003 // 2) Perform a same-document navigation by adding a fragment.
1004 {
1005 TestNavigationThrottleInstaller installer(
1006 shell()->web_contents(), NavigationThrottle::PROCEED,
1007 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
1008 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_1);
1009 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_1));
1010 EXPECT_EQ(0, installer.will_start_called());
1011 EXPECT_EQ(0, installer.will_process_called());
1012 EXPECT_TRUE(observer.is_same_page());
1013 }
1014
1015 // 3) Perform a same-document navigation by modifying the fragment.
1016 {
1017 TestNavigationThrottleInstaller installer(
1018 shell()->web_contents(), NavigationThrottle::PROCEED,
1019 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
1020 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2);
1021 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2));
1022 EXPECT_EQ(0, installer.will_start_called());
1023 EXPECT_EQ(0, installer.will_process_called());
1024 EXPECT_TRUE(observer.is_same_page());
1025 }
1026
1027 // 4) Redo the last navigation, but this time it should trigger a reload.
1028 {
1029 TestNavigationThrottleInstaller installer(
1030 shell()->web_contents(), NavigationThrottle::PROCEED,
1031 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
1032 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2);
1033 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2));
1034 EXPECT_EQ(1, installer.will_start_called());
1035 EXPECT_EQ(1, installer.will_process_called());
1036 EXPECT_FALSE(observer.is_same_page());
1037 }
1038
1039 // 5) Perform a new-document navigation by removing the fragment.
1040 {
1041 TestNavigationThrottleInstaller installer(
1042 shell()->web_contents(), NavigationThrottle::PROCEED,
1043 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
1044 NavigationHandleObserver observer(shell()->web_contents(), url);
1045 EXPECT_TRUE(NavigateToURL(shell(), url));
1046 EXPECT_EQ(1, installer.will_start_called());
1047 EXPECT_EQ(1, installer.will_process_called());
1048 EXPECT_FALSE(observer.is_same_page());
1049 }
1050 }
1051
983 } // namespace content 1052 } // namespace content
OLDNEW
« 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