OLD | NEW |
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 Loading... |
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. |
| 909 // See crbug.com/663777. |
| 910 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, |
| 911 SamePageBrowserInitiatedNoReload) { |
| 912 GURL url(embedded_test_server()->GetURL("/title1.html")); |
| 913 GURL url_fragment_1(embedded_test_server()->GetURL("/title1.html#id_1")); |
| 914 GURL url_fragment_2(embedded_test_server()->GetURL("/title1.html#id_2")); |
| 915 |
| 916 // 1) Perform a new-document navigation. |
| 917 { |
| 918 TestNavigationThrottleInstaller installer( |
| 919 shell()->web_contents(), NavigationThrottle::PROCEED, |
| 920 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); |
| 921 NavigationHandleObserver observer(shell()->web_contents(), url); |
| 922 EXPECT_TRUE(NavigateToURL(shell(), url)); |
| 923 EXPECT_EQ(1, installer.will_start_called()); |
| 924 EXPECT_EQ(1, installer.will_process_called()); |
| 925 EXPECT_FALSE(observer.is_same_page()); |
| 926 } |
| 927 |
| 928 // 2) Perform a same-document navigation by adding a fragment. |
| 929 { |
| 930 TestNavigationThrottleInstaller installer( |
| 931 shell()->web_contents(), NavigationThrottle::PROCEED, |
| 932 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); |
| 933 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_1); |
| 934 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_1)); |
| 935 EXPECT_EQ(0, installer.will_start_called()); |
| 936 EXPECT_EQ(0, installer.will_process_called()); |
| 937 EXPECT_TRUE(observer.is_same_page()); |
| 938 } |
| 939 |
| 940 // 3) Perform a same-document navigation by modifying the fragment. |
| 941 { |
| 942 TestNavigationThrottleInstaller installer( |
| 943 shell()->web_contents(), NavigationThrottle::PROCEED, |
| 944 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); |
| 945 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2); |
| 946 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2)); |
| 947 EXPECT_EQ(0, installer.will_start_called()); |
| 948 EXPECT_EQ(0, installer.will_process_called()); |
| 949 EXPECT_TRUE(observer.is_same_page()); |
| 950 } |
| 951 |
| 952 // 4) Redo the last navigation, but this time it should trigger a reload. |
| 953 { |
| 954 TestNavigationThrottleInstaller installer( |
| 955 shell()->web_contents(), NavigationThrottle::PROCEED, |
| 956 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); |
| 957 NavigationHandleObserver observer(shell()->web_contents(), url_fragment_2); |
| 958 EXPECT_TRUE(NavigateToURL(shell(), url_fragment_2)); |
| 959 EXPECT_EQ(1, installer.will_start_called()); |
| 960 EXPECT_EQ(1, installer.will_process_called()); |
| 961 EXPECT_FALSE(observer.is_same_page()); |
| 962 } |
| 963 |
| 964 // 5) Perform a new-document navigation by removing the fragment. |
| 965 { |
| 966 TestNavigationThrottleInstaller installer( |
| 967 shell()->web_contents(), NavigationThrottle::PROCEED, |
| 968 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); |
| 969 NavigationHandleObserver observer(shell()->web_contents(), url); |
| 970 EXPECT_TRUE(NavigateToURL(shell(), url)); |
| 971 EXPECT_EQ(1, installer.will_start_called()); |
| 972 EXPECT_EQ(1, installer.will_process_called()); |
| 973 EXPECT_FALSE(observer.is_same_page()); |
| 974 } |
| 975 } |
| 976 |
907 } // namespace content | 977 } // namespace content |
OLD | NEW |