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

Unified Diff: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc

Issue 23600041: Add tests for recent popup blocker fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/popup_blocker/popup-dos.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
diff --git a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
index 293cca3cc82653b144b203b471cddf1101046a42..b391f642fc5b27e9fb2a67cb557ac26fcebbf7ab 100644
--- a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
+++ b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
@@ -258,6 +258,41 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
NavigateAndCheckPopupShown(url);
}
+// Verify that content settings are applied based on the top-level frame URL.
+IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
+ AllowPopupThroughContentSettingIFrame) {
+ GURL url(ui_test_utils::GetTestUrl(
+ base::FilePath(kTestDir),
+ base::FilePath(FILE_PATH_LITERAL("popup-frames.html"))));
+ browser()->profile()->GetHostContentSettingsMap()
+ ->SetContentSetting(ContentSettingsPattern::FromURL(url),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ std::string(),
+ CONTENT_SETTING_ALLOW);
+
+ // Popup from the iframe should be allowed since the top-level URL is
+ // whitelisted.
+ NavigateAndCheckPopupShown(url);
+
+ // Whitelist iframe URL instead.
+ GURL frame_url(ui_test_utils::GetTestUrl(
+ base::FilePath(kTestDir),
+ base::FilePath(FILE_PATH_LITERAL("popup-frames-iframe.html"))));
+ browser()->profile()->GetHostContentSettingsMap()->ClearSettingsForOneType(
+ CONTENT_SETTINGS_TYPE_POPUPS);
+ browser()->profile()->GetHostContentSettingsMap()
+ ->SetContentSetting(ContentSettingsPattern::FromURL(frame_url),
+ ContentSettingsPattern::Wildcard(),
+ CONTENT_SETTINGS_TYPE_POPUPS,
+ std::string(),
+ CONTENT_SETTING_ALLOW);
+
+ // Popup should be blocked.
+ ui_test_utils::NavigateToURL(browser(), url);
+ ASSERT_EQ(1, GetBlockedContentsCount());
+}
+
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
PopupsLaunchWhenTabIsClosed) {
CommandLine::ForCurrentProcess()->AppendSwitch(
@@ -367,4 +402,14 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, WebUI) {
EXPECT_EQ(GURL(content::kAboutBlankURL), popup->GetURL());
}
+// Verify that the renderer can't DOS the browser by creating arbitrarily many
+// popups.
+IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, DenialOfService) {
+ GURL url(ui_test_utils::GetTestUrl(
+ base::FilePath(kTestDir),
+ base::FilePath(FILE_PATH_LITERAL("popup-dos.html"))));
+ ui_test_utils::NavigateToURL(browser(), url);
+ ASSERT_EQ(25, GetBlockedContentsCount());
+}
+
} // namespace
« no previous file with comments | « no previous file | chrome/test/data/popup_blocker/popup-dos.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698