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')) | |
|
dennis_jeffrey
2011/11/17 00:11:32
add a second parameter to the assert:
msg='Browse
frankf
2011/11/17 00:25:03
Done.
| |
| 202 | |
| 203 def testTriggerPageAction(self): | |
| 204 """Test triggering page action.""" | |
| 205 dir_path = os.path.abspath( | |
| 206 os.path.join(self.DataDir(), 'extensions', 'trigger_actions', | |
| 207 'page_action')) | |
| 208 ext_id = self.InstallExtension(dir_path, False); | |
| 209 self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) | |
| 210 | |
| 211 # Page action icon is displayed when a tab is created. | |
|
dennis_jeffrey
2011/11/17 00:11:32
Is it required that the page action icon be displa
frankf
2011/11/17 00:25:03
Yes, done.
| |
| 212 self.AppendTab(pyauto.GURL(self.GetFileURLForDataPath( | |
| 213 'frame_dom_access', 'frame_dom_access.html'))) | |
| 214 | |
| 215 self.TriggerExtensionActionById(ext_id) | |
| 216 | |
| 217 # Verify that page action turned the background red. | |
| 218 self.assertTrue(self.WaitUntil( | |
| 219 lambda: self.GetDOMValue('document.body.style.backgroundColor', 1), | |
|
dennis_jeffrey
2011/11/17 00:11:32
tab_index=1
frankf
2011/11/17 00:25:03
Done.
| |
| 220 expect_retval='red')) | |
|
dennis_jeffrey
2011/11/17 00:11:32
add a second parameter to the assert:
msg='Page a
frankf
2011/11/17 00:25:03
Done.
| |
| 221 | |
| 185 def testAdblockExtensionCrash(self): | 222 def testAdblockExtensionCrash(self): |
| 186 """Test AdBlock extension successfully installed and enabled, and do not | 223 """Test AdBlock extension successfully installed and enabled, and do not |
| 187 cause browser crash. | 224 cause browser crash. |
| 188 """ | 225 """ |
| 189 crx_file_path = os.path.abspath( | 226 crx_file_path = os.path.abspath( |
| 190 os.path.join(self.DataDir(), 'extensions', 'adblock.crx')) | 227 os.path.join(self.DataDir(), 'extensions', 'adblock.crx')) |
| 191 ext_id = self.InstallExtension(crx_file_path, False) | 228 ext_id = self.InstallExtension(crx_file_path, False) |
| 192 self.assertTrue(ext_id, msg='Failed to install extension.') | 229 self.assertTrue(ext_id, msg='Failed to install extension.') |
| 193 | 230 |
| 194 self.RestartBrowser(clear_profile=False) | 231 self.RestartBrowser(clear_profile=False) |
| 195 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) | 232 extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
| 196 self.assertTrue(extension['is_enabled']) | 233 self.assertTrue(extension['is_enabled']) |
| 197 self.assertFalse(extension['allowed_in_incognito']) | 234 self.assertFalse(extension['allowed_in_incognito']) |
| 198 | 235 |
| 199 | 236 |
| 200 if __name__ == '__main__': | 237 if __name__ == '__main__': |
| 201 pyauto_functional.Main() | 238 pyauto_functional.Main() |
| OLD | NEW |