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 81155278b2e37afe6a0bfba3c6ceca271b734aec..6f15f49dd40b623c928d32ac30d6664fa9a18b22 100644 |
--- a/chrome/browser/content_settings/content_settings_browsertest.cc |
+++ b/chrome/browser/content_settings/content_settings_browsertest.cc |
@@ -291,243 +291,6 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest, RedirectCrossOrigin) { |
IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); |
} |
-// 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::kEnableNpapiForTesting); |
- } |
-}; |
- |
-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() {} |
- |
- 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::kEnableNpapiForTesting); |
- } |
-}; |
- |
-IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) { |
- browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
- |
- GURL url = ui_test_utils::GetTestUrl( |
- base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); |
- ui_test_utils::NavigateToURL(browser(), url); |
- |
- base::string16 expected_title(base::ASCIIToUTF16("OK")); |
- content::TitleWatcher title_watcher( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
- |
- content::WebContents* web_contents = |
- browser()->tab_strip_model()->GetActiveWebContents(); |
- ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); |
- int process_id = web_contents->GetMainFrame()->GetProcess()->GetID(); |
- base::FilePath path(FILE_PATH_LITERAL("blah")); |
- EXPECT_FALSE(filter->CanLoadPlugin(process_id, path)); |
- filter->AuthorizeAllPlugins(web_contents, true, std::string()); |
- EXPECT_TRUE(filter->CanLoadPlugin(process_id, path)); |
- |
- EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
-} |
- |
-// Verify that plugins can be allowed on a domain by adding an exception |
-IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { |
- GURL url = ui_test_utils::GetTestUrl( |
- base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); |
- |
- browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
- browser()->profile()->GetHostContentSettingsMap() |
- ->SetContentSetting(ContentSettingsPattern::FromURL(url), |
- ContentSettingsPattern::Wildcard(), |
- CONTENT_SETTINGS_TYPE_PLUGINS, |
- std::string(), |
- CONTENT_SETTING_ALLOW); |
- |
- base::string16 expected_title(base::ASCIIToUTF16("OK")); |
- content::TitleWatcher title_watcher( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
- ui_test_utils::NavigateToURL(browser(), url); |
- EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
-} |
- |
-// Verify that plugins can be blocked on a domain by adding an exception. |
-IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, BlockException) { |
- GURL url = ui_test_utils::GetTestUrl( |
- base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); |
- |
- browser()->profile()->GetHostContentSettingsMap() |
- ->SetContentSetting(ContentSettingsPattern::FromURL(url), |
- ContentSettingsPattern::Wildcard(), |
- CONTENT_SETTINGS_TYPE_PLUGINS, |
- std::string(), |
- CONTENT_SETTING_BLOCK); |
- |
- base::string16 expected_title(base::ASCIIToUTF16("Click To Play")); |
- content::TitleWatcher title_watcher( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
- ui_test_utils::NavigateToURL(browser(), url); |
- EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
-} |
- |
-// Crashes on Mac Asan. http://crbug.com/239169 |
-#if defined(OS_MACOSX) |
-#define MAYBE_LoadAllBlockedPlugins DISABLED_LoadAllBlockedPlugins |
-// TODO(jschuh): Flaky plugin tests. crbug.com/244653 |
-#elif defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
-#define MAYBE_LoadAllBlockedPlugins DISABLED_LoadAllBlockedPlugins |
-#else |
-#define MAYBE_LoadAllBlockedPlugins LoadAllBlockedPlugins |
-#endif |
-IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, MAYBE_LoadAllBlockedPlugins) { |
- browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
- |
- GURL url = ui_test_utils::GetTestUrl( |
- base::FilePath(), |
- base::FilePath().AppendASCII("load_all_blocked_plugins.html")); |
- ui_test_utils::NavigateToURL(browser(), url); |
- |
- base::string16 expected_title1(base::ASCIIToUTF16("1")); |
- content::TitleWatcher title_watcher1( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title1); |
- |
- ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
- browser()->tab_strip_model()->GetActiveWebContents(), true, |
- std::string()); |
- EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); |
- |
- base::string16 expected_title2(base::ASCIIToUTF16("2")); |
- content::TitleWatcher title_watcher2( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title2); |
- |
- ASSERT_TRUE(content::ExecuteScript( |
- browser()->tab_strip_model()->GetActiveWebContents(), "window.inject()")); |
- |
- EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle()); |
-} |
- |
-// If this flakes, use http://crbug.com/113057. |
-// TODO(jschuh): Hanging plugin tests. crbug.com/244653 |
-#if !defined(OS_WIN) && !defined(ARCH_CPU_X86_64) |
-IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, NoCallbackAtLoad) { |
- browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
- |
- GURL url("data:application/vnd.npapi-test,CallOnStartup();"); |
- ui_test_utils::NavigateToURL(browser(), url); |
- |
- std::string script("CallOnStartup = function() { "); |
- script.append("document.documentElement.appendChild"); |
- script.append("(document.createElement(\"head\")); "); |
- script.append("document.title = \"OK\"; }"); |
- |
- // Inject the callback function into the HTML page generated by the browser. |
- ASSERT_TRUE(content::ExecuteScript( |
- browser()->tab_strip_model()->GetActiveWebContents(), script)); |
- |
- base::string16 expected_title(base::ASCIIToUTF16("OK")); |
- content::TitleWatcher title_watcher( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
- |
- ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
- browser()->tab_strip_model()->GetActiveWebContents(), true, |
- std::string()); |
- |
- EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
-} |
-#endif |
- |
-IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { |
- browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); |
- |
- GURL url = ui_test_utils::GetTestUrl( |
- base::FilePath(), |
- base::FilePath().AppendASCII("plugin_delete_self_at_load.html")); |
- ui_test_utils::NavigateToURL(browser(), url); |
- |
- base::string16 expected_title(base::ASCIIToUTF16("OK")); |
- content::TitleWatcher title_watcher( |
- browser()->tab_strip_model()->GetActiveWebContents(), expected_title); |
- |
- ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
- browser()->tab_strip_model()->GetActiveWebContents(), true, |
- std::string()); |
- |
- EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
-} |
- |
-#endif // !defined(USE_AURA) || defined(OS_WIN) |
- |
#if defined(ENABLE_PLUGINS) |
class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest { |
protected: |