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 """ | 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 curr_extension = 0 | 57 curr_extension = 0 |
58 num_extensions = len(extensions) | 58 num_extensions = len(extensions) |
59 self.RestartBrowser() | 59 self.RestartBrowser() |
60 orig_extension_ids = self._GetInstalledExtensionIds() | 60 orig_extension_ids = self._GetInstalledExtensionIds() |
61 | 61 |
62 while curr_extension < num_extensions: | 62 while curr_extension < num_extensions: |
63 logging.debug('New group of %d extensions.' % group_size) | 63 logging.debug('New group of %d extensions.' % group_size) |
64 group_end = curr_extension + group_size | 64 group_end = curr_extension + group_size |
65 for extension in extensions[curr_extension:group_end]: | 65 for extension in extensions[curr_extension:group_end]: |
66 logging.debug('Installing extension: %s' % extension) | 66 logging.debug('Installing extension: %s' % extension) |
67 self.InstallExtension(pyauto.FilePath(extension), False) | 67 self.InstallExtension(extension, False) |
68 | 68 |
69 for url in top_urls: | 69 for url in top_urls: |
70 self.NavigateToURL(url) | 70 self.NavigateToURL(url) |
71 | 71 |
72 def _LogAndReturnCrashing(): | 72 def _LogAndReturnCrashing(): |
73 crashing_extensions = extensions[curr_extension:group_end] | 73 crashing_extensions = extensions[curr_extension:group_end] |
74 logging.debug('Crashing extensions: %s' % crashing_extensions) | 74 logging.debug('Crashing extensions: %s' % crashing_extensions) |
75 return crashing_extensions | 75 return crashing_extensions |
76 | 76 |
77 # If the browser has crashed, return the extensions in the failing group. | 77 # If the browser has crashed, return the extensions in the failing group. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 self.assertTrue(len(permissions_api) == 3 and | 150 self.assertTrue(len(permissions_api) == 3 and |
151 'bookmarks' in permissions_api and | 151 'bookmarks' in permissions_api and |
152 'experimental' in permissions_api and | 152 'experimental' in permissions_api and |
153 'tabs' in permissions_api, | 153 'tabs' in permissions_api, |
154 msg='Unexpected host permissions information.') | 154 msg='Unexpected host permissions information.') |
155 | 155 |
156 def testSetExtensionStates(self): | 156 def testSetExtensionStates(self): |
157 """Test setting different extension states.""" | 157 """Test setting different extension states.""" |
158 crx_file_path = os.path.abspath( | 158 crx_file_path = os.path.abspath( |
159 os.path.join(self.DataDir(), 'extensions', 'google_talk.crx')) | 159 os.path.join(self.DataDir(), 'extensions', 'google_talk.crx')) |
160 ext_id = self.InstallExtension(pyauto.FilePath(crx_file_path), False); | 160 ext_id = self.InstallExtension(crx_file_path, False); |
161 self.assertTrue(ext_id, 'Failed to install extension.') | 161 self.assertTrue(ext_id, 'Failed to install extension.') |
162 | 162 |
163 # Verify extension is in default state. | 163 # Verify extension is in default state. |
164 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 164 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
165 self.assertTrue(extension['is_enabled']) | 165 self.assertTrue(extension['is_enabled']) |
166 self.assertFalse(extension['allowed_in_incognito']) | 166 self.assertFalse(extension['allowed_in_incognito']) |
167 | 167 |
168 # Disable the extension and verify. | 168 # Disable the extension and verify. |
169 self.SetExtensionStateById(ext_id, enable=False, allow_in_incognito=False) | 169 self.SetExtensionStateById(ext_id, enable=False, allow_in_incognito=False) |
170 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 170 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
(...skipping 10 matching lines...) Expand all Loading... |
181 self.assertTrue(extension['allowed_in_incognito']) | 181 self.assertTrue(extension['allowed_in_incognito']) |
182 | 182 |
183 # Disallow extension in incognito mode and verify. | 183 # Disallow extension in incognito mode and verify. |
184 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=False) | 184 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=False) |
185 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 185 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
186 self.assertFalse(extension['allowed_in_incognito']) | 186 self.assertFalse(extension['allowed_in_incognito']) |
187 | 187 |
188 | 188 |
189 if __name__ == '__main__': | 189 if __name__ == '__main__': |
190 pyauto_functional.Main() | 190 pyauto_functional.Main() |
OLD | NEW |