| 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 "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/browser_side_navigation_policy.h" | 10 #include "content/public/common/browser_side_navigation_policy.h" |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 // EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, observer.net_error_code()); | 1113 // EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, observer.net_error_code()); |
| 1114 | 1114 |
| 1115 // Only one navigation is expected to happen. | 1115 // Only one navigation is expected to happen. |
| 1116 std::vector<GURL> started_navigation = {kRedirectingUrl}; | 1116 std::vector<GURL> started_navigation = {kRedirectingUrl}; |
| 1117 EXPECT_EQ(started_navigation, logger.started_navigation_urls()); | 1117 EXPECT_EQ(started_navigation, logger.started_navigation_urls()); |
| 1118 | 1118 |
| 1119 std::vector<GURL> finished_navigation = {kUrl}; | 1119 std::vector<GURL> finished_navigation = {kUrl}; |
| 1120 EXPECT_EQ(finished_navigation, logger.finished_navigation_urls()); | 1120 EXPECT_EQ(finished_navigation, logger.finished_navigation_urls()); |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 // Tests that when a navigation starts while there's an existing one, the first |
| 1124 // one has the right error code set on its navigation handle. |
| 1125 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest, ErrorCodeOnCancel) { |
| 1126 GURL slow_url = embedded_test_server()->GetURL("/slow?60"); |
| 1127 NavigationHandleObserver observer(shell()->web_contents(), slow_url); |
| 1128 shell()->LoadURL(slow_url); |
| 1129 |
| 1130 GURL url2(embedded_test_server()->GetURL("/title1.html")); |
| 1131 TestNavigationObserver same_tab_observer( |
| 1132 shell()->web_contents(), 1); |
| 1133 shell()->LoadURL(url2); |
| 1134 same_tab_observer.Wait(); |
| 1135 |
| 1136 EXPECT_EQ(net::ERR_ABORTED, observer.net_error_code()); |
| 1137 } |
| 1138 |
| 1123 // This class allows running tests with PlzNavigate enabled, regardless of | 1139 // This class allows running tests with PlzNavigate enabled, regardless of |
| 1124 // default test configuration. | 1140 // default test configuration. |
| 1125 class PlzNavigateNavigationHandleImplBrowserTest : public ContentBrowserTest { | 1141 class PlzNavigateNavigationHandleImplBrowserTest : public ContentBrowserTest { |
| 1126 public: | 1142 public: |
| 1127 PlzNavigateNavigationHandleImplBrowserTest() {} | 1143 PlzNavigateNavigationHandleImplBrowserTest() {} |
| 1128 | 1144 |
| 1129 void SetUpCommandLine(base::CommandLine* command_line) override { | 1145 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 1130 command_line->AppendSwitch(switches::kEnableBrowserSideNavigation); | 1146 command_line->AppendSwitch(switches::kEnableBrowserSideNavigation); |
| 1131 } | 1147 } |
| 1132 }; | 1148 }; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 NavigationHandleObserver observer(shell()->web_contents(), error_url); | 1212 NavigationHandleObserver observer(shell()->web_contents(), error_url); |
| 1197 EXPECT_FALSE(NavigateToURL(shell(), error_url)); | 1213 EXPECT_FALSE(NavigateToURL(shell(), error_url)); |
| 1198 EXPECT_TRUE(observer.has_committed()); | 1214 EXPECT_TRUE(observer.has_committed()); |
| 1199 EXPECT_TRUE(observer.is_error()); | 1215 EXPECT_TRUE(observer.is_error()); |
| 1200 EXPECT_NE(site_instance, | 1216 EXPECT_NE(site_instance, |
| 1201 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); | 1217 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); |
| 1202 } | 1218 } |
| 1203 } | 1219 } |
| 1204 | 1220 |
| 1205 } // namespace content | 1221 } // namespace content |
| OLD | NEW |