Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: chrome/test/functional/passwords.py

Issue 10409077: Revert 138289 - Fix and enable testPasswordAutofilledInIncognito. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mergeinfo
OLDNEW
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 os 6 import os
7 from urlparse import urlparse
8 7
9 import pyauto_functional # Must be imported before pyauto 8 import pyauto_functional # Must be imported before pyauto
10 import pyauto 9 import pyauto
11 import test_utils 10 import test_utils
12 from webdriver_pages import settings 11 from webdriver_pages import settings
13 12
14 13
15 class PasswordTest(pyauto.PyUITest): 14 class PasswordTest(pyauto.PyUITest):
16 """Tests that passwords work correctly.""" 15 """Tests that passwords work correctly."""
17 16
18 INFOBAR_TYPE = 'password_infobar' 17 INFOBAR_TYPE = 'password_infobar'
19 URL = 'https://accounts.google.com/ServiceLogin' 18 URL = 'https://accounts.google.com/ServiceLogin'
20 URL_HTTPS = 'https://accounts.google.com/Login' 19 URL_HTTPS = 'https://accounts.google.com/Login'
21 URL_LOGOUT = 'https://accounts.google.com/Logout' 20 URL_LOGOUT = 'https://accounts.google.com/Logout'
22 HOSTNAME = 'https://' + urlparse(URL).netloc
23 USERNAME_ELEM = 'Email'
24 PASSWORD_ELEM = 'Passwd'
25 USERNAME = 'test@google.com'
26 PASSWORD = 'test.password'
27 21
28 def Debug(self): 22 def Debug(self):
29 """Test method for experimentation. 23 """Test method for experimentation.
30 24
31 This method will not run automatically. 25 This method will not run automatically.
32 """ 26 """
33 while True: 27 while True:
34 raw_input('Interact with the browser and hit <enter> to dump passwords. ') 28 raw_input('Interact with the browser and hit <enter> to dump passwords. ')
35 print '*' * 20 29 print '*' * 20
36 self.pprint(self.GetSavedPasswords()) 30 self.pprint(self.GetSavedPasswords())
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 # Wait until username/password is filled by the Password manager on the 73 # Wait until username/password is filled by the Password manager on the
80 # login page. 74 # login page.
81 js_template = """ 75 js_template = """
82 var value = ""; 76 var value = "";
83 var element = document.getElementById("%s"); 77 var element = document.getElementById("%s");
84 if (element) 78 if (element)
85 value = element.value; 79 value = element.value;
86 window.domAutomationController.send(value); 80 window.domAutomationController.send(value);
87 """ 81 """
88 self.assertTrue(self.WaitUntil( 82 self.assertTrue(self.WaitUntil(
89 lambda: self.ExecuteJavascript(js_template % self.USERNAME_ELEM, 83 lambda: self.ExecuteJavascript(js_template % 'Email',
90 tab_index, window_index) != '' and 84 tab_index, window_index) != '' and
91 self.ExecuteJavascript(js_template % self.PASSWORD_ELEM, 85 self.ExecuteJavascript(js_template % 'Passwd',
92 tab_index, window_index) != '')) 86 tab_index, window_index) != ''))
93 87
94 def testSavePassword(self): 88 def testSavePassword(self):
95 """Test saving a password and getting saved passwords.""" 89 """Test saving a password and getting saved passwords."""
96 password1 = self._ConstructPasswordDictionary( 90 password1 = self._ConstructPasswordDictionary(
97 'user@example.com', 'test.password', 91 'user@example.com', 'test.password',
98 'https://www.example.com/', 'https://www.example.com/login', 92 'https://www.example.com/', 'https://www.example.com/login',
99 'username', 'password', 'https://www.example.com/login/') 93 'username', 'password', 'https://www.example.com/login/')
100 self.assertTrue(self.AddSavedPassword(password1)) 94 self.assertTrue(self.AddSavedPassword(password1))
101 self.assertEqual(self.GetSavedPasswords(), [password1]) 95 self.assertEqual(self.GetSavedPasswords(), [password1])
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 self.assertEqual(email_value, '', 209 self.assertEqual(email_value, '',
216 msg='Email creds displayed %s.' % email_value) 210 msg='Email creds displayed %s.' % email_value)
217 self.assertEqual(passwd_value, '', msg='Password creds displayed.') 211 self.assertEqual(passwd_value, '', msg='Password creds displayed.')
218 212
219 def testPasswordAutofilledInIncognito(self): 213 def testPasswordAutofilledInIncognito(self):
220 """Verify saved password is autofilled in Incognito mode. 214 """Verify saved password is autofilled in Incognito mode.
221 215
222 Saved passwords should be autofilled once the username is entered in 216 Saved passwords should be autofilled once the username is entered in
223 incognito mode. 217 incognito mode.
224 """ 218 """
225 action_target = self.HOSTNAME
226
227 driver = self.NewWebDriver() 219 driver = self.NewWebDriver()
220 username = 'test@google.com'
221 password = 'test.password'
228 password_dict = self._ConstructPasswordDictionary( 222 password_dict = self._ConstructPasswordDictionary(
229 self.USERNAME, self.PASSWORD, self.HOSTNAME, self.URL, 223 username, password,
230 self.USERNAME_ELEM, self.PASSWORD_ELEM, action_target) 224 'https://www.google.com/', 'https://www.google.com/accounts',
225 'Email', 'Passwd', 'https://www.google.com/accounts')
231 self.AddSavedPassword(password_dict) 226 self.AddSavedPassword(password_dict)
232 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) 227 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
233 self.NavigateToURL(self.URL, 1, 0) 228 self.NavigateToURL(self.URL, 1, 0)
234 # Switch to window 1. 229 # Switch to window 1.
235 driver.switch_to_window(driver.window_handles[1]) 230 driver.switch_to_window(driver.window_handles[1])
236 driver.find_element_by_id( 231 driver.find_element_by_id('Email').send_keys(username + '\t')
237 self.USERNAME_ELEM).send_keys(self.USERNAME + '\t')
238 incognito_passwd = self.GetDOMValue( 232 incognito_passwd = self.GetDOMValue(
239 'document.getElementById("Passwd").value', tab_index=0, windex=1) 233 'document.getElementById("Passwd").value', tab_index=0, windex=1)
240 self.assertEqual(incognito_passwd, self.PASSWORD, 234 self.assertEqual(incognito_passwd, password,
241 msg='Password creds did not autofill in incognito mode.') 235 msg='Password creds did not autofill in incognito mode.')
242 236
243 def testInfoBarDisappearByNavigatingPage(self): 237 def testInfoBarDisappearByNavigatingPage(self):
244 """Test password infobar is dismissed when navigating to different page.""" 238 """Test password infobar is dismissed when navigating to different page."""
245 creds = self.GetPrivateInfo()['test_google_account'] 239 creds = self.GetPrivateInfo()['test_google_account']
246 # Disable one-click login infobar for sync. 240 # Disable one-click login infobar for sync.
247 self.SetPrefs(pyauto.kReverseAutologinEnabled, False) 241 self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
248 # Login to Google account. 242 # Login to Google account.
249 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) 243 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password'])
250 self.PerformActionOnInfobar( 244 self.PerformActionOnInfobar(
251 'accept', infobar_index=test_utils.WaitForInfobarTypeAndGetIndex( 245 'accept', infobar_index=test_utils.WaitForInfobarTypeAndGetIndex(
(...skipping 16 matching lines...) Expand all
268 self, self.INFOBAR_TYPE)) 262 self, self.INFOBAR_TYPE))
269 self.GetBrowserWindow(0).GetTab(0).Reload() 263 self.GetBrowserWindow(0).GetTab(0).Reload()
270 test_utils.AssertInfobarTypeDoesNotAppear(self, self.INFOBAR_TYPE) 264 test_utils.AssertInfobarTypeDoesNotAppear(self, self.INFOBAR_TYPE)
271 265
272 def testPasswdInfoNotStoredWhenAutocompleteOff(self): 266 def testPasswdInfoNotStoredWhenAutocompleteOff(self):
273 """Verify that password infobar does not appear when autocomplete is off. 267 """Verify that password infobar does not appear when autocomplete is off.
274 268
275 If the password field has autocomplete turned off, then the password infobar 269 If the password field has autocomplete turned off, then the password infobar
276 should not offer to save the password info. 270 should not offer to save the password info.
277 """ 271 """
278 password_info = {'Email': self.USERNAME, 272 password_info = {'Email': 'test@google.com',
279 'Passwd': self.PASSWORD} 273 'Passwd': 'test12345'}
280 274
281 # Disable one-click login infobar for sync. 275 # Disable one-click login infobar for sync.
282 self.SetPrefs(pyauto.kReverseAutologinEnabled, False) 276 self.SetPrefs(pyauto.kReverseAutologinEnabled, False)
283 url = self.GetHttpURLForDataPath( 277 url = self.GetHttpURLForDataPath(
284 os.path.join('password', 'password_autocomplete_off_test.html')) 278 os.path.join('password', 'password_autocomplete_off_test.html'))
285 self.NavigateToURL(url) 279 self.NavigateToURL(url)
286 for key, value in password_info.iteritems(): 280 for key, value in password_info.iteritems():
287 script = ('document.getElementById("%s").value = "%s"; ' 281 script = ('document.getElementById("%s").value = "%s"; '
288 'window.domAutomationController.send("done");') % (key, value) 282 'window.domAutomationController.send("done");') % (key, value)
289 self.ExecuteJavascript(script, 0, 0) 283 self.ExecuteJavascript(script, 0, 0)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 password = creds['password'] 346 password = creds['password']
353 # Block cookies for Google accounts domain. 347 # Block cookies for Google accounts domain.
354 self.SetPrefs(pyauto.kContentSettingsPatternPairs, 348 self.SetPrefs(pyauto.kContentSettingsPatternPairs,
355 {'https://accounts.google.com/': {'cookies': 2}}) 349 {'https://accounts.google.com/': {'cookies': 2}})
356 test_utils.GoogleAccountsLogin(self, username, password) 350 test_utils.GoogleAccountsLogin(self, username, password)
357 test_utils.WaitForInfobarTypeAndGetIndex(self, self.INFOBAR_TYPE) 351 test_utils.WaitForInfobarTypeAndGetIndex(self, self.INFOBAR_TYPE)
358 352
359 353
360 if __name__ == '__main__': 354 if __name__ == '__main__':
361 pyauto_functional.Main() 355 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698