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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl_browsertest.cc

Issue 2901833002: Create NavigationHandle after beforeunload with PlzNavigate. (Closed)
Patch Set: small fix from jam Created 3 years, 7 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "content/browser/frame_host/navigation_handle_impl.h" 7 #include "content/browser/frame_host/navigation_handle_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents_observer.h" 10 #include "content/public/browser/web_contents_observer.h"
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 std::string("/server-redirect?") + kChromeUINetworkErrorsListingURL); 1061 std::string("/server-redirect?") + kChromeUINetworkErrorsListingURL);
1062 NavigationHandleObserver observer(shell()->web_contents(), redirect_url); 1062 NavigationHandleObserver observer(shell()->web_contents(), redirect_url);
1063 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1); 1063 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
1064 EXPECT_TRUE( 1064 EXPECT_TRUE(
1065 ExecuteScript(shell(), base::StringPrintf("location.href = '%s';", 1065 ExecuteScript(shell(), base::StringPrintf("location.href = '%s';",
1066 redirect_url.spec().c_str()))); 1066 redirect_url.spec().c_str())));
1067 same_tab_observer.Wait(); 1067 same_tab_observer.Wait();
1068 EXPECT_EQ(net::ERR_ABORTED, observer.net_error_code()); 1068 EXPECT_EQ(net::ERR_ABORTED, observer.net_error_code());
1069 } 1069 }
1070 1070
1071 // Tests that when a navigation is aborted (i.e. because of beforeunload), the
1072 // right error code is set on the NavigationHandle.
1073 IN_PROC_BROWSER_TEST_F(NavigationHandleImplBrowserTest,
1074 ErrorCodeOnAbortedNavigation) {
1075 // Without PlzNavigate, NavigationHandles aren't created until after the
1076 // beforeunload handler runs.
1077 if (!IsBrowserSideNavigationEnabled())
1078 return;
1079 GURL url(
1080 embedded_test_server()->GetURL("/render_frame_host/beforeunload.html"));
1081 EXPECT_TRUE(NavigateToURL(shell(), url));
1082
1083 GURL new_url("/title1.html");
1084 NavigationHandleObserver observer(shell()->web_contents(), new_url);
1085 TestNavigationManager navigation_waiter(shell()->web_contents(), new_url);
1086 PrepContentsForBeforeUnloadTest(shell()->web_contents());
1087 SetShouldProceedOnBeforeUnload(shell(), false);
1088
1089 shell()->LoadURL(new_url);
1090 WaitForAppModalDialog(shell());
1091 static_cast<WebContentsImpl*>(shell()->web_contents())
1092 ->CancelModalDialogsForRenderManager();
1093 navigation_waiter.WaitForNavigationFinished();
1094 EXPECT_EQ(net::ERR_ABORTED, observer.net_error_code());
1095 }
1096
1097 // This class allows running tests with PlzNavigate enabled, regardless of 1071 // This class allows running tests with PlzNavigate enabled, regardless of
1098 // default test configuration. 1072 // default test configuration.
1099 class PlzNavigateNavigationHandleImplBrowserTest : public ContentBrowserTest { 1073 class PlzNavigateNavigationHandleImplBrowserTest : public ContentBrowserTest {
1100 public: 1074 public:
1101 PlzNavigateNavigationHandleImplBrowserTest() {} 1075 PlzNavigateNavigationHandleImplBrowserTest() {}
1102 1076
1103 void SetUpCommandLine(base::CommandLine* command_line) override { 1077 void SetUpCommandLine(base::CommandLine* command_line) override {
1104 command_line->AppendSwitch(switches::kEnableBrowserSideNavigation); 1078 command_line->AppendSwitch(switches::kEnableBrowserSideNavigation);
1105 } 1079 }
1106 1080
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 EXPECT_TRUE(last_committed); 1236 EXPECT_TRUE(last_committed);
1263 EXPECT_EQ(blocked_url, last_committed->GetVirtualURL()); 1237 EXPECT_EQ(blocked_url, last_committed->GetVirtualURL());
1264 EXPECT_EQ(PAGE_TYPE_ERROR, last_committed->GetPageType()); 1238 EXPECT_EQ(PAGE_TYPE_ERROR, last_committed->GetPageType());
1265 EXPECT_NE(web_ui_process.get(), web_contents->GetSiteInstance()); 1239 EXPECT_NE(web_ui_process.get(), web_contents->GetSiteInstance());
1266 EXPECT_TRUE(commit_observer.has_committed()); 1240 EXPECT_TRUE(commit_observer.has_committed());
1267 EXPECT_TRUE(commit_observer.is_error()); 1241 EXPECT_TRUE(commit_observer.is_error());
1268 EXPECT_FALSE(commit_observer.is_renderer_initiated()); 1242 EXPECT_FALSE(commit_observer.is_renderer_initiated());
1269 } 1243 }
1270 1244
1271 } // namespace content 1245 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.cc ('k') | content/browser/frame_host/navigation_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698