2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
9 import pyauto_functional # Must be imported before pyauto
14 class AboutPluginsUITest(pyauto.PyUITest):
15 """Testcase for chrome://plugins UI."""
17 def testAboutPluginDetailInfo(self):
18 """Verify chrome://plugins page shows plugin details."""
19 self.NavigateToURL('chrome://plugins/')
20 driver = self.NewWebDriver()
21 detail_link = driver.find_element_by_id('details-link')
22 self.assertTrue(self.WaitUntil(lambda: detail_link.is_displayed()),
23 msg='Details link could not be found.')
25 # Verify that detail info for Remote Viewer plugin shows up.
26 # Remote Viewer plugin is expected to be present on all platforms.
27 self.assertTrue(self.WaitUntil(lambda: len(driver.find_elements_by_xpath(
28 '//*[@jscontent="path"][text()="internal-remoting-viewer"]'))))
31 class ChromeAboutPluginsUITest(pyauto.PyUITest):
32 """Testcase for official build only plugins in chrome://plugins UI."""
35 """chrome://plugins test debug method.
37 This method will not run automatically.
39 self.NavigateToURL('chrome://plugins/')
40 driver = self.NewWebDriver()
44 def _IsEnabled(self, driver, plugin_name):
45 """Checks if plugin is enabled.
48 driver: A Chrome driver object.
49 plugin_name: Plugin name to verify.
52 True, if plugin is enabled, or False otherwise.
54 check_plugin_enabled_js = 'return navigator.plugins["%s"] != undefined' % \
56 return driver.execute_script(check_plugin_enabled_js)
58 def _ExpandDetailInfoLink(self, driver):
59 """Expand detail info link.
62 driver: A Chrome driver object.
64 detail_link = driver.find_element_by_id('details-link')
65 self.assertTrue(self.WaitUntil(lambda: detail_link.is_displayed()),
66 msg='Details link could not be found.')
69 def _OverridePluginPageAnimation(self, driver):
70 """Override the animation for expanding detail info to make sure element
71 remain at the same location where web driver found it.
74 driver: A Chrome driver object.
76 override_animation_style_js = """
77 style = document.createElement('style');
78 style.innerHTML = "* { -webkit-transition: all 0s ease-in !important}";
79 document.head.appendChild(style);
81 driver.execute_script(override_animation_style_js)
83 def testAboutPluginEnableAndDisablePDFPlugin(self):
84 """Verify enable and disable pdf plugins from about:plugins page."""
85 self.NavigateToURL('chrome://plugins/')
86 driver = self.NewWebDriver()
88 self._OverridePluginPageAnimation(driver)
89 self._ExpandDetailInfoLink(driver)
91 pdf_disable_path = '//*[@class="plugin-name"][text()="Chrome PDF Viewer"' \
92 ']//ancestor::*[@class="plugin-text"]//a[text()="Disable"]'
93 pdf_enable_path = '//*[@class="plugin-name"][text()="Chrome PDF Viewer"' \
94 ']//ancestor::*[@class="plugin-text"]//a[text()="Enable"]'
96 # Confirm Chrome PDF Viewer plugin is found and find disable PDF link.
97 pdf_disable_link = pyauto_utils.WaitForDomElement(self, driver,
100 # Disable PDF viewer plugin in about:plugins.
101 pdf_disable_link.click()
102 self.assertTrue(self.WaitUntil(lambda: not
103 self._IsEnabled(driver, 'Chrome PDF Viewer')))
105 # Re-enable PDF viewer plugin.
106 pdf_enable_link = driver.find_element_by_xpath(pdf_enable_path)
107 pdf_enable_link.click()
108 self.assertTrue(self.WaitUntil(lambda:
109 self._IsEnabled(driver, 'Chrome PDF Viewer')))
111 def testEnableAndDisableFlashPlugin(self):
112 """Verify enable and disable flash plugins from about:plugins page."""
113 self.NavigateToURL('chrome://plugins/')
114 driver = self.NewWebDriver()
116 self._OverridePluginPageAnimation(driver)
117 self._ExpandDetailInfoLink(driver)
118 flash_plugins_elem = driver.find_element_by_xpath(
119 '//*[@jscontent="name"][text()="Flash"]//ancestor' \
120 '::*[@class="plugin-text"]')
122 # Disable flash plugin from flash detail info.
123 flash_disable_link = flash_plugins_elem.find_element_by_xpath(
124 './/a[text()="Disable"]')
125 flash_disable_link.click()
126 self.assertTrue(self.WaitUntil(lambda: not
127 self._IsEnabled(driver, 'Shockwave Flash')))
129 # Re-enable Flash plugin from flash detail info.
130 flash_enable_link = flash_plugins_elem.find_element_by_xpath(
131 './/a[text()="Enable"]')
132 flash_enable_link.click()
133 self.assertTrue(self.WaitUntil(lambda:
134 self._IsEnabled(driver, 'Shockwave Flash')))
137 if __name__ == '__main__':
138 pyauto_functional.Main()