OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import re | 8 import re |
9 | 9 |
10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 Returns: | 41 Returns: |
42 a list of 2-tuple, corresponding to the html file used for test and the | 42 a list of 2-tuple, corresponding to the html file used for test and the |
43 name of the plugin | 43 name of the plugin |
44 """ | 44 """ |
45 plugins = [('flash-clicktoplay.html', 'Shockwave Flash'), | 45 plugins = [('flash-clicktoplay.html', 'Shockwave Flash'), |
46 ('java_new.html', 'Java'),] # common to all platforms | 46 ('java_new.html', 'Java'),] # common to all platforms |
47 if self.IsWin() or self.IsMac(): | 47 if self.IsWin() or self.IsMac(): |
48 plugins = plugins + [ | 48 plugins = plugins + [ |
49 ('silverlight_new.html', 'Silverlight'), | 49 ('silverlight_new.html', 'Silverlight'), |
50 ('quicktime.html', 'Quicktime'), | 50 ('quicktime.html', 'QuickTime'), |
51 ('wmp_new.html', 'Windows Media'), | 51 ('wmp_new.html', 'Windows Media'), |
52 ('real.html', 'RealPlayer'), | 52 ('real.html', 'RealPlayer'), |
53 ] | 53 ] |
54 | 54 |
55 out = [] | 55 out = [] |
56 # Emit warnings for plugins that are not installed on the machine and | 56 # Emit warnings for plugins that are not installed on the machine and |
57 # therefore cannot be tested. | 57 # therefore cannot be tested. |
58 plugins_info = self.GetPluginsInfo() | 58 plugins_info = self.GetPluginsInfo() |
59 for fname, name in plugins: | 59 for fname, name in plugins: |
60 for a_plugin in plugins_info.Plugins(): | 60 for a_plugin in plugins_info.Plugins(): |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 self.EnablePlugin(plugin['path']) | 93 self.EnablePlugin(plugin['path']) |
94 | 94 |
95 def _IsEnabled(self, plugin_name): | 95 def _IsEnabled(self, plugin_name): |
96 """Checks if plugin is enabled.""" | 96 """Checks if plugin is enabled.""" |
97 for plugin in self.GetPluginsInfo().Plugins(): | 97 for plugin in self.GetPluginsInfo().Plugins(): |
98 if re.search(plugin_name, plugin['name']): | 98 if re.search(plugin_name, plugin['name']): |
99 return plugin['enabled'] | 99 return plugin['enabled'] |
100 | 100 |
101 def _PluginNeedsAuthorization(self, plugin_name): | 101 def _PluginNeedsAuthorization(self, plugin_name): |
102 # These plug-ins seek permission to run | 102 # These plug-ins seek permission to run |
103 return plugin_name in ['Java', 'Quicktime', 'Windows Media'] | 103 return plugin_name in ['Java', 'QuickTime', 'Windows Media', 'RealPlayer'] |
104 | 104 |
105 def testKillAndReloadAllPlugins(self): | 105 def testKillAndReloadAllPlugins(self): |
106 """Verify plugin processes and check if they can reload after killing.""" | 106 """Verify plugin processes and check if they can reload after killing.""" |
107 for fname, plugin_name in self._ObtainPluginsList(): | 107 for fname, plugin_name in self._ObtainPluginsList(): |
108 if plugin_name == 'Shockwave Flash': | 108 if plugin_name == 'Shockwave Flash': |
109 continue # cannot reload file:// flash URL - crbug.com/47249 | 109 continue # cannot reload file:// flash URL - crbug.com/47249 |
110 url = self.GetFileURLForPath( | 110 url = self.GetFileURLForPath( |
111 os.path.join(self.DataDir(), 'plugin', fname)) | 111 os.path.join(self.DataDir(), 'plugin', fname)) |
112 self.NavigateToURL(url) | 112 self.NavigateToURL(url) |
113 if self._PluginNeedsAuthorization(plugin_name): | 113 if self._PluginNeedsAuthorization(plugin_name): |
(...skipping 27 matching lines...) Expand all Loading... |
141 self.assertTrue(self._IsEnabled(plugin_name), | 141 self.assertTrue(self._IsEnabled(plugin_name), |
142 '%s not enabled initially.' % plugin_name) | 142 '%s not enabled initially.' % plugin_name) |
143 # Disable | 143 # Disable |
144 self._TogglePlugin(plugin_name) | 144 self._TogglePlugin(plugin_name) |
145 self.assertFalse(self._IsEnabled(plugin_name)) | 145 self.assertFalse(self._IsEnabled(plugin_name)) |
146 # Attempt to load a page that triggers the plugin and verify that it | 146 # Attempt to load a page that triggers the plugin and verify that it |
147 # indeed could not be loaded. | 147 # indeed could not be loaded. |
148 url = self.GetFileURLForPath( | 148 url = self.GetFileURLForPath( |
149 os.path.join(self.DataDir(), 'plugin', fname)) | 149 os.path.join(self.DataDir(), 'plugin', fname)) |
150 self.NavigateToURL(url) | 150 self.NavigateToURL(url) |
| 151 self.assertTrue(self.WaitUntil( |
| 152 lambda: self._GetPluginPID(plugin_name) is None )) |
151 self.assertFalse(self._GetPluginPID(plugin_name=plugin_name)) | 153 self.assertFalse(self._GetPluginPID(plugin_name=plugin_name)) |
152 if plugin_name == 'Shockwave Flash': | 154 if plugin_name == 'Shockwave Flash': |
153 continue # cannot reload file:// flash URL - crbug.com/47249 | 155 continue # cannot reload file:// flash URL - crbug.com/47249 |
154 if plugin_name == 'Java': | 156 if plugin_name == 'Java': |
155 continue # crbug.com/71223 | 157 continue # crbug.com/71223 |
156 # Enable | 158 # Enable |
157 self._TogglePlugin(plugin_name) | 159 self._TogglePlugin(plugin_name) |
158 self.GetBrowserWindow(0).GetTab(0).Reload() | 160 self.GetBrowserWindow(0).GetTab(0).Reload() |
159 if self._PluginNeedsAuthorization(plugin_name): | 161 if self._PluginNeedsAuthorization(plugin_name): |
160 self.assertTrue(self.WaitForInfobarCount(1)) | 162 self.assertTrue(self.WaitForInfobarCount(1)) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 # Add an exception to block plugins on localhost. | 226 # Add an exception to block plugins on localhost. |
225 self.SetPrefs(pyauto.kContentSettingsPatterns, | 227 self.SetPrefs(pyauto.kContentSettingsPatterns, |
226 {'[*.]127.0.0.1,*': {'plugins': 2}}) | 228 {'[*.]127.0.0.1,*': {'plugins': 2}}) |
227 self.GetBrowserWindow(0).GetTab(0).Reload() | 229 self.GetBrowserWindow(0).GetTab(0).Reload() |
228 self.assertFalse(self._GetPluginPID('Shockwave Flash'), | 230 self.assertFalse(self._GetPluginPID('Shockwave Flash'), |
229 msg='Shockwave Flash Plug-in not blocked.') | 231 msg='Shockwave Flash Plug-in not blocked.') |
230 | 232 |
231 | 233 |
232 if __name__ == '__main__': | 234 if __name__ == '__main__': |
233 pyauto_functional.Main() | 235 pyauto_functional.Main() |
OLD | NEW |