OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
26 #include "chrome/test/base/test_switches.h" | 26 #include "chrome/test/base/test_switches.h" |
27 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
28 #include "components/content_settings/core/browser/host_content_settings_map.h" | 28 #include "components/content_settings/core/browser/host_content_settings_map.h" |
29 #include "components/omnibox/autocomplete_match.h" | 29 #include "components/omnibox/autocomplete_match.h" |
30 #include "components/omnibox/autocomplete_result.h" | 30 #include "components/omnibox/autocomplete_result.h" |
31 #include "content/public/browser/navigation_controller.h" | |
31 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
32 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/render_frame_host.h" | 34 #include "content/public/browser/render_frame_host.h" |
34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
35 #include "content/public/browser/web_contents_observer.h" | 36 #include "content/public/browser/web_contents_observer.h" |
36 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
37 #include "content/public/test/browser_test_utils.h" | 38 #include "content/public/test/browser_test_utils.h" |
38 #include "content/public/test/test_navigation_observer.h" | 39 #include "content/public/test/test_navigation_observer.h" |
39 #include "net/dns/mock_host_resolver.h" | 40 #include "net/dns/mock_host_resolver.h" |
40 #include "net/test/embedded_test_server/embedded_test_server.h" | 41 #include "net/test/embedded_test_server/embedded_test_server.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 } | 478 } |
478 | 479 |
479 // Verify that the renderer can't DOS the browser by creating arbitrarily many | 480 // Verify that the renderer can't DOS the browser by creating arbitrarily many |
480 // popups. | 481 // popups. |
481 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, DenialOfService) { | 482 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, DenialOfService) { |
482 GURL url(embedded_test_server()->GetURL("/popup_blocker/popup-dos.html")); | 483 GURL url(embedded_test_server()->GetURL("/popup_blocker/popup-dos.html")); |
483 ui_test_utils::NavigateToURL(browser(), url); | 484 ui_test_utils::NavigateToURL(browser(), url); |
484 ASSERT_EQ(25, GetBlockedContentsCount()); | 485 ASSERT_EQ(25, GetBlockedContentsCount()); |
485 } | 486 } |
486 | 487 |
488 // Verify that an onunload popup does not show up for about:blank. | |
489 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, Regress427477) { | |
490 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | |
491 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); | |
492 | |
493 GURL url( | |
494 embedded_test_server()->GetURL("/popup_blocker/popup-on-unload.html")); | |
495 ui_test_utils::NavigateToURL(browser(), url); | |
496 | |
497 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | |
498 | |
499 tab->GetController().GoBack(); | |
500 content::WaitForLoadStop(tab); | |
501 | |
502 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | |
503 browser()->host_desktop_type())); | |
504 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | |
505 | |
506 // The popup from th unload event handler should not show up for about:blank. | |
Charlie Reis
2014/11/10 17:41:26
nit: th -> the
jochen (gone - plz use gerrit)
2014/11/10 19:39:13
done
| |
507 ASSERT_EQ(0, GetBlockedContentsCount()); | |
508 } | |
509 | |
487 } // namespace | 510 } // namespace |
OLD | NEW |