Chromium Code Reviews| 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 2c4bc273d65ed3f9b3de4e2ab70be4f7b8c4baa0..3e9914385fde7c4b139b4b9442ebd0a426acb453 100644 |
| --- a/chrome/browser/content_settings/content_settings_browsertest.cc |
| +++ b/chrome/browser/content_settings/content_settings_browsertest.cc |
| @@ -294,18 +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(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 defined(OS_MACOSX) || defined(OS_WIN) |
|
jam
2014/10/20 15:50:32
ditto
Will Harris
2014/10/20 17:59:56
Done.
|
| + if (expect_loaded) |
| + command_line->AppendSwitch(switches::kEnableNpapi); |
| +#endif |
| + } |
| +}; |
| + |
| +class DisabledPluginTest : public LoadPluginTest { |
| + public: |
| + DisabledPluginTest() {} |
| + |
| + virtual void SetUpCommandLine(CommandLine* command_line) override { |
| + SetUpCommandLineInternal(command_line, false); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(DisabledPluginTest, Load) { |
| + PerformTest(false); |
| +} |
| + |
| +class EnabledPluginTest : public LoadPluginTest { |
| + public: |
| + EnabledPluginTest() {} |
| + |
| + virtual void SetUpCommandLine(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) |
| +#if defined(OS_WIN) || defined(OS_MACOSX) |
| virtual void SetUpCommandLine(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); |
| } |
| #endif |
| }; |