Chromium Code Reviews| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 # Allow extension in incognito mode and verify. | 175 # Allow extension in incognito mode and verify. |
| 176 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=True) | 176 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=True) |
| 177 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 177 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
| 178 self.assertTrue(extension['allowed_in_incognito']) | 178 self.assertTrue(extension['allowed_in_incognito']) |
| 179 | 179 |
| 180 # Disallow extension in incognito mode and verify. | 180 # Disallow extension in incognito mode and verify. |
| 181 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=False) | 181 self.SetExtensionStateById(ext_id, enable=True, allow_in_incognito=False) |
| 182 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 182 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
| 183 self.assertFalse(extension['allowed_in_incognito']) | 183 self.assertFalse(extension['allowed_in_incognito']) |
| 184 | 184 |
| 185 def testTriggerBrowserAction(self): | |
| 186 """Test triggering browser action.""" | |
| 187 dir_path = os.path.abspath( | |
| 188 os.path.join(self.DataDir(), 'extensions', 'trigger_actions', | |
| 189 'browser_action')) | |
| 190 ext_id = self.InstallExtension(dir_path, False); | |
| 191 self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) | |
| 192 | |
| 193 self.NavigateToURL(self.GetFileURLForDataPath( | |
| 194 'frame_dom_access', 'frame_dom_access.html')) | |
| 195 | |
| 196 self.TriggerExtensionActionById(ext_id) | |
| 197 | |
| 198 # Verify that the browser action turned the background red. | |
| 199 self.assertTrue(self.WaitUntil( | |
| 200 lambda: self.GetDOMValue('document.body.style.backgroundColor'), | |
| 201 expect_retval='red'), | |
| 202 msg='Browser action was not triggered.') | |
| 203 | |
| 204 def testTriggerPageAction(self): | |
| 205 """Test triggering page action.""" | |
| 206 dir_path = os.path.abspath( | |
| 207 os.path.join(self.DataDir(), 'extensions', 'trigger_actions', | |
| 208 'page_action')) | |
| 209 ext_id = self.InstallExtension(dir_path, False); | |
| 210 self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) | |
| 211 | |
| 212 # Page action icon is displayed when a tab is created. | |
| 213 self.AppendTab(pyauto.GURL(self.GetFileURLForDataPath( | |
| 214 'frame_dom_access', 'frame_dom_access.html'))) | |
| 215 | |
| 216 self.TriggerExtensionActionById(ext_id) | |
| 217 | |
| 218 # Verify that page action turned the background red. | |
| 219 self.assertTrue(self.WaitUntil( | |
| 220 lambda: self.GetDOMValue('document.body.style.backgroundColor', | |
| 221 tab_index=1), | |
| 222 expect_retval='red'), | |
| 223 msg='Browser action was not triggered.') | |
|
dennis_jeffrey
2011/11/17 00:53:17
'Browser' --> 'Page'
| |
| 224 | |
| 185 def testAdblockExtensionCrash(self): | 225 def testAdblockExtensionCrash(self): |
| 186 """Test AdBlock extension successfully installed and enabled, and do not | 226 """Test AdBlock extension successfully installed and enabled, and do not |
| 187 cause browser crash. | 227 cause browser crash. |
| 188 """ | 228 """ |
| 189 crx_file_path = os.path.abspath( | 229 crx_file_path = os.path.abspath( |
| 190 os.path.join(self.DataDir(), 'extensions', 'adblock.crx')) | 230 os.path.join(self.DataDir(), 'extensions', 'adblock.crx')) |
| 191 ext_id = self.InstallExtension(crx_file_path, False) | 231 ext_id = self.InstallExtension(crx_file_path, False) |
| 192 self.assertTrue(ext_id, msg='Failed to install extension.') | 232 self.assertTrue(ext_id, msg='Failed to install extension.') |
| 193 | 233 |
| 194 self.RestartBrowser(clear_profile=False) | 234 self.RestartBrowser(clear_profile=False) |
| 195 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 235 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
| 196 self.assertTrue(extension['is_enabled']) | 236 self.assertTrue(extension['is_enabled']) |
| 197 self.assertFalse(extension['allowed_in_incognito']) | 237 self.assertFalse(extension['allowed_in_incognito']) |
| 198 | 238 |
| 199 | 239 |
| 200 if __name__ == '__main__': | 240 if __name__ == '__main__': |
| 201 pyauto_functional.Main() | 241 pyauto_functional.Main() |
| OLD | NEW |