| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 import pyauto_functional # must come before pyauto. | 9 import pyauto_functional # must come before pyauto. |
| 10 import policy_base | 10 import policy_base |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return ret == 'ok' | 97 return ret == 'ok' |
| 98 | 98 |
| 99 def _RestartRenderer(self, windex=0): | 99 def _RestartRenderer(self, windex=0): |
| 100 """Kills the current renderer, and reloads it again.""" | 100 """Kills the current renderer, and reloads it again.""" |
| 101 info = self.GetBrowserInfo() | 101 info = self.GetBrowserInfo() |
| 102 tab = self.GetActiveTabIndex() | 102 tab = self.GetActiveTabIndex() |
| 103 pid = info['windows'][windex]['tabs'][tab]['renderer_pid'] | 103 pid = info['windows'][windex]['tabs'][tab]['renderer_pid'] |
| 104 self.KillRendererProcess(pid) | 104 self.KillRendererProcess(pid) |
| 105 self.ReloadActiveTab() | 105 self.ReloadActiveTab() |
| 106 | 106 |
| 107 def setUp(self): |
| 108 policy_base.PolicyTestBase.setUp(self) |
| 109 if self.IsChromeOS(): |
| 110 self.LoginWithTestAccount() |
| 111 |
| 107 def testPolicyToPrefMapping(self): | 112 def testPolicyToPrefMapping(self): |
| 108 """Verify that simple user policies map to corresponding prefs. | 113 """Verify that simple user policies map to corresponding prefs. |
| 109 | 114 |
| 110 Also verify that once these policies are in effect, the prefs cannot be | 115 Also verify that once these policies are in effect, the prefs cannot be |
| 111 modified by the user. | 116 modified by the user. |
| 112 """ | 117 """ |
| 113 total = 0 | 118 total = 0 |
| 114 fails = [] | 119 fails = [] |
| 115 policy_prefs = policy_test_cases.PolicyPrefsTestCases | 120 policy_prefs = policy_test_cases.PolicyPrefsTestCases |
| 116 for policy, values in policy_prefs.policies.iteritems(): | 121 for policy, values in policy_prefs.policies.iteritems(): |
| 117 pref = values[policy_prefs.INDEX_PREF] | 122 pref = values[policy_prefs.INDEX_PREF] |
| 118 value = values[policy_prefs.INDEX_VALUE] | 123 value = values[policy_prefs.INDEX_VALUE] |
| 119 os = values[policy_prefs.INDEX_OS] | 124 os = values[policy_prefs.INDEX_OS] |
| 120 if not pref or self.GetPlatform() not in os: | 125 if not pref or self.GetPlatform() not in os: |
| 121 continue | 126 continue |
| 122 self.SetPolicies({policy: value}) | 127 self.SetUserPolicy({policy: value}) |
| 123 error = self._GetPrefIsManagedError(getattr(pyauto, pref), value) | 128 error = self._GetPrefIsManagedError(getattr(pyauto, pref), value) |
| 124 if error: | 129 if error: |
| 125 fails.append('%s: %s' % (policy, error)) | 130 fails.append('%s: %s' % (policy, error)) |
| 126 total += 1 | 131 total += 1 |
| 127 self.assertFalse(fails, msg='%d of %d policies failed.\n%s' % | 132 self.assertFalse(fails, msg='%d of %d policies failed.\n%s' % |
| 128 (len(fails), total, '\n'.join(fails))) | 133 (len(fails), total, '\n'.join(fails))) |
| 129 | 134 |
| 130 def testBlacklistPolicy(self): | 135 def testBlacklistPolicy(self): |
| 131 """Tests the URLBlacklist and URLWhitelist policies.""" | 136 """Tests the URLBlacklist and URLWhitelist policies.""" |
| 132 # This is an end to end test and not an exaustive test of the filter format. | 137 # This is an end to end test and not an exaustive test of the filter format. |
| 133 policy = { | 138 policy = { |
| 134 'URLBlacklist': [ | 139 'URLBlacklist': [ |
| 135 'news.google.com', | 140 'news.google.com', |
| 136 'chromium.org', | 141 'chromium.org', |
| 137 ], | 142 ], |
| 138 'URLWhitelist': [ | 143 'URLWhitelist': [ |
| 139 'dev.chromium.org', | 144 'dev.chromium.org', |
| 140 'chromium.org/chromium-os', | 145 'chromium.org/chromium-os', |
| 141 ] | 146 ] |
| 142 } | 147 } |
| 143 self.SetPolicies(policy) | 148 self.SetUserPolicy(policy) |
| 144 | 149 |
| 145 self.assertTrue(self._IsBlocked('http://news.google.com/')) | 150 self.assertTrue(self._IsBlocked('http://news.google.com/')) |
| 146 self.assertFalse(self._IsBlocked('http://www.google.com/')) | 151 self.assertFalse(self._IsBlocked('http://www.google.com/')) |
| 147 self.assertFalse(self._IsBlocked('http://google.com/')) | 152 self.assertFalse(self._IsBlocked('http://google.com/')) |
| 148 | 153 |
| 149 self.assertTrue(self._IsBlocked('http://chromium.org/')) | 154 self.assertTrue(self._IsBlocked('http://chromium.org/')) |
| 150 self.assertTrue(self._IsBlocked('http://www.chromium.org/')) | 155 self.assertTrue(self._IsBlocked('http://www.chromium.org/')) |
| 151 self.assertFalse(self._IsBlocked('http://dev.chromium.org/')) | 156 self.assertFalse(self._IsBlocked('http://dev.chromium.org/')) |
| 152 self.assertFalse(self._IsBlocked('http://chromium.org/chromium-os/testing')) | 157 self.assertFalse(self._IsBlocked('http://chromium.org/chromium-os/testing')) |
| 153 | 158 |
| 154 def testBookmarkBarPolicy(self): | 159 def testBookmarkBarPolicy(self): |
| 155 """Tests the BookmarkBarEnabled policy.""" | 160 """Tests the BookmarkBarEnabled policy.""" |
| 156 self.NavigateToURL('about:blank') | 161 self.NavigateToURL('about:blank') |
| 157 self.assertFalse(self.GetBookmarkBarVisibility()) | 162 self.assertFalse(self.GetBookmarkBarVisibility()) |
| 158 self.assertFalse(self.IsBookmarkBarDetached()) | 163 self.assertFalse(self.IsBookmarkBarDetached()) |
| 159 | 164 |
| 160 # It should be visible in detached state, in the NTP. | 165 # It should be visible in detached state, in the NTP. |
| 161 self.NavigateToURL('chrome://newtab') | 166 self.NavigateToURL('chrome://newtab') |
| 162 self.assertFalse(self.GetBookmarkBarVisibility()) | 167 self.assertFalse(self.GetBookmarkBarVisibility()) |
| 163 self.assertTrue(self.IsBookmarkBarDetached()) | 168 self.assertTrue(self.IsBookmarkBarDetached()) |
| 164 | 169 |
| 165 policy = { | 170 policy = { |
| 166 'BookmarkBarEnabled': True | 171 'BookmarkBarEnabled': True |
| 167 } | 172 } |
| 168 self.SetPolicies(policy) | 173 self.SetUserPolicy(policy) |
| 169 | 174 |
| 170 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(True)) | 175 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(True)) |
| 171 self.assertTrue(self.GetBookmarkBarVisibility()) | 176 self.assertTrue(self.GetBookmarkBarVisibility()) |
| 172 self.assertFalse(self.IsBookmarkBarDetached()) | 177 self.assertFalse(self.IsBookmarkBarDetached()) |
| 173 # The accelerator should be disabled by the policy. | 178 # The accelerator should be disabled by the policy. |
| 174 self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR) | 179 self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR) |
| 175 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(True)) | 180 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(True)) |
| 176 self.assertTrue(self.GetBookmarkBarVisibility()) | 181 self.assertTrue(self.GetBookmarkBarVisibility()) |
| 177 self.assertFalse(self.IsBookmarkBarDetached()) | 182 self.assertFalse(self.IsBookmarkBarDetached()) |
| 178 | 183 |
| 179 policy['BookmarkBarEnabled'] = False | 184 policy['BookmarkBarEnabled'] = False |
| 180 self.SetPolicies(policy) | 185 self.SetUserPolicy(policy) |
| 181 | 186 |
| 182 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(False)) | 187 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(False)) |
| 183 self.assertFalse(self.GetBookmarkBarVisibility()) | 188 self.assertFalse(self.GetBookmarkBarVisibility()) |
| 184 self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR) | 189 self.ApplyAccelerator(pyauto.IDC_SHOW_BOOKMARK_BAR) |
| 185 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(False)) | 190 self.assertTrue(self.WaitForBookmarkBarVisibilityChange(False)) |
| 186 self.assertFalse(self.GetBookmarkBarVisibility()) | 191 self.assertFalse(self.GetBookmarkBarVisibility()) |
| 187 # When disabled by policy, it should never be displayed at all, | 192 # When disabled by policy, it should never be displayed at all, |
| 188 # not even on the NTP. | 193 # not even on the NTP. |
| 189 self.assertFalse(self.IsBookmarkBarDetached()) | 194 self.assertFalse(self.IsBookmarkBarDetached()) |
| 190 | 195 |
| 191 def testJavascriptPolicies(self): | 196 def testJavascriptPolicies(self): |
| 192 """Tests the Javascript policies.""" | 197 """Tests the Javascript policies.""" |
| 193 # The navigation to about:blank after each policy reset is to reset the | 198 # The navigation to about:blank after each policy reset is to reset the |
| 194 # content settings state. | 199 # content settings state. |
| 195 policy = {} | 200 policy = {} |
| 196 self.SetPolicies(policy) | 201 self.SetUserPolicy(policy) |
| 197 self.assertTrue(self._IsJavascriptEnabled()) | 202 self.assertTrue(self._IsJavascriptEnabled()) |
| 198 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) | 203 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) |
| 199 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) | 204 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) |
| 200 | 205 |
| 201 policy['DeveloperToolsDisabled'] = True | 206 policy['DeveloperToolsDisabled'] = True |
| 202 self.SetPolicies(policy) | 207 self.SetUserPolicy(policy) |
| 203 self.assertTrue(self._IsJavascriptEnabled()) | 208 self.assertTrue(self._IsJavascriptEnabled()) |
| 204 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) | 209 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) |
| 205 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) | 210 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) |
| 206 | 211 |
| 207 policy['DeveloperToolsDisabled'] = False | 212 policy['DeveloperToolsDisabled'] = False |
| 208 self.SetPolicies(policy) | 213 self.SetUserPolicy(policy) |
| 209 self.assertTrue(self._IsJavascriptEnabled()) | 214 self.assertTrue(self._IsJavascriptEnabled()) |
| 210 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) | 215 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) |
| 211 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) | 216 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) |
| 212 | 217 |
| 213 # The Developer Tools still work when javascript is disabled. | 218 # The Developer Tools still work when javascript is disabled. |
| 214 policy['JavascriptEnabled'] = False | 219 policy['JavascriptEnabled'] = False |
| 215 self.SetPolicies(policy) | 220 self.SetUserPolicy(policy) |
| 216 self.NavigateToURL('about:blank') | 221 self.NavigateToURL('about:blank') |
| 217 self.assertFalse(self._IsJavascriptEnabled()) | 222 self.assertFalse(self._IsJavascriptEnabled()) |
| 218 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) | 223 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) |
| 219 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) | 224 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) |
| 220 # Javascript is always enabled for internal Chrome pages. | 225 # Javascript is always enabled for internal Chrome pages. |
| 221 self.NavigateToURL('chrome://settings-frame') | 226 self.NavigateToURL('chrome://settings-frame') |
| 222 self.assertTrue(self._IsJavascriptEnabled()) | 227 self.assertTrue(self._IsJavascriptEnabled()) |
| 223 | 228 |
| 224 # The Developer Tools can be explicitly disabled. | 229 # The Developer Tools can be explicitly disabled. |
| 225 policy['DeveloperToolsDisabled'] = True | 230 policy['DeveloperToolsDisabled'] = True |
| 226 self.SetPolicies(policy) | 231 self.SetUserPolicy(policy) |
| 227 self.NavigateToURL('about:blank') | 232 self.NavigateToURL('about:blank') |
| 228 self.assertFalse(self._IsJavascriptEnabled()) | 233 self.assertFalse(self._IsJavascriptEnabled()) |
| 229 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) | 234 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) |
| 230 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) | 235 self.assertFalse(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) |
| 231 | 236 |
| 232 # Javascript can also be disabled with content settings policies. | 237 # Javascript can also be disabled with content settings policies. |
| 233 policy = { | 238 policy = { |
| 234 'DefaultJavaScriptSetting': 2, | 239 'DefaultJavaScriptSetting': 2, |
| 235 } | 240 } |
| 236 self.SetPolicies(policy) | 241 self.SetUserPolicy(policy) |
| 237 self.NavigateToURL('about:blank') | 242 self.NavigateToURL('about:blank') |
| 238 self.assertFalse(self._IsJavascriptEnabled()) | 243 self.assertFalse(self._IsJavascriptEnabled()) |
| 239 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) | 244 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS)) |
| 240 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) | 245 self.assertTrue(self.IsMenuCommandEnabled(pyauto.IDC_DEV_TOOLS_CONSOLE)) |
| 241 | 246 |
| 242 # The content setting overrides JavascriptEnabled. | 247 # The content setting overrides JavascriptEnabled. |
| 243 policy = { | 248 policy = { |
| 244 'DefaultJavaScriptSetting': 1, | 249 'DefaultJavaScriptSetting': 1, |
| 245 'JavascriptEnabled': False, | 250 'JavascriptEnabled': False, |
| 246 } | 251 } |
| 247 self.SetPolicies(policy) | 252 self.SetUserPolicy(policy) |
| 248 self.NavigateToURL('about:blank') | 253 self.NavigateToURL('about:blank') |
| 249 self.assertTrue(self._IsJavascriptEnabled()) | 254 self.assertTrue(self._IsJavascriptEnabled()) |
| 250 | 255 |
| 251 def testDisable3DAPIs(self): | 256 def testDisable3DAPIs(self): |
| 252 """Tests the policy that disables the 3D APIs.""" | 257 """Tests the policy that disables the 3D APIs.""" |
| 253 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kDisable3DAPIs)) | 258 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kDisable3DAPIs)) |
| 254 self.assertTrue(self._IsWebGLEnabled()) | 259 self.assertTrue(self._IsWebGLEnabled()) |
| 255 | 260 |
| 256 self.SetPolicies({ | 261 self.SetUserPolicy({ |
| 257 'Disable3DAPIs': True | 262 'Disable3DAPIs': True |
| 258 }) | 263 }) |
| 259 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kDisable3DAPIs)) | 264 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kDisable3DAPIs)) |
| 260 # The Disable3DAPIs policy only applies updated values to new renderers. | 265 # The Disable3DAPIs policy only applies updated values to new renderers. |
| 261 self._RestartRenderer() | 266 self._RestartRenderer() |
| 262 self.assertFalse(self._IsWebGLEnabled()) | 267 self.assertFalse(self._IsWebGLEnabled()) |
| 263 | 268 |
| 264 def testStartupOptions(self): | 269 def testStartupOptions(self): |
| 265 """Verify that user cannot modify the startup page options.""" | 270 """Verify that user cannot modify the startup page options.""" |
| 266 policy = { | 271 policy = { |
| 267 'RestoreOnStartup': 4, | 272 'RestoreOnStartup': 4, |
| 268 'RestoreOnStartupURLs': ['http://chromium.org'] | 273 'RestoreOnStartupURLs': ['http://chromium.org'] |
| 269 } | 274 } |
| 270 self.SetPolicies(policy) | 275 self.SetUserPolicy(policy) |
| 271 # Verify startup option | 276 # Verify startup option |
| 272 self.assertEquals(4, self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup)) | 277 self.assertEquals(4, self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup)) |
| 273 self.assertRaises( | 278 self.assertRaises( |
| 274 pyauto.JSONInterfaceError, | 279 pyauto.JSONInterfaceError, |
| 275 lambda: self.SetPrefs(pyauto.kRestoreOnStartup, 1)) | 280 lambda: self.SetPrefs(pyauto.kRestoreOnStartup, 1)) |
| 276 policy['RestoreOnStartup'] = 0 | 281 policy['RestoreOnStartup'] = 0 |
| 277 self.SetPolicies(policy) | 282 self.SetUserPolicy(policy) |
| 278 self.assertEquals(0, self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup)) | 283 self.assertEquals(0, self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup)) |
| 279 self.assertRaises( | 284 self.assertRaises( |
| 280 pyauto.JSONInterfaceError, | 285 pyauto.JSONInterfaceError, |
| 281 lambda: self.SetPrefs(pyauto.kRestoreOnStartup, 1)) | 286 lambda: self.SetPrefs(pyauto.kRestoreOnStartup, 1)) |
| 282 # Verify URLs to open on startup | 287 # Verify URLs to open on startup |
| 283 self.assertEquals( | 288 self.assertEquals( |
| 284 ['http://chromium.org'], | 289 ['http://chromium.org'], |
| 285 self.GetPrefsInfo().Prefs(pyauto.kURLsToRestoreOnStartup)) | 290 self.GetPrefsInfo().Prefs(pyauto.kURLsToRestoreOnStartup)) |
| 286 self.assertRaises( | 291 self.assertRaises( |
| 287 pyauto.JSONInterfaceError, | 292 pyauto.JSONInterfaceError, |
| 288 lambda: self.SetPrefs(pyauto.kURLsToRestoreOnStartup, | 293 lambda: self.SetPrefs(pyauto.kURLsToRestoreOnStartup, |
| 289 ['http://www.google.com'])) | 294 ['http://www.google.com'])) |
| 290 | 295 |
| 291 def testHomePageOptions(self): | 296 def testHomePageOptions(self): |
| 292 """Verify that we cannot modify Homepage URL.""" | 297 """Verify that we cannot modify Homepage URL.""" |
| 293 policy = { | 298 policy = { |
| 294 'HomepageLocation': 'http://chromium.org', | 299 'HomepageLocation': 'http://chromium.org', |
| 295 'HomepageIsNewTabPage': True | 300 'HomepageIsNewTabPage': True |
| 296 } | 301 } |
| 297 self.SetPolicies(policy) | 302 self.SetUserPolicy(policy) |
| 298 # Try to configure home page URL | 303 # Try to configure home page URL |
| 299 self.assertEquals('http://chromium.org', | 304 self.assertEquals('http://chromium.org', |
| 300 self.GetPrefsInfo().Prefs('homepage')) | 305 self.GetPrefsInfo().Prefs('homepage')) |
| 301 self.assertRaises( | 306 self.assertRaises( |
| 302 pyauto.JSONInterfaceError, | 307 pyauto.JSONInterfaceError, |
| 303 lambda: self.SetPrefs('homepage', 'http://www.google.com')) | 308 lambda: self.SetPrefs('homepage', 'http://www.google.com')) |
| 304 # Try to remove NTP as home page | 309 # Try to remove NTP as home page |
| 305 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kHomePageIsNewTabPage)) | 310 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kHomePageIsNewTabPage)) |
| 306 self.assertRaises( | 311 self.assertRaises( |
| 307 pyauto.JSONInterfaceError, | 312 pyauto.JSONInterfaceError, |
| 308 lambda: self.SetPrefs(pyauto.kHomePageIsNewTabPage, False)) | 313 lambda: self.SetPrefs(pyauto.kHomePageIsNewTabPage, False)) |
| 309 | 314 |
| 310 def testApplicationLocaleValue(self): | 315 def testApplicationLocaleValue(self): |
| 311 """Verify that Chrome can be launched only in a specific locale.""" | 316 """Verify that Chrome can be launched only in a specific locale.""" |
| 312 if self.IsWin(): | 317 if self.IsWin(): |
| 313 policy = {'ApplicationLocaleValue': 'hi'} | 318 policy = {'ApplicationLocaleValue': 'hi'} |
| 314 self.SetPolicies(policy) | 319 self.SetUserPolicy(policy) |
| 315 self.assertTrue( | 320 self.assertTrue( |
| 316 'hi' in self.GetPrefsInfo().Prefs()['intl']['accept_languages'], | 321 'hi' in self.GetPrefsInfo().Prefs()['intl']['accept_languages'], |
| 317 msg='Chrome locale is not Hindi.') | 322 msg='Chrome locale is not Hindi.') |
| 318 # TODO(sunandt): Try changing the application locale to another language. | 323 # TODO(sunandt): Try changing the application locale to another language. |
| 319 else: | 324 else: |
| 320 raise NotImplementedError() | 325 raise NotImplementedError() |
| 321 | 326 |
| 322 def testDeveloperToolsDisabled(self): | 327 def testDeveloperToolsDisabled(self): |
| 323 """Verify that devtools window cannot be launched.""" | 328 """Verify that devtools window cannot be launched.""" |
| 324 # DevTools process can be seen by PyAuto only when it's undocked. | 329 # DevTools process can be seen by PyAuto only when it's undocked. |
| 325 policy = {'DeveloperToolsDisabled': True} | 330 policy = {'DeveloperToolsDisabled': True} |
| 326 self.SetPolicies(policy) | 331 self.SetUserPolicy(policy) |
| 327 self.SetPrefs(pyauto.kDevToolsOpenDocked, False) | 332 self.SetPrefs(pyauto.kDevToolsOpenDocked, False) |
| 328 self.ApplyAccelerator(pyauto.IDC_DEV_TOOLS) | 333 self.ApplyAccelerator(pyauto.IDC_DEV_TOOLS) |
| 329 self.assertEquals(1, len(self.GetBrowserInfo()['windows']), | 334 self.assertEquals(1, len(self.GetBrowserInfo()['windows']), |
| 330 msg='Devtools window launched.') | 335 msg='Devtools window launched.') |
| 331 policy = {'DeveloperToolsDisabled': False} | 336 policy = {'DeveloperToolsDisabled': False} |
| 332 self.SetPolicies(policy) | 337 self.SetUserPolicy(policy) |
| 333 self.ApplyAccelerator(pyauto.IDC_DEV_TOOLS) | 338 self.ApplyAccelerator(pyauto.IDC_DEV_TOOLS) |
| 334 self.assertEquals(2, len(self.GetBrowserInfo()['windows']), | 339 self.assertEquals(2, len(self.GetBrowserInfo()['windows']), |
| 335 msg='Devtools window not launched.') | 340 msg='Devtools window not launched.') |
| 336 | 341 |
| 337 def testDisableSPDY(self): | 342 def testDisableSPDY(self): |
| 338 """Verify that SPDY is disabled.""" | 343 """Verify that SPDY is disabled.""" |
| 339 policy = {'DisableSpdy': True} | 344 policy = {'DisableSpdy': True} |
| 340 self.SetPolicies(policy) | 345 self.SetUserPolicy(policy) |
| 341 self.NavigateToURL('chrome://net-internals/#spdy') | 346 self.NavigateToURL('chrome://net-internals/#spdy') |
| 342 self.assertEquals(0, self.FindInPage('SPDY Enabled: true')['match_count']) | 347 self.assertEquals(0, self.FindInPage('SPDY Enabled: true')['match_count']) |
| 343 self.assertEquals( | 348 self.assertEquals( |
| 344 1, | 349 1, |
| 345 self.FindInPage('SPDY Enabled: false', tab_index=0)['match_count'], | 350 self.FindInPage('SPDY Enabled: false', tab_index=0)['match_count'], |
| 346 msg='SPDY is not disabled.') | 351 msg='SPDY is not disabled.') |
| 347 policy = {'DisableSpdy': False} | 352 policy = {'DisableSpdy': False} |
| 348 self.SetPolicies(policy) | 353 self.SetUserPolicy(policy) |
| 349 self.GetBrowserWindow(0).GetTab(0).Reload() | 354 self.GetBrowserWindow(0).GetTab(0).Reload() |
| 350 self.assertEquals( | 355 self.assertEquals( |
| 351 1, | 356 1, |
| 352 self.FindInPage('SPDY Enabled: true', tab_index=0)['match_count'], | 357 self.FindInPage('SPDY Enabled: true', tab_index=0)['match_count'], |
| 353 msg='SPDY is not disabled.') | 358 msg='SPDY is not disabled.') |
| 354 | 359 |
| 355 def testDisabledPlugins(self): | 360 def testDisabledPlugins(self): |
| 356 """Verify that disabled plugins cannot be enabled.""" | 361 """Verify that disabled plugins cannot be enabled.""" |
| 357 policy = {'DisabledPlugins': ['Shockwave Flash']} | 362 policy = {'DisabledPlugins': ['Shockwave Flash']} |
| 358 self.SetPolicies(policy) | 363 self.SetUserPolicy(policy) |
| 359 for plugin in self.GetPluginsInfo().Plugins(): | 364 for plugin in self.GetPluginsInfo().Plugins(): |
| 360 if 'Flash' in plugin['name']: | 365 if 'Flash' in plugin['name']: |
| 361 self.assertRaises(pyauto.JSONInterfaceError, | 366 self.assertRaises(pyauto.JSONInterfaceError, |
| 362 lambda: self.EnablePlugin(plugin['path'])) | 367 lambda: self.EnablePlugin(plugin['path'])) |
| 363 return | 368 return |
| 364 | 369 |
| 365 def testDisabledPluginsException(self): | 370 def testDisabledPluginsException(self): |
| 366 """Verify that plugins given exceptions can be managed by users. | 371 """Verify that plugins given exceptions can be managed by users. |
| 367 | 372 |
| 368 Chrome PDF Viewer is disabled using DisabledPlugins policy. | 373 Chrome PDF Viewer is disabled using DisabledPlugins policy. |
| 369 User can still toggle the plugin setting when an exception is given for a | 374 User can still toggle the plugin setting when an exception is given for a |
| 370 plugin. So we are trying to enable Chrome PDF Viewer. | 375 plugin. So we are trying to enable Chrome PDF Viewer. |
| 371 """ | 376 """ |
| 372 policy = { | 377 policy = { |
| 373 'DisabledPlugins': ['Chrome PDF Viewer'], | 378 'DisabledPlugins': ['Chrome PDF Viewer'], |
| 374 'DisabledPluginsExceptions': ['Chrome PDF Viewer'] | 379 'DisabledPluginsExceptions': ['Chrome PDF Viewer'] |
| 375 } | 380 } |
| 376 self.SetPolicies(policy) | 381 self.SetUserPolicy(policy) |
| 377 for plugin in self.GetPluginsInfo().Plugins(): | 382 for plugin in self.GetPluginsInfo().Plugins(): |
| 378 if 'Chrome PDF Viewer' in plugin['name']: | 383 if 'Chrome PDF Viewer' in plugin['name']: |
| 379 self.EnablePlugin(plugin['path']) | 384 self.EnablePlugin(plugin['path']) |
| 380 return | 385 return |
| 381 | 386 |
| 382 def testEnabledPlugins(self): | 387 def testEnabledPlugins(self): |
| 383 """Verify that enabled plugins cannot be disabled.""" | 388 """Verify that enabled plugins cannot be disabled.""" |
| 384 policy = {'EnabledPlugins': ['Shockwave Flash']} | 389 policy = {'EnabledPlugins': ['Shockwave Flash']} |
| 385 self.SetPolicies(policy) | 390 self.SetUserPolicy(policy) |
| 386 for plugin in self.GetPluginsInfo().Plugins(): | 391 for plugin in self.GetPluginsInfo().Plugins(): |
| 387 if 'Flash' in plugin['name']: | 392 if 'Flash' in plugin['name']: |
| 388 self.assertRaises(pyauto.JSONInterfaceError, | 393 self.assertRaises(pyauto.JSONInterfaceError, |
| 389 lambda: self.DisablePlugin(plugin['path'])) | 394 lambda: self.DisablePlugin(plugin['path'])) |
| 390 return | 395 return |
| 391 logging.debug('Flash is not present.') | 396 logging.debug('Flash is not present.') |
| 392 | 397 |
| 393 def testAlwaysAuthorizePlugins(self): | 398 def testAlwaysAuthorizePlugins(self): |
| 394 """Verify plugins are always allowed to run when policy is set.""" | 399 """Verify plugins are always allowed to run when policy is set.""" |
| 395 policy = {'AlwaysAuthorizePlugins': True} | 400 policy = {'AlwaysAuthorizePlugins': True} |
| 396 self.SetPolicies(policy) | 401 self.SetUserPolicy(policy) |
| 397 url = self.GetFileURLForDataPath('plugin', 'java_new.html') | 402 url = self.GetFileURLForDataPath('plugin', 'java_new.html') |
| 398 self.NavigateToURL(url) | 403 self.NavigateToURL(url) |
| 399 self.assertFalse(self.WaitForInfobarCount(1)) | 404 self.assertFalse(self.WaitForInfobarCount(1)) |
| 400 pid = self._GetPluginPID('Java') | 405 pid = self._GetPluginPID('Java') |
| 401 self.assertTrue(pid, 'No plugin process for java') | 406 self.assertTrue(pid, 'No plugin process for java') |
| 402 policy = {'AlwaysAuthorizePlugins': False} | 407 policy = {'AlwaysAuthorizePlugins': False} |
| 403 self.NavigateToURL(url) | 408 self.NavigateToURL(url) |
| 404 self.assertFalse(self.WaitForInfobarCount(1)) | 409 self.assertFalse(self.WaitForInfobarCount(1)) |
| 405 pid = self._GetPluginPID('Java') | 410 pid = self._GetPluginPID('Java') |
| 406 self.assertTrue(pid, 'No plugin process for java') | 411 self.assertTrue(pid, 'No plugin process for java') |
| 407 | 412 |
| 408 def testSetDownloadDirectory(self): | 413 def testSetDownloadDirectory(self): |
| 409 """Verify download directory and prompt cannot be modified.""" | 414 """Verify download directory and prompt cannot be modified.""" |
| 410 # Check for changing the download directory location | 415 # Check for changing the download directory location |
| 411 download_default_dir = self.GetDownloadDirectory().value() | 416 download_default_dir = self.GetDownloadDirectory().value() |
| 412 self.assertEqual( | 417 self.assertEqual( |
| 413 download_default_dir, | 418 download_default_dir, |
| 414 self.GetPrefsInfo().Prefs()['download']['default_directory'], | 419 self.GetPrefsInfo().Prefs()['download']['default_directory'], |
| 415 msg='Downloads directory is not set correctly.') | 420 msg='Downloads directory is not set correctly.') |
| 416 self.SetPrefs(pyauto.kDownloadDefaultDirectory, 'download') | 421 self.SetPrefs(pyauto.kDownloadDefaultDirectory, 'download') |
| 417 new_download_dir = os.path.abspath(os.path.join(download_default_dir, | 422 new_download_dir = os.path.abspath(os.path.join(download_default_dir, |
| 418 os.pardir)) | 423 os.pardir)) |
| 419 policy = {'DownloadDirectory': new_download_dir} | 424 policy = {'DownloadDirectory': new_download_dir} |
| 420 self.SetPolicies(policy) | 425 self.SetUserPolicy(policy) |
| 421 self.assertEqual( | 426 self.assertEqual( |
| 422 new_download_dir, | 427 new_download_dir, |
| 423 self.GetPrefsInfo().Prefs()['download']['default_directory'], | 428 self.GetPrefsInfo().Prefs()['download']['default_directory'], |
| 424 msg='Downloads directory is not set correctly.') | 429 msg='Downloads directory is not set correctly.') |
| 425 self.assertRaises( | 430 self.assertRaises( |
| 426 pyauto.JSONInterfaceError, | 431 pyauto.JSONInterfaceError, |
| 427 lambda: self.SetPrefs(pyauto.kDownloadDefaultDirectory, | 432 lambda: self.SetPrefs(pyauto.kDownloadDefaultDirectory, |
| 428 'download')) | 433 'download')) |
| 429 # Check for changing the option 'Ask for each download' | 434 # Check for changing the option 'Ask for each download' |
| 430 self.assertRaises( | 435 self.assertRaises( |
| 431 pyauto.JSONInterfaceError, | 436 pyauto.JSONInterfaceError, |
| 432 lambda: self.SetPrefs(pyauto.kPromptForDownload, True)) | 437 lambda: self.SetPrefs(pyauto.kPromptForDownload, True)) |
| 433 | 438 |
| 434 def testIncognitoEnabled(self): | 439 def testIncognitoEnabled(self): |
| 435 """Verify that incognito window can be launched.""" | 440 """Verify that incognito window can be launched.""" |
| 436 policy = {'IncognitoEnabled': False} | 441 policy = {'IncognitoEnabled': False} |
| 437 self.SetPolicies(policy) | 442 self.SetUserPolicy(policy) |
| 438 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 443 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| 439 self.assertEquals(1, self.GetBrowserWindowCount()) | 444 self.assertEquals(1, self.GetBrowserWindowCount()) |
| 440 policy = {'IncognitoEnabled': True} | 445 policy = {'IncognitoEnabled': True} |
| 441 self.SetPolicies(policy) | 446 self.SetUserPolicy(policy) |
| 442 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 447 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| 443 self.assertEquals(2, self.GetBrowserWindowCount()) | 448 self.assertEquals(2, self.GetBrowserWindowCount()) |
| 444 | 449 |
| 445 def testSavingBrowserHistoryDisabled(self): | 450 def testSavingBrowserHistoryDisabled(self): |
| 446 """Verify that browsing history is not being saved.""" | 451 """Verify that browsing history is not being saved.""" |
| 447 policy = {'SavingBrowserHistoryDisabled': True} | 452 policy = {'SavingBrowserHistoryDisabled': True} |
| 448 self.SetPolicies(policy) | 453 self.SetUserPolicy(policy) |
| 449 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'empty.html')) | 454 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'empty.html')) |
| 450 self.NavigateToURL(url) | 455 self.NavigateToURL(url) |
| 451 self.assertFalse(self.GetHistoryInfo().History(), | 456 self.assertFalse(self.GetHistoryInfo().History(), |
| 452 msg='History is being saved.') | 457 msg='History is being saved.') |
| 453 policy = {'SavingBrowserHistoryDisabled': False} | 458 policy = {'SavingBrowserHistoryDisabled': False} |
| 454 self.SetPolicies(policy) | 459 self.SetUserPolicy(policy) |
| 455 self.NavigateToURL(url) | 460 self.NavigateToURL(url) |
| 456 self.assertTrue(self.GetHistoryInfo().History(), | 461 self.assertTrue(self.GetHistoryInfo().History(), |
| 457 msg='History not is being saved.') | 462 msg='History not is being saved.') |
| 458 | 463 |
| 459 def testTranslateEnabled(self): | 464 def testTranslateEnabled(self): |
| 460 """Verify that translate happens if policy enables it.""" | 465 """Verify that translate happens if policy enables it.""" |
| 461 policy = {'TranslateEnabled': True} | 466 policy = {'TranslateEnabled': True} |
| 462 self.SetPolicies(policy) | 467 self.SetUserPolicy(policy) |
| 463 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate)) | 468 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate)) |
| 464 url = self.GetFileURLForDataPath('translate', 'es', 'google.html') | 469 url = self.GetFileURLForDataPath('translate', 'es', 'google.html') |
| 465 self.NavigateToURL(url) | 470 self.NavigateToURL(url) |
| 466 self.assertTrue(self.WaitForInfobarCount(1)) | 471 self.assertTrue(self.WaitForInfobarCount(1)) |
| 467 translate_info = self.GetTranslateInfo() | 472 translate_info = self.GetTranslateInfo() |
| 468 self.assertEqual('es', translate_info['original_language']) | 473 self.assertEqual('es', translate_info['original_language']) |
| 469 self.assertFalse(translate_info['page_translated']) | 474 self.assertFalse(translate_info['page_translated']) |
| 470 self.assertTrue(translate_info['can_translate_page']) | 475 self.assertTrue(translate_info['can_translate_page']) |
| 471 self.assertTrue('translate_bar' in translate_info) | 476 self.assertTrue('translate_bar' in translate_info) |
| 472 self.assertFalse(self._GetPrefIsManagedError(pyauto.kEnableTranslate, True)) | 477 self.assertFalse(self._GetPrefIsManagedError(pyauto.kEnableTranslate, True)) |
| 473 policy = {'TranslateEnabled': False} | 478 policy = {'TranslateEnabled': False} |
| 474 self.SetPolicies(policy) | 479 self.SetUserPolicy(policy) |
| 475 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate)) | 480 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate)) |
| 476 self.NavigateToURL(url) | 481 self.NavigateToURL(url) |
| 477 self.assertFalse(self.WaitForInfobarCount(1)) | 482 self.assertFalse(self.WaitForInfobarCount(1)) |
| 478 self.assertFalse(self._GetPrefIsManagedError(pyauto.kEnableTranslate, | 483 self.assertFalse(self._GetPrefIsManagedError(pyauto.kEnableTranslate, |
| 479 False)) | 484 False)) |
| 480 | 485 |
| 481 def testDefaultSearchProviderOptions(self): | 486 def testDefaultSearchProviderOptions(self): |
| 482 """Verify a default search is performed when using omnibox.""" | 487 """Verify a default search is performed when using omnibox.""" |
| 483 policy = { | 488 policy = { |
| 484 'DefaultSearchProviderEnabled': True, | 489 'DefaultSearchProviderEnabled': True, |
| 485 'DefaultSearchProviderEncodings': ['UTF-8', 'UTF-16', 'GB2312', | 490 'DefaultSearchProviderEncodings': ['UTF-8', 'UTF-16', 'GB2312', |
| 486 'ISO-8859-1'], | 491 'ISO-8859-1'], |
| 487 'DefaultSearchProviderIconURL': 'http://search.my.company/favicon.ico', | 492 'DefaultSearchProviderIconURL': 'http://search.my.company/favicon.ico', |
| 488 'DefaultSearchProviderInstantURL': ('http://search.my.company/' | 493 'DefaultSearchProviderInstantURL': ('http://search.my.company/' |
| 489 'suggest?q={searchTerms}'), | 494 'suggest?q={searchTerms}'), |
| 490 'DefaultSearchProviderKeyword': 'mis', | 495 'DefaultSearchProviderKeyword': 'mis', |
| 491 'DefaultSearchProviderName': 'My Intranet Search', | 496 'DefaultSearchProviderName': 'My Intranet Search', |
| 492 'DefaultSearchProviderSearchURL': ('http://search.my.company/' | 497 'DefaultSearchProviderSearchURL': ('http://search.my.company/' |
| 493 'search?q={searchTerms}'), | 498 'search?q={searchTerms}'), |
| 494 'DefaultSearchProviderSuggestURL': ('http://search.my.company/' | 499 'DefaultSearchProviderSuggestURL': ('http://search.my.company/' |
| 495 'suggest?q={searchTerms}'), | 500 'suggest?q={searchTerms}'), |
| 496 } | 501 } |
| 497 self.SetPolicies(policy) | 502 self.SetUserPolicy(policy) |
| 498 self.assertFalse( | 503 self.assertFalse( |
| 499 self._GetPrefIsManagedError(pyauto.kDefaultSearchProviderEnabled, True)) | 504 self._GetPrefIsManagedError(pyauto.kDefaultSearchProviderEnabled, True)) |
| 500 intranet_engine = [x for x in self.GetSearchEngineInfo() | 505 intranet_engine = [x for x in self.GetSearchEngineInfo() |
| 501 if x['keyword'] == 'mis'] | 506 if x['keyword'] == 'mis'] |
| 502 self.assertTrue(intranet_engine) | 507 self.assertTrue(intranet_engine) |
| 503 self.assertTrue(intranet_engine[0]['is_default']) | 508 self.assertTrue(intranet_engine[0]['is_default']) |
| 504 self.SetOmniboxText('google chrome') | 509 self.SetOmniboxText('google chrome') |
| 505 self.WaitUntilOmniboxQueryDone() | 510 self.WaitUntilOmniboxQueryDone() |
| 506 self.OmniboxAcceptInput() | 511 self.OmniboxAcceptInput() |
| 507 self.assertTrue('search.my.company' in self.GetActiveTabURL().spec()) | 512 self.assertTrue('search.my.company' in self.GetActiveTabURL().spec()) |
| 508 policy = { | 513 policy = { |
| 509 'DefaultSearchProviderEnabled': False, | 514 'DefaultSearchProviderEnabled': False, |
| 510 } | 515 } |
| 511 self.SetPolicies(policy) | 516 self.SetUserPolicy(policy) |
| 512 self.assertFalse( | 517 self.assertFalse( |
| 513 self._GetPrefIsManagedError(pyauto.kDefaultSearchProviderEnabled, | 518 self._GetPrefIsManagedError(pyauto.kDefaultSearchProviderEnabled, |
| 514 False)) | 519 False)) |
| 515 self.SetOmniboxText('deli') | 520 self.SetOmniboxText('deli') |
| 516 self.WaitUntilOmniboxQueryDone() | 521 self.WaitUntilOmniboxQueryDone() |
| 517 self.assertRaises(pyauto.JSONInterfaceError, | 522 self.assertRaises(pyauto.JSONInterfaceError, |
| 518 lambda: self.OmniboxAcceptInput()) | 523 lambda: self.OmniboxAcceptInput()) |
| 519 | 524 |
| 520 # Needed for extension tests | 525 # Needed for extension tests |
| 521 _GOOD_CRX_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf' | 526 _GOOD_CRX_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf' |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 # There is an issue where if you uninstall and reinstall and extension | 597 # There is an issue where if you uninstall and reinstall and extension |
| 593 # quickly with self.InstallExtension, the reinstall fails. This is a hack | 598 # quickly with self.InstallExtension, the reinstall fails. This is a hack |
| 594 # to fix it. Bug coming soon. | 599 # to fix it. Bug coming soon. |
| 595 self.NavigateToURL('chrome:extensions') | 600 self.NavigateToURL('chrome:extensions') |
| 596 | 601 |
| 597 def testExtensionInstallPopulatedBlacklist(self): | 602 def testExtensionInstallPopulatedBlacklist(self): |
| 598 """Verify blacklisted extensions cannot be installed.""" | 603 """Verify blacklisted extensions cannot be installed.""" |
| 599 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. | 604 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. |
| 600 self._RemoveTestingExtensions() | 605 self._RemoveTestingExtensions() |
| 601 # Blacklist good.crx | 606 # Blacklist good.crx |
| 602 self.SetPolicies({ | 607 self.SetUserPolicy({ |
| 603 'ExtensionInstallBlacklist': [self._GOOD_CRX_ID] | 608 'ExtensionInstallBlacklist': [self._GOOD_CRX_ID] |
| 604 }) | 609 }) |
| 605 self._AttemptExtensionInstallThatShouldFail('good.crx') | 610 self._AttemptExtensionInstallThatShouldFail('good.crx') |
| 606 # Check adblock is installed. | 611 # Check adblock is installed. |
| 607 self._AttemptExtensionInstallThatShouldPass('adblock.crx') | 612 self._AttemptExtensionInstallThatShouldPass('adblock.crx') |
| 608 | 613 |
| 609 def testExtensionInstallFailWithGlobalBlacklist(self): | 614 def testExtensionInstallFailWithGlobalBlacklist(self): |
| 610 """Verify no extensions can be installed when all are blacklisted.""" | 615 """Verify no extensions can be installed when all are blacklisted.""" |
| 611 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. | 616 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. |
| 612 self._RemoveTestingExtensions() | 617 self._RemoveTestingExtensions() |
| 613 # Block installs of all extensions | 618 # Block installs of all extensions |
| 614 self.SetPolicies({ | 619 self.SetUserPolicy({ |
| 615 'ExtensionInstallBlacklist': ['*'] | 620 'ExtensionInstallBlacklist': ['*'] |
| 616 }) | 621 }) |
| 617 self._AttemptExtensionInstallThatShouldFail('good.crx') | 622 self._AttemptExtensionInstallThatShouldFail('good.crx') |
| 618 self._AttemptExtensionInstallThatShouldFail('adblock.crx') | 623 self._AttemptExtensionInstallThatShouldFail('adblock.crx') |
| 619 | 624 |
| 620 def testExtensionInstallWithGlobalBlacklistAndWhitelistedExtension(self): | 625 def testExtensionInstallWithGlobalBlacklistAndWhitelistedExtension(self): |
| 621 """Verify whitelisted extension is installed when all are blacklisted.""" | 626 """Verify whitelisted extension is installed when all are blacklisted.""" |
| 622 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. | 627 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. |
| 623 self._RemoveTestingExtensions() | 628 self._RemoveTestingExtensions() |
| 624 # Block installs of all extensions, but whitelist adblock.crx | 629 # Block installs of all extensions, but whitelist adblock.crx |
| 625 self.SetPolicies({ | 630 self.SetUserPolicy({ |
| 626 'ExtensionInstallBlacklist': ['*'], | 631 'ExtensionInstallBlacklist': ['*'], |
| 627 'ExtensionInstallWhitelist': [self._ADBLOCK_CRX_ID] | 632 'ExtensionInstallWhitelist': [self._ADBLOCK_CRX_ID] |
| 628 }) | 633 }) |
| 629 self._AttemptExtensionInstallThatShouldFail('good.crx') | 634 self._AttemptExtensionInstallThatShouldFail('good.crx') |
| 630 self._AttemptExtensionInstallThatShouldPass('adblock.crx') | 635 self._AttemptExtensionInstallThatShouldPass('adblock.crx') |
| 631 | 636 |
| 632 # TODO(krisr): Enable this test once we figure out why it isn't downloading | 637 # TODO(krisr): Enable this test once we figure out why it isn't downloading |
| 633 # the extension, crbug.com/118123. | 638 # the extension, crbug.com/118123. |
| 634 def testExtensionInstallFromForceList(self): | 639 def testExtensionInstallFromForceList(self): |
| 635 """Verify force install extensions are installed.""" | 640 """Verify force install extensions are installed.""" |
| 636 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. | 641 # TODO(krisr): Remove this when crosbug.com/27227 is fixed. |
| 637 self._RemoveTestingExtensions() | 642 self._RemoveTestingExtensions() |
| 638 # Force an extension download from the webstore. | 643 # Force an extension download from the webstore. |
| 639 self.SetPolicies({ | 644 self.SetUserPolicy({ |
| 640 'ExtensionInstallForcelist': [self._SCREEN_CAPTURE_CRX_ID], | 645 'ExtensionInstallForcelist': [self._SCREEN_CAPTURE_CRX_ID], |
| 641 }) | 646 }) |
| 642 # Give the system 30 seconds to go get this extension. We are not sure how | 647 # Give the system 30 seconds to go get this extension. We are not sure how |
| 643 # long it will take the policy to take affect and download the extension. | 648 # long it will take the policy to take affect and download the extension. |
| 644 self.assertTrue(self.WaitUntil(lambda: | 649 self.assertTrue(self.WaitUntil(lambda: |
| 645 self._CheckForExtensionByID(self._SCREEN_CAPTURE_CRX_ID), | 650 self._CheckForExtensionByID(self._SCREEN_CAPTURE_CRX_ID), |
| 646 expect_retval=True), | 651 expect_retval=True), |
| 647 msg='The force install extension was never installed.') | 652 msg='The force install extension was never installed.') |
| 648 | 653 |
| 649 | 654 |
| 650 if __name__ == '__main__': | 655 if __name__ == '__main__': |
| 651 pyauto_functional.Main() | 656 pyauto_functional.Main() |
| OLD | NEW |