Index: chrome/test/functional/extensions.py |
diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py |
index e5a12a833c5c0293de9b6d4dab85c708b72b65ac..f158efd2432473b63699ab908e8c2260c0d59a76 100755 |
--- a/chrome/test/functional/extensions.py |
+++ b/chrome/test/functional/extensions.py |
@@ -181,6 +181,87 @@ 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) |
+ |
+ 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) |
+ |
+ 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) |
+ |
+ # 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) |
+ |
+ # 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. |