Rebaseline svg/custom/foreignObject-crash-on-hover.xml.
[chromium-blink-merge.git] / o3d / tests / lab / configure_ie.py
blob6279308411f8cb96e4ab832a8695d96628bc4277
1 #!/usr/bin/python
2 # Copyright (c) 2006-2008 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.
6 """Manages configuring Microsoft Internet Explorer."""
8 import logging
9 import os
10 import re
11 import subprocess
12 import urllib
13 import urlparse
14 import util
17 def _ConfigureSecurityKeyForZone(zone_number, key, value):
18 """Set key under the Zone settings in Security.
20 Args:
21 zone_number: Integer identifier of zone to edit.
22 key: key under "HKEY_CURRENT_USER\Software\Microsoft\Windows\
23 CurrentVersion\Internet Settings\Zones\<Zone>"
24 to edit.
25 value: new value for key.
27 Returns:
28 True on success.
29 """
30 if not util.RegAdd(('HKEY_CURRENT_USER\\Software\\Microsoft\\'
31 'Windows\\CurrentVersion\\Internet Settings\\'
32 'Zones\\%s' % zone_number), key, util.REG_DWORD, value):
33 return False
34 return True
37 def GetInstalledVersion():
38 """Reads the version of IE installed by checking the registry.
40 The complete version is returned. For example: 6.0.2900.55.5512.
42 Returns:
43 String for version or None on failure.
44 """
45 return util.RegQuery('HKLM\\Software\\Microsoft\\Internet Explorer','Version')
48 def ConfigurePopupBlocker(active):
49 """Configure if popup blocker is active for IE 8.
51 Args:
52 active: new active state for popup blocker.
54 Returns:
55 True on success.
56 """
57 if active:
58 value = '1'
59 else:
60 value = '0'
62 # IE 8
63 if not util.RegAdd(('HKEY_LOCAL_MACHINE\\Software\\Microsoft'
64 '\\Internet Explorer\\Main\\FeatureControl\\'
65 'FEATURE_WEBOC_POPUPMANAGEMENT'), 'iexplore.exe',
66 util.REG_DWORD, value):
67 return False
69 # IE 6
70 if active:
71 value = 'yes'
72 else:
73 value = 'no'
75 if not util.RegAdd(('HKEY_CURRENT_USER\\Software\\Microsoft\\'
76 'Internet Explorer\\New Windows'),
77 'PopupMgr', util.REG_SZ, value):
78 return False
80 return True
83 def DisableDefaultBrowserCheck(active):
84 """Turn off the check to be set as default browser on start up.
86 Args:
87 active: if True then disables browser check, otherwise enables.
89 Returns:
90 True on success.
91 """
92 if active:
93 value = 'no'
94 else:
95 value = 'yes'
97 path = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main'
99 if not util.RegAdd(path, 'Check_Associations', util.REG_SZ, value):
100 return False
102 return True
105 def DisableWelcomeWindowForInternetExplorer8():
106 """Turn off the window which asks user to configure IE8 on start up.
108 Returns:
109 True on success.
111 path = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main'
113 if not util.RegAdd(path, 'IE8RunOnceLastShown', util.REG_DWORD, '1'):
114 return False
116 if not util.RegAdd(path, 'IE8RunOnceLastShown_TIMESTAMP', util.REG_BINARY,
117 '79a29ba0bbb7c901'):
118 return False
120 if not util.RegAdd(path, 'IE8RunOnceCompletionTime', util.REG_BINARY,
121 'f98da5b2bbb7c901'):
122 return False
124 if not util.RegAdd(path, 'IE8TourShown', util.REG_DWORD, '1'):
125 return False
127 if not util.RegAdd(path, 'IE8TourShownTime', util.REG_BINARY,
128 '1ada825779b6c901'):
129 return False
131 if not util.RegAdd(path, 'DisableFirstRunCustomize', util.REG_DWORD, '1'):
132 return False
134 return True
137 def DisableInformationBarIntro():
138 """Turn off the dialog which tells you about information bar.
140 Returns:
141 True on success.
143 path = (r'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer'
144 r'\InformationBar')
146 if not util.RegAdd(path, 'FirstTime', util.REG_DWORD, '0'):
147 return False
149 return True
152 def DisableInternetExplorerPhishingFilter():
153 """Turn off the dialog for Phishing filter which blocks tests on IE 7.
155 Returns:
156 True on success.
158 path = ('HKEY_CURRENT_USER\\Software\\Microsoft\\'
159 'Internet Explorer\\PhishingFilter')
161 if not util.RegAdd(path, 'Enabled', util.REG_DWORD, '1'):
162 return False
164 if not util.RegAdd(path, 'ShownVerifyBalloon', util.REG_DWORD, '1'):
165 return False
167 if not util.RegAdd(path, 'EnabledV8', util.REG_DWORD, '1'):
168 return False
170 return True
173 def ConfigureAllowActiveX(activate):
174 """Configure internet zone to use Active X.
176 Args:
177 activate: Turn on if True, otherwise turn off.
179 Returns:
180 True on success.
182 internet_zone = 3
184 if activate:
185 value = '00000000'
186 else:
187 value = '00000003'
189 return _ConfigureSecurityKeyForZone(internet_zone, '1200', value)
192 def ConfigureAllowPreviouslyUnusedActiveXControlsToRun(activate):
193 """Configure internet zone to allow new Active X controls to run.
195 Args:
196 activate: Turn on if True, otherwise turn off.
198 Returns:
199 True on success.
201 internet_zone = 3
203 if activate:
204 value = '00000000'
205 else:
206 value = '00000003'
208 return _ConfigureSecurityKeyForZone(internet_zone, '1208', value)
211 def ConfigureAllowAllDomainsToUseActiveX(activate):
212 """Configure internet zone to allow all domains to use Active X.
214 Args:
215 activate: Turn on if True, otherwise turn off.
217 Returns:
218 True on success.
220 internet_zone = 3
222 if activate:
223 value = '00000000'
224 else:
225 value = '00000003'
227 return _ConfigureSecurityKeyForZone(internet_zone, '120B', value)
230 def ConfigureAllowActiveContentFromMyComputer(activate):
231 """Allow Active X to run from local files loaded from My Computer.
233 This option is shown under Security of the Advanced tab of Internet Options.
235 Args:
236 activate: Turn on if True, otherwise turn off.
238 Returns:
239 True on success.
241 if activate:
242 value = '0'
243 else:
244 value = '1'
246 if not util.RegAdd(('HKEY_CURRENT_USER\\Software\\Microsoft\\'
247 'Internet Explorer\\Main\\FeatureControl\\'
248 'FEATURE_LOCALMACHINE_LOCKDOWN'),
249 'iexplore.exe', util.REG_DWORD, value):
250 return False
251 if not util.RegAdd(('HKLM\\SOFTWARE\\Microsoft\\Internet Explorer\\Main\\'
252 'FeatureControl\\FEATURE_LOCALMACHINE_LOCKDOWN'),
253 'iexplore.exe', util.REG_DWORD, value):
254 return False
256 return True
259 def ConfigureIE():
260 """Calls the other methods to allow testing with Internet Explorer.
262 Returns:
263 True on success.
265 on = True
266 logging.info('Configuring IE...')
267 logging.info('Allowing all active domains to use ActiveX...')
268 if not ConfigureAllowAllDomainsToUseActiveX(on):
269 return False
271 logging.info('Allowing ActiveX...')
272 if not ConfigureAllowActiveX(on):
273 return False
275 logging.info('Allowing previously unused ActiveX to run...')
276 if not ConfigureAllowPreviouslyUnusedActiveXControlsToRun(on):
277 return False
279 logging.info('Disabling default browser check...')
280 if not DisableDefaultBrowserCheck(on):
281 return False
283 logging.info('Allowing active content from my computer...')
284 if not ConfigureAllowActiveContentFromMyComputer(on):
285 return False
287 logging.info('Disabling popup blocker...')
288 if not ConfigurePopupBlocker(False):
289 return False
291 logging.info('Disabling Phishing Filter...')
292 if not DisableInternetExplorerPhishingFilter():
293 return False
295 logging.info('Disabling welcome window for IE 8...')
296 if not DisableWelcomeWindowForInternetExplorer8():
297 return False
299 logging.info('Disabling info bar intro...')
300 if not DisableInformationBarIntro():
301 return False
303 return True