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

Unified Diff: chrome/browser/subresource_filter/subresource_filter_browsertest.cc

Issue 2822773002: [subresource_filter] Force the popup blocker on sites with activation (Closed)
Patch Set: engedy review Created 3 years, 8 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
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..416ebd04d4fb2a3b35fbad880c026cf0e9c07e92 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,44 @@ IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest,
std::vector<const char*>{"b", "d"}, {false, true});
}
+IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest, BlockCreatingNewWindows) {
+ base::HistogramTester tester;
+ const char kWindowOpenPath[] = "/subresource_filter/window_open.html";
+ GURL a_url(embedded_test_server()->GetURL("a.com", kWindowOpenPath));
+ GURL b_url(embedded_test_server()->GetURL("b.com", kWindowOpenPath));
+ // Only configure |a_url| as a phishing URL.
+ ConfigureAsPhishingURL(a_url);
+
+ // Only necessary so we have a valid ruleset.
+ ASSERT_NO_FATAL_FAILURE(SetRulesetWithRules(std::vector<proto::UrlRule>()));
+
+ // Navigate to a_url, should trigger the popup blocker.
+ ui_test_utils::NavigateToURL(browser(), a_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);
+ // 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));
+
+ // Navigate to |b_url|, which should successfully open the popup.
+ ui_test_utils::NavigateToURL(browser(), b_url);
+ opened_window = false;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(web_contents, "openWindow()",
+ &opened_window));
+ EXPECT_TRUE(opened_window);
+ // Popup UI should not be shown.
+ EXPECT_FALSE(TabSpecificContentSettings::FromWebContents(web_contents)
+ ->IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
+}
+
IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest,
ContentSettingsWhitelist_DoNotActivate) {
ASSERT_NO_FATAL_FAILURE(
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/test/data/subresource_filter/window_open.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698