diff options
author | wfh <wfh@chromium.org> | 2015-01-21 06:36:46 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-21 14:38:17 +0000 |
commit | 0539f2f5214fc17fdd5d1964be0ceedf98fdb9ce (patch) | |
tree | 1f30ce9cd48cba479715c1cc6d6cbe8bb02d404b /chrome/browser/content_settings | |
parent | d7ce058384dd92263b59836d11e6fde7950e3eb7 (diff) | |
download | chromium_src-0539f2f5214fc17fdd5d1964be0ceedf98fdb9ce.zip chromium_src-0539f2f5214fc17fdd5d1964be0ceedf98fdb9ce.tar.gz chromium_src-0539f2f5214fc17fdd5d1964be0ceedf98fdb9ce.tar.bz2 |
Block NPAPI plugins by default
Add --enable-npapi flag in chrome://flags to support re-enable.
BUG=295137
TEST=browser_tests, unit_tests, content_browsertests, blink layout tests
Review URL: https://codereview.chromium.org/645203002
Cr-Commit-Position: refs/heads/master@{#312374}
Diffstat (limited to 'chrome/browser/content_settings')
-rw-r--r-- | chrome/browser/content_settings/content_settings_browsertest.cc | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc index f6f0606..1ed96bb 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) { |