Chromium Code Reviews| Index: chrome/test/functional/extensions.py |
| diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py |
| index c949a71d5e3a266a8834852c2dede4cbd659b98d..46380e699410a4e86e1dc6f75cfdbbd9ff37c582 100644 |
| --- a/chrome/test/functional/extensions.py |
| +++ b/chrome/test/functional/extensions.py |
| @@ -182,6 +182,91 @@ class ExtensionsTest(pyauto.PyUITest): |
| extension = self._GetExtensionInfoById(self.GetExtensionsInfo(), ext_id) |
| self.assertFalse(extension['allowed_in_incognito']) |
| + def testTriggerBrowserAction(self): |
| + """Test triggering browser action.""" |
| + dir_path = os.path.abspath( |
| + os.path.join(self.DataDir(), 'extensions', 'trigger_actions', |
| + 'browser_action')) |
| + ext_id = self.InstallExtension(dir_path, False) |
|
dennis_jeffrey
2011/11/23 21:54:54
I think these calls to InstallExtension() will hav
|
| + self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) |
| + |
| + self.NavigateToURL(self.GetFileURLForDataPath('simple.html')) |
| + |
| + self.TriggerBrowserActionById(ext_id) |
| + |
| + # Verify that the browser action turned the background red. |
| + self.assertTrue(self.WaitUntil( |
| + lambda: self.GetDOMValue('document.body.style.backgroundColor'), |
| + expect_retval='red'), |
| + msg='Browser action was not triggered.') |
| + |
| + def testTriggerBrowserActionWithPopup(self): |
| + """Test triggering browser action that shows a popup.""" |
| + dir_path = os.path.abspath( |
| + os.path.join(self.DataDir(), 'extensions', 'trigger_actions', |
| + 'browser_action_popup')) |
| + ext_id = self.InstallExtension(dir_path, False) |
| + self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) |
| + |
| + self.TriggerBrowserActionById(ext_id) |
| + |
| + # Verify that the extension popup is displayed. |
| + popup = self.WaitUntilExtensionViewLoaded( |
| + view_type='EXTENSION_POPUP') |
| + self.assertTrue(popup, |
| + msg='Browser action failed to display the popup (views=%s).' % |
| + self.GetBrowserInfo()['extension_views']) |
| + |
| + def testTriggerPageAction(self): |
| + """Test triggering page action.""" |
| + dir_path = os.path.abspath( |
| + os.path.join(self.DataDir(), 'extensions', 'trigger_actions', |
| + 'page_action')) |
| + ext_id = self.InstallExtension(dir_path, False) |
| + self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) |
| + |
| + # Page action icon is displayed when a tab is created. |
| + self.NavigateToURL(self.GetFileURLForDataPath('simple.html')) |
| + self.AppendTab(pyauto.GURL('chrome://newtab')) |
| + self.ActivateTab(0) |
| + self.assertTrue(self.WaitUntil( |
| + lambda: ext_id in |
| + self.GetBrowserInfo()['windows'][0]['visible_page_actions']), |
| + msg='Page action icon is not visible.') |
| + |
| + self.TriggerPageActionById(ext_id) |
| + |
| + # Verify that page action turned the background red. |
| + self.assertTrue(self.WaitUntil( |
| + lambda: self.GetDOMValue('document.body.style.backgroundColor'), |
| + expect_retval='red'), |
| + msg='Page action was not triggered.') |
| + |
| + def testTriggerPageActionWithPopup(self): |
| + """Test triggering page action that shows a popup.""" |
| + dir_path = os.path.abspath( |
| + os.path.join(self.DataDir(), 'extensions', 'trigger_actions', |
| + 'page_action_popup')) |
| + ext_id = self.InstallExtension(dir_path, False) |
| + self.assertTrue(ext_id, msg='Failed to install extension: %s.' % dir_path) |
| + |
| + # Page action icon is displayed when a tab is created. |
| + self.AppendTab(pyauto.GURL('chrome://newtab')) |
| + self.ActivateTab(0) |
| + self.assertTrue(self.WaitUntil( |
| + lambda: ext_id in |
| + self.GetBrowserInfo()['windows'][0]['visible_page_actions']), |
| + msg='Page action icon is not visible.') |
| + |
| + self.TriggerPageActionById(ext_id) |
| + |
| + # Verify that the extension popup is displayed. |
| + popup = self.WaitUntilExtensionViewLoaded( |
| + view_type='EXTENSION_POPUP') |
| + self.assertTrue(popup, |
| + msg='Page action failed to display the popup (views=%s).' % |
| + self.GetBrowserInfo()['extension_views']) |
| + |
| def testAdblockExtensionCrash(self): |
| """Test AdBlock extension successfully installed and enabled, and do not |
| cause browser crash. |