Index: chrome/browser/subresource_filter/subresource_filter_browsertest.cc |
diff --git a/chrome/browser/subresource_filter/subresource_filter_browsertest.cc b/chrome/browser/subresource_filter/subresource_filter_browsertest.cc |
index 9aa2ddb77d7944964cc57c1930c8df379610699c..ffefb49e495543d20f6577672a4907f82c155b40 100644 |
--- a/chrome/browser/subresource_filter/subresource_filter_browsertest.cc |
+++ b/chrome/browser/subresource_filter/subresource_filter_browsertest.cc |
@@ -20,6 +20,7 @@ |
#include "base/test/histogram_tester.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
+#include "chrome/browser/content_settings/tab_specific_content_settings.h" |
#include "chrome/browser/metrics/subprocess_metrics_provider.h" |
#include "chrome/browser/page_load_metrics/observers/subresource_filter_metrics_observer.h" |
#include "chrome/browser/safe_browsing/test_safe_browsing_service.h" |
@@ -881,6 +882,30 @@ IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest, |
std::vector<const char*>{"b", "d"}, {false, true}); |
} |
+IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest, BlockCreatingNewWindows) { |
+ base::HistogramTester tester; |
+ GURL url(GetTestUrl("subresource_filter/window_open.html")); |
+ ConfigureAsPhishingURL(url); |
+ // Only necessary so we have a valid ruleset. |
+ ASSERT_NO_FATAL_FAILURE( |
+ SetRulesetWithRules({testing::CreateSuffixRule("included_script.js")})); |
engedy
2017/04/24 10:03:27
Would passing std::vector<proto::UrlRule>(), that
Charlie Harrison
2017/04/24 15:41:55
Yep, done.
|
+ ui_test_utils::NavigateToURL(browser(), url); |
+ bool opened_window = false; |
+ content::WebContents* web_contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, "openWindow()", |
+ &opened_window)); |
+ EXPECT_FALSE(opened_window); |
engedy
2017/04/24 10:03:27
For good measure, let's augment this test so that
Charlie Harrison
2017/04/24 15:41:55
Done.
|
+ // Do not force the UI if the popup was the only thing disallowed. The popup |
+ // UI is good enough. |
+ tester.ExpectBucketCount(kSubresourceFilterActionsHistogram, kActionUIShown, |
+ 0); |
+ |
+ // Make sure the popup UI was shown. |
+ EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents) |
+ ->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest, |
ContentSettingsWhitelist_DoNotActivate) { |
ASSERT_NO_FATAL_FAILURE( |