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( | |
286 "data:text/html,<html><script>window.onbeforeunload=function(e)" | |
nasko
2017/03/29 23:31:26
Why not create a simple html file in content/test/
jam
2017/03/30 14:53:22
Done.
| |
287 "{}</script></html>"); | |
288 NavigateToURL(shell(), url); | |
285 shell()->LoadURL(GURL("chrome://resources/css/tabs.css")); | 289 shell()->LoadURL(GURL("chrome://resources/css/tabs.css")); |
286 shell()->web_contents()->DispatchBeforeUnload(); | 290 shell()->web_contents()->DispatchBeforeUnload(); |
287 close_observer.Wait(); | 291 close_observer.Wait(); |
288 } | 292 } |
289 | 293 |
290 // Ensure that the referrer of a navigation is properly sanitized. | 294 // Ensure that the referrer of a navigation is properly sanitized. |
291 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, SanitizeReferrer) { | 295 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, SanitizeReferrer) { |
292 const GURL kInsecureUrl(embedded_test_server()->GetURL("/title1.html")); | 296 const GURL kInsecureUrl(embedded_test_server()->GetURL("/title1.html")); |
293 const Referrer kSecureReferrer( | 297 const Referrer kSecureReferrer( |
294 GURL("https://secure-url.com"), | 298 GURL("https://secure-url.com"), |
(...skipping 17 matching lines...) Expand all Loading... | |
312 EXPECT_EQ(GURL(), | 316 EXPECT_EQ(GURL(), |
313 root->navigation_request()->navigation_handle()->GetReferrer().url); | 317 root->navigation_request()->navigation_handle()->GetReferrer().url); |
314 | 318 |
315 // The navigation should commit without being blocked. | 319 // The navigation should commit without being blocked. |
316 EXPECT_TRUE(manager.WaitForResponse()); | 320 EXPECT_TRUE(manager.WaitForResponse()); |
317 manager.WaitForNavigationFinished(); | 321 manager.WaitForNavigationFinished(); |
318 EXPECT_EQ(kInsecureUrl, shell()->web_contents()->GetLastCommittedURL()); | 322 EXPECT_EQ(kInsecureUrl, shell()->web_contents()->GetLastCommittedURL()); |
319 } | 323 } |
320 | 324 |
321 } // namespace content | 325 } // namespace content |
OLD | NEW |