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..a638b9584dd32be90ce42a03303fe66f4d72a977 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")))); |
+ GURL frame_url(ui_test_utils::GetTestUrl( |
Bernhard Bauer
2013/09/12 13:39:22
Nit: You could move this declaration down to where
|
+ base::FilePath(kTestDir), |
+ base::FilePath(FILE_PATH_LITERAL("popup-frames-iframe.html")))); |
+ browser()->profile()->GetHostContentSettingsMap() |
Bernhard Bauer
2013/09/12 13:39:22
Nit: Extract the HCSM into a local variable?
|
+ ->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. |
+ 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 |
+// popus. |
Bernhard Bauer
2013/09/12 13:39:22
Nit: "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 |