Chromium Code Reviews| Index: functional/plugins.py | 
| =================================================================== | 
| --- functional/plugins.py (revision 70178) | 
| +++ functional/plugins.py (working copy) | 
| @@ -139,6 +139,65 @@ | 
| re.search(plugin_name, x['name'])]) | 
| self.assertTrue(self._IsEnabled(plugin_name), plugin_name) | 
| + def testBlockAllPlugins(self): | 
| + """Verify that all the plugins are blocked.""" | 
| 
 
Nirnimesh
2011/01/07 22:44:23
s/are/can be/
 
Nirnimesh
2011/01/07 22:44:23
Add: Verifies by checking that flash plugin was bl
 
sunandt
2011/01/13 00:29:34
Done.
 
sunandt
2011/01/13 00:29:34
Done.
 
 | 
| + flash_url = self.GetFileURLForPath(os.path.join(self.DataDir(), | 
| 
 
Nirnimesh
2011/01/07 22:44:23
it's ok to move all args from self.DataDir() to ne
 
sunandt
2011/01/13 00:29:34
Done.
 
 | 
| + 'plugin', 'flash-clicktoplay.html')) | 
| + self.NavigateToURL(flash_url) | 
| + pid = self._GetPluginPID('Shockwave Flash') | 
| 
 
Nirnimesh
2011/01/07 22:44:23
s/pid/flash_pid/
 
sunandt
2011/01/13 00:29:34
Done.
 
 | 
| + self.assertTrue(pid, msg='No plugin process for Shockwave Flash') | 
| + self.Kill(pid) | 
| 
 
Nirnimesh
2011/01/07 22:44:23
Is it necessary to Kill?
 
sunandt
2011/01/13 00:29:34
Yes. Because the flash process is not killed immed
 
 | 
| + 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(), | 
| 
 
Nirnimesh
2011/01/07 22:44:23
repeat
 
sunandt
2011/01/13 00:29:34
Done.
 
 | 
| + '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 youtube.com. | 
| + self.SetPrefs(pyauto.kContentSettingsPatterns, | 
| + {'[*.]youtube.com': { 'plugins': 1}}) | 
| + self.AppendTab(pyauto.GURL('http://www.youtube.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).""" | 
| + flash_url = self.GetFileURLForPath(os.path.join(self.DataDir(), | 
| 
 
Nirnimesh
2011/01/07 22:44:23
repeat
 
sunandt
2011/01/13 00:29:34
Done.
 
 | 
| + 'plugin', 'flash-clicktoplay.html')) | 
| + self.NavigateToURL(flash_url) | 
| + 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 youtube.com. | 
| + self.SetPrefs(pyauto.kContentSettingsPatterns, | 
| + {'[*.]youtube.com': { 'plugins': 2}}) | 
| + self.AppendTab(pyauto.GURL('http://www.youtube.com')) | 
| + self.assertFalse(self._GetPluginPID('Shockwave Flash'), | 
| + msg='Plug-in not blocked.') | 
| + | 
| + | 
| if __name__ == '__main__': | 
| pyauto_functional.Main() |