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

Unified Diff: chrome/browser/content_settings/content_settings_browsertest.cc

Issue 645203002: Block NPAPI plugins by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move UMA outside ifdef Created 5 years, 11 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 | « chrome/browser/about_flags.cc ('k') | chrome/browser/plugins/plugin_prefs_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_settings/content_settings_browsertest.cc
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc
index f6f0606d0ef9cf8990258e25caaabb51d128197c..1ed96bbd3a47a872ee4142be98028437f4151bb5 100644
--- a/chrome/browser/content_settings/content_settings_browsertest.cc
+++ b/chrome/browser/content_settings/content_settings_browsertest.cc
@@ -294,20 +294,84 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest, RedirectCrossOrigin) {
// On Aura NPAPI only works on Windows.
#if !defined(USE_AURA) || defined(OS_WIN)
+class LoadPluginTest : public ContentSettingsTest {
+ protected:
+ void PerformTest(bool expect_loaded) {
+ GURL url = ui_test_utils::GetTestUrl(
+ base::FilePath(),
+ base::FilePath().AppendASCII("load_npapi_plugin.html"));
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded";
+ const char* unexpected_result = expect_loaded ? "Not Loaded" : "Loaded";
+
+ base::string16 expected_title(base::ASCIIToUTF16(expected_result));
+ base::string16 unexpected_title(base::ASCIIToUTF16(unexpected_result));
+
+ content::TitleWatcher title_watcher(
+ browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
+ title_watcher.AlsoWaitForTitle(unexpected_title);
+
+ EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
+ }
+
+ void SetUpCommandLineInternal(base::CommandLine* command_line,
+ bool expect_loaded) {
+#if defined(OS_MACOSX)
+ base::FilePath plugin_dir;
+ PathService::Get(base::DIR_MODULE, &plugin_dir);
+ plugin_dir = plugin_dir.AppendASCII("plugins");
+ // The plugins directory isn't read by default on the Mac, so it needs to be
+ // explicitly registered.
+ command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir);
+#endif
+ command_line->AppendSwitch(switches::kAlwaysAuthorizePlugins);
+ if (expect_loaded)
+ command_line->AppendSwitch(switches::kEnableNpapi);
+ }
+};
+
+class DisabledPluginTest : public LoadPluginTest {
+ public:
+ DisabledPluginTest() {}
+
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ SetUpCommandLineInternal(command_line, false);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(DisabledPluginTest, Load) {
+ PerformTest(false);
+}
+
+class EnabledPluginTest : public LoadPluginTest {
+ public:
+ EnabledPluginTest() {}
+
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ SetUpCommandLineInternal(command_line, true);
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(EnabledPluginTest, Load) {
+ PerformTest(true);
+}
+
class ClickToPlayPluginTest : public ContentSettingsTest {
public:
ClickToPlayPluginTest() {}
-#if defined(OS_MACOSX)
void SetUpCommandLine(base::CommandLine* command_line) override {
+#if defined(OS_MACOSX)
base::FilePath plugin_dir;
PathService::Get(base::DIR_MODULE, &plugin_dir);
plugin_dir = plugin_dir.AppendASCII("plugins");
// The plugins directory isn't read by default on the Mac, so it needs to be
// explicitly registered.
command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir);
- }
#endif
+ command_line->AppendSwitch(switches::kEnableNpapi);
+ }
};
IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) {
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/plugins/plugin_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698