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

Side by Side Diff: chrome/test/functional/extensions.py

Issue 8649004: Allow chromedriver to install an extension and get all installed extension IDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 1 month 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
OLDNEW
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 """ 6 """
7 This module is a simple qa tool that installs extensions and tests whether the 7 This module is a simple qa tool that installs extensions and tests whether the
8 browser crashes while visiting a list of urls. 8 browser crashes while visiting a list of urls.
9 9
10 Usage: python extensions.py -v 10 Usage: python extensions.py -v
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 curr_extension = 0 54 curr_extension = 0
55 num_extensions = len(extensions) 55 num_extensions = len(extensions)
56 self.RestartBrowser() 56 self.RestartBrowser()
57 orig_extension_ids = self._GetInstalledExtensionIds() 57 orig_extension_ids = self._GetInstalledExtensionIds()
58 58
59 while curr_extension < num_extensions: 59 while curr_extension < num_extensions:
60 logging.debug('New group of %d extensions.' % group_size) 60 logging.debug('New group of %d extensions.' % group_size)
61 group_end = curr_extension + group_size 61 group_end = curr_extension + group_size
62 for extension in extensions[curr_extension:group_end]: 62 for extension in extensions[curr_extension:group_end]:
63 logging.debug('Installing extension: %s' % extension) 63 logging.debug('Installing extension: %s' % extension)
64 self.InstallExtension(extension, False) 64 self.InstallExtension(extension)
65 65
66 for url in top_urls: 66 for url in top_urls:
67 self.NavigateToURL(url) 67 self.NavigateToURL(url)
68 68
69 def _LogAndReturnCrashing(): 69 def _LogAndReturnCrashing():
70 crashing_extensions = extensions[curr_extension:group_end] 70 crashing_extensions = extensions[curr_extension:group_end]
71 logging.debug('Crashing extensions: %s' % crashing_extensions) 71 logging.debug('Crashing extensions: %s' % crashing_extensions)
72 return crashing_extensions 72 return crashing_extensions
73 73
74 # If the browser has crashed, return the extensions in the failing group. 74 # If the browser has crashed, return the extensions in the failing group.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 self.assertTrue(len(permissions_api) == 3 and 147 self.assertTrue(len(permissions_api) == 3 and
148 'bookmarks' in permissions_api and 148 'bookmarks' in permissions_api and
149 'experimental' in permissions_api and 149 'experimental' in permissions_api and
150 'tabs' in permissions_api, 150 'tabs' in permissions_api,
151 msg='Unexpected host permissions information.') 151 msg='Unexpected host permissions information.')
152 152
153 def testSetExtensionStates(self): 153 def testSetExtensionStates(self):
154 """Test setting different extension states.""" 154 """Test setting different extension states."""
155 crx_file_path = os.path.abspath( 155 crx_file_path = os.path.abspath(
156 os.path.join(self.DataDir(), 'extensions', 'google_talk.crx')) 156 os.path.join(self.DataDir(), 'extensions', 'google_talk.crx'))
157 ext_id = self.InstallExtension(crx_file_path, False); 157 ext_id = self.InstallExtension(crx_file_path)
158 self.assertTrue(ext_id, 'Failed to install extension.')
159 158
160 # Verify extension is in default state. 159 # Verify extension is in default state.
161 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) 160 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id)
162 self.assertTrue(extension['is_enabled']) 161 self.assertTrue(extension['is_enabled'])
163 self.assertFalse(extension['allowed_in_incognito']) 162 self.assertFalse(extension['allowed_in_incognito'])
164 163
165 # Disable the extension and verify. 164 # Disable the extension and verify.
166 self.SetExtensionStateById(ext_id, enable=False, allow_in_incognito=False) 165 self.SetExtensionStateById(ext_id, enable=False, allow_in_incognito=False)
167 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) 166 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id)
168 self.assertFalse(extension['is_enabled']) 167 self.assertFalse(extension['is_enabled'])
(...skipping 12 matching lines...) Expand all
181 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=False) 180 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=False)
182 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) 181 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id)
183 self.assertFalse(extension['allowed_in_incognito']) 182 self.assertFalse(extension['allowed_in_incognito'])
184 183
185 def testAdblockExtensionCrash(self): 184 def testAdblockExtensionCrash(self):
186 """Test AdBlock extension successfully installed and enabled, and do not 185 """Test AdBlock extension successfully installed and enabled, and do not
187 cause browser crash. 186 cause browser crash.
188 """ 187 """
189 crx_file_path = os.path.abspath( 188 crx_file_path = os.path.abspath(
190 os.path.join(self.DataDir(), 'extensions', 'adblock.crx')) 189 os.path.join(self.DataDir(), 'extensions', 'adblock.crx'))
191 ext_id = self.InstallExtension(crx_file_path, False) 190 ext_id = self.InstallExtension(crx_file_path)
192 self.assertTrue(ext_id, msg='Failed to install extension.')
193 191
194 self.RestartBrowser(clear_profile=False) 192 self.RestartBrowser(clear_profile=False)
195 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) 193 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id)
196 self.assertTrue(extension['is_enabled']) 194 self.assertTrue(extension['is_enabled'])
197 self.assertFalse(extension['allowed_in_incognito']) 195 self.assertFalse(extension['allowed_in_incognito'])
198 196
199 197
200 if __name__ == '__main__': 198 if __name__ == '__main__':
201 pyauto_functional.Main() 199 pyauto_functional.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698