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

Side by Side Diff: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc

Issue 707223004: Don't report blocked web contents from already navigated render views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 6 years, 1 month 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
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 the unload event handler should not show up for about:blank.
507 ASSERT_EQ(0, GetBlockedContentsCount());
508 }
509
487 } // namespace 510 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698