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

Side by Side Diff: content/browser/browser_side_navigation_browsertest.cc

Issue 2386983002: PlzNavigate: cancel any navigations if DispatchBeforeUnload is called (other than for starting a ... (Closed)
Patch Set: guard against NavigatorImpl::RequestNavigation resetting the navigation, and add reduced test case Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/common/site_isolation_policy.h" 11 #include "content/common/site_isolation_policy.h"
12 #include "content/public/browser/notification_types.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
14 #include "content/public/common/url_constants.h" 15 #include "content/public/common/url_constants.h"
15 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/content_browser_test.h" 17 #include "content/public/test/content_browser_test.h"
17 #include "content/public/test/content_browser_test_utils.h" 18 #include "content/public/test/content_browser_test_utils.h"
18 #include "content/public/test/test_navigation_observer.h" 19 #include "content/public/test/test_navigation_observer.h"
19 #include "content/shell/browser/shell.h" 20 #include "content/shell/browser/shell.h"
20 #include "net/dns/mock_host_resolver.h" 21 #include "net/dns/mock_host_resolver.h"
21 #include "net/test/embedded_test_server/embedded_test_server.h" 22 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 console_delegate->Wait(); 265 console_delegate->Wait();
265 // Original page shouldn't navigate away. 266 // Original page shouldn't navigate away.
266 EXPECT_EQ(kUrl, shell()->web_contents()->GetURL()); 267 EXPECT_EQ(kUrl, shell()->web_contents()->GetURL());
267 EXPECT_FALSE(shell() 268 EXPECT_FALSE(shell()
268 ->web_contents() 269 ->web_contents()
269 ->GetController() 270 ->GetController()
270 .GetLastCommittedEntry() 271 .GetLastCommittedEntry()
271 ->IsViewSourceMode()); 272 ->IsViewSourceMode());
272 } 273 }
273 274
275 // Ensure that closing a page by running its beforeunload handler doesn't hang
276 // if there's an ongoing navigation.
277 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest,
278 UnloadDuringNavigation) {
279 content::WindowedNotificationObserver close_observer(
280 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
281 content::Source<content::WebContents>(shell()->web_contents()));
282 shell()->LoadURL(GURL("chrome://resources/css/tabs.css"));
283 shell()->web_contents()->DispatchBeforeUnload();
284 close_observer.Wait();
285 }
286
274 } // namespace content 287 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698