OLD | NEW |
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/frame_host/navigation_handle_impl.h" | 10 #include "content/browser/frame_host/navigation_handle_impl.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 ->IsViewSourceMode()); | 275 ->IsViewSourceMode()); |
276 } | 276 } |
277 | 277 |
278 // Ensure that closing a page by running its beforeunload handler doesn't hang | 278 // Ensure that closing a page by running its beforeunload handler doesn't hang |
279 // if there's an ongoing navigation. | 279 // if there's an ongoing navigation. |
280 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, | 280 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, |
281 UnloadDuringNavigation) { | 281 UnloadDuringNavigation) { |
282 content::WindowedNotificationObserver close_observer( | 282 content::WindowedNotificationObserver close_observer( |
283 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 283 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
284 content::Source<content::WebContents>(shell()->web_contents())); | 284 content::Source<content::WebContents>(shell()->web_contents())); |
285 GURL url( | 285 GURL url = |
286 "data:text/html,<html><script>window.onbeforeunload=function(e)" | 286 embedded_test_server()->GetURL("/page_with_empty_beforeunload.html"); |
287 "{}</script></html>"); | |
288 NavigateToURL(shell(), url); | 287 NavigateToURL(shell(), url); |
289 shell()->LoadURL(GURL("chrome://resources/css/tabs.css")); | 288 shell()->LoadURL(GURL("chrome://resources/css/tabs.css")); |
290 shell()->web_contents()->DispatchBeforeUnload(); | 289 shell()->web_contents()->DispatchBeforeUnload(); |
291 close_observer.Wait(); | 290 close_observer.Wait(); |
292 } | 291 } |
293 | 292 |
294 // Ensure that the referrer of a navigation is properly sanitized. | 293 // Ensure that the referrer of a navigation is properly sanitized. |
295 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, SanitizeReferrer) { | 294 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, SanitizeReferrer) { |
296 const GURL kInsecureUrl(embedded_test_server()->GetURL("/title1.html")); | 295 const GURL kInsecureUrl(embedded_test_server()->GetURL("/title1.html")); |
297 const Referrer kSecureReferrer( | 296 const Referrer kSecureReferrer( |
(...skipping 18 matching lines...) Expand all Loading... |
316 EXPECT_EQ(GURL(), | 315 EXPECT_EQ(GURL(), |
317 root->navigation_request()->navigation_handle()->GetReferrer().url); | 316 root->navigation_request()->navigation_handle()->GetReferrer().url); |
318 | 317 |
319 // The navigation should commit without being blocked. | 318 // The navigation should commit without being blocked. |
320 EXPECT_TRUE(manager.WaitForResponse()); | 319 EXPECT_TRUE(manager.WaitForResponse()); |
321 manager.WaitForNavigationFinished(); | 320 manager.WaitForNavigationFinished(); |
322 EXPECT_EQ(kInsecureUrl, shell()->web_contents()->GetLastCommittedURL()); | 321 EXPECT_EQ(kInsecureUrl, shell()->web_contents()->GetLastCommittedURL()); |
323 } | 322 } |
324 | 323 |
325 } // namespace content | 324 } // namespace content |
OLD | NEW |