Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: functional/plugins.py

Issue 6015010: Adding tests for plugins section in content settings.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 9 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if 'Shockwave Flash' == plugin_name: 132 if 'Shockwave Flash' == plugin_name:
133 continue # cannot reload file:// flash URL - crbug.com/47249 133 continue # cannot reload file:// flash URL - crbug.com/47249
134 # Enable 134 # Enable
135 self._TogglePlugin(plugin_name) 135 self._TogglePlugin(plugin_name)
136 self.GetBrowserWindow(0).GetTab(0).Reload() 136 self.GetBrowserWindow(0).GetTab(0).Reload()
137 self.assertTrue([x for x in self.GetBrowserInfo()['child_processes'] 137 self.assertTrue([x for x in self.GetBrowserInfo()['child_processes']
138 if x['type'] == 'Plug-in' and 138 if x['type'] == 'Plug-in' and
139 re.search(plugin_name, x['name'])]) 139 re.search(plugin_name, x['name'])])
140 self.assertTrue(self._IsEnabled(plugin_name), plugin_name) 140 self.assertTrue(self._IsEnabled(plugin_name), plugin_name)
141 141
142 def testBlockAllPlugins(self):
143 """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.
144 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.
145 'plugin', 'flash-clicktoplay.html'))
146 self.NavigateToURL(flash_url)
147 pid = self._GetPluginPID('Shockwave Flash')
Nirnimesh 2011/01/07 22:44:23 s/pid/flash_pid/
sunandt 2011/01/13 00:29:34 Done.
148 self.assertTrue(pid, msg='No plugin process for Shockwave Flash')
149 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
150 self.assertTrue(self.WaitUntil(
151 lambda: self._GetPluginPID('Shockwave Flash') is None),
152 msg='Expected Shockwave Flash plugin to die after killing')
153
154 # Set the preference to block all plugins.
155 self.SetPrefs(pyauto.kDefaultContentSettings, {'plugins': 2})
156
157 self.GetBrowserWindow(0).GetTab(0).Reload()
158 self.assertFalse(self._GetPluginPID('Shockwave Flash'),
159 msg='Plug-in not blocked.')
160
161 def testAllowPluginException(self):
162 """Verify that plugins can be allowed on a domain by adding
163 an exception(s)."""
164 # Set the preference to block all plugins.
165 self.SetPrefs(pyauto.kDefaultContentSettings, {'plugins': 2})
166
167 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.
168 'plugin', 'flash-clicktoplay.html'))
169 self.NavigateToURL(flash_url)
170 # Check that plugins are blocked.
171 self.assertFalse(self._GetPluginPID('Shockwave Flash'),
172 msg='Plug-in not blocked.')
173
174 # Add an exception to allow plugins on youtube.com.
175 self.SetPrefs(pyauto.kContentSettingsPatterns,
176 {'[*.]youtube.com': { 'plugins': 1}})
177 self.AppendTab(pyauto.GURL('http://www.youtube.com'))
178 self.assertTrue(self._GetPluginPID('Shockwave Flash'),
179 msg='No plugin process for Shockwave Flash')
180
181 def testBlockPluginException(self):
182 """Verify that plugins can be blocked on a domain by adding
183 an exception(s)."""
184 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.
185 'plugin', 'flash-clicktoplay.html'))
186 self.NavigateToURL(flash_url)
187 pid = self._GetPluginPID('Shockwave Flash')
188 self.assertTrue(pid, msg='No plugin process for Shockwave Flash')
189 self.Kill(pid)
190 self.assertTrue(self.WaitUntil(
191 lambda: self._GetPluginPID('Shockwave Flash') is None),
192 msg='Expected Shockwave Flash plugin to die after killing')
193
194 # Add an exception to block plugins on youtube.com.
195 self.SetPrefs(pyauto.kContentSettingsPatterns,
196 {'[*.]youtube.com': { 'plugins': 2}})
197 self.AppendTab(pyauto.GURL('http://www.youtube.com'))
198 self.assertFalse(self._GetPluginPID('Shockwave Flash'),
199 msg='Plug-in not blocked.')
200
142 201
143 if __name__ == '__main__': 202 if __name__ == '__main__':
144 pyauto_functional.Main() 203 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698