diff options
author | sunandt@chromium.org <sunandt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 22:49:32 +0000 |
---|---|---|
committer | sunandt@chromium.org <sunandt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 22:49:32 +0000 |
commit | 00207a41566893c9681d092eaa1ac7f31a5666e4 (patch) | |
tree | deff634970776bd0f739d64fad2a30d37ff7e85a | |
parent | 80e72d286383dd324e464e6254d66c8b28f0474d (diff) | |
download | chromium_src-00207a41566893c9681d092eaa1ac7f31a5666e4.zip chromium_src-00207a41566893c9681d092eaa1ac7f31a5666e4.tar.gz chromium_src-00207a41566893c9681d092eaa1ac7f31a5666e4.tar.bz2 |
Adding tests for plugins section in content settings.
1. testBlockAllPlugins
2. testAllowPluginException
3. testBlockPluginException
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6015010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71505 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/functional/plugins.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/test/functional/plugins.py b/chrome/test/functional/plugins.py index 9e52eb7..0a54b05 100644 --- a/chrome/test/functional/plugins.py +++ b/chrome/test/functional/plugins.py @@ -139,6 +139,69 @@ class PluginsTest(pyauto.PyUITest): re.search(plugin_name, x['name'])]) self.assertTrue(self._IsEnabled(plugin_name), plugin_name) + def testBlockAllPlugins(self): + """Verify that all the plugins can be blocked. + Verifying by checking that flash plugin was blocked. + """ + flash_url = self.GetFileURLForPath(os.path.join( + self.DataDir(), 'plugin', 'flash-clicktoplay.html')) + self.NavigateToURL(flash_url) + flash_pid = self._GetPluginPID('Shockwave Flash') + self.assertTrue(flash_pid, msg='No plugin process for Shockwave Flash') + # Killing the flash process as it takes a while before the plugin + # process is terminated even though there are no tabs using it. + self.Kill(flash_pid) + self.assertTrue(self.WaitUntil( + lambda: self._GetPluginPID('Shockwave Flash') is None), + msg='Expected Shockwave Flash plugin to die after killing') + + # Set the preference to block all plugins. + self.SetPrefs(pyauto.kDefaultContentSettings, {'plugins': 2}) + + self.GetBrowserWindow(0).GetTab(0).Reload() + self.assertFalse(self._GetPluginPID('Shockwave Flash'), + msg='Plug-in not blocked.') + + def testAllowPluginException(self): + """Verify that plugins can be allowed on a domain by adding + an exception(s).""" + # Set the preference to block all plugins. + self.SetPrefs(pyauto.kDefaultContentSettings, {'plugins': 2}) + + flash_url = self.GetFileURLForPath(os.path.join( + self.DataDir(), 'plugin', 'flash-clicktoplay.html')) + self.NavigateToURL(flash_url) + # Check that plugins are blocked. + self.assertFalse(self._GetPluginPID('Shockwave Flash'), + msg='Plug-in not blocked.') + + # Add an exception to allow plugins on hulu.com. + self.SetPrefs(pyauto.kContentSettingsPatterns, + {'[*.]hulu.com': {'plugins': 1}}) + self.AppendTab(pyauto.GURL('http://www.hulu.com')) + self.assertTrue(self._GetPluginPID('Shockwave Flash'), + msg='No plugin process for Shockwave Flash') + + def testBlockPluginException(self): + """Verify that plugins can be blocked on a domain by adding + an exception(s).""" + # We are using the same live site in order to detect if the web page + # is using shockwave flash process + self.NavigateToURL('http://www.hulu.com') + pid = self._GetPluginPID('Shockwave Flash') + self.assertTrue(pid, msg='No plugin process for Shockwave Flash') + self.Kill(pid) + self.assertTrue(self.WaitUntil( + lambda: self._GetPluginPID('Shockwave Flash') is None), + msg='Expected Shockwave Flash plugin to die after killing') + + # Add an exception to block plugins on hulu.com. + self.SetPrefs(pyauto.kContentSettingsPatterns, + {'[*.]hulu.com': {'plugins': 2}}) + self.GetBrowserWindow(0).GetTab(0).Reload() + self.assertFalse(self._GetPluginPID('Shockwave Flash'), + msg='Plug-in not blocked.') + if __name__ == '__main__': pyauto_functional.Main() |