Chromium Code Reviews| 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 os | 6 import os |
| 7 | 7 |
| 8 import pyauto_functional # Must be imported before pyauto | 8 import pyauto_functional # Must be imported before pyauto |
| 9 import pyauto | 9 import pyauto |
| 10 import test_utils | 10 import test_utils |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 self.assertEqual(email_value, '', | 209 self.assertEqual(email_value, '', |
| 210 msg='Email creds displayed %s.' % email_value) | 210 msg='Email creds displayed %s.' % email_value) |
| 211 self.assertEqual(passwd_value, '', msg='Password creds displayed.') | 211 self.assertEqual(passwd_value, '', msg='Password creds displayed.') |
| 212 | 212 |
| 213 def testPasswordAutofilledInIncognito(self): | 213 def testPasswordAutofilledInIncognito(self): |
| 214 """Verify saved password is autofilled in Incognito mode. | 214 """Verify saved password is autofilled in Incognito mode. |
| 215 | 215 |
| 216 Saved passwords should be autofilled once the username is entered in | 216 Saved passwords should be autofilled once the username is entered in |
| 217 incognito mode. | 217 incognito mode. |
| 218 """ | 218 """ |
| 219 USERNAME = 'test@google.com' | |
|
Nirnimesh
2012/05/18 03:20:23
please use lowercase for local vars. CAPS looks we
dyu1
2012/05/18 23:44:39
Done.
| |
| 220 PASSWORD = 'test.password' | |
| 221 SIGNON_REALM = 'https://accounts.google.com/' | |
|
Ilya Sherman
2012/05/18 03:14:27
nit: It would be good if you could compute this fr
dyu1
2012/05/18 23:44:39
Done.
| |
| 222 ORIGIN_URL = 'https://accounts.google.com/ServiceLogin' | |
|
Ilya Sherman
2012/05/18 03:14:27
nit: You can use URL for this.
dyu1
2012/05/18 23:44:39
Done.
| |
| 223 USERNAME_ELEM = 'Email' | |
| 224 PASSWORD_ELEM = 'Passwd' | |
|
Ilya Sherman
2012/05/18 03:14:27
nit: These should probably be defined with the oth
dyu1
2012/05/18 23:44:39
Done.
| |
| 225 ACTION_TARGET = 'https://accounts.google.com/' | |
|
Ilya Sherman
2012/05/18 03:14:27
nit: Same comment as for the sign-on realm.
dyu1
2012/05/18 23:44:39
Done.
| |
| 226 | |
| 219 driver = self.NewWebDriver() | 227 driver = self.NewWebDriver() |
| 220 username = 'test@google.com' | |
| 221 password = 'test.password' | |
| 222 password_dict = self._ConstructPasswordDictionary( | 228 password_dict = self._ConstructPasswordDictionary( |
| 223 username, password, | 229 USERNAME, PASSWORD, SIGNON_REALM, ORIGIN_URL, |
| 224 'https://www.google.com/', 'https://www.google.com/accounts', | 230 USERNAME_ELEM, PASSWORD_ELEM, ACTION_TARGET) |
| 225 'Email', 'Passwd', 'https://www.google.com/accounts') | |
| 226 self.AddSavedPassword(password_dict) | 231 self.AddSavedPassword(password_dict) |
| 227 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 232 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| 228 self.NavigateToURL(self.URL, 1, 0) | 233 self.NavigateToURL(self.URL, 1, 0) |
| 229 # Switch to window 1. | 234 # Switch to window 1. |
| 230 driver.switch_to_window(driver.window_handles[1]) | 235 driver.switch_to_window(driver.window_handles[1]) |
| 231 driver.find_element_by_id('Email').send_keys(username + '\t') | 236 driver.find_element_by_id('Email').send_keys(USERNAME + '\t') |
| 232 incognito_passwd = self.GetDOMValue( | 237 incognito_passwd = self.GetDOMValue( |
| 233 'document.getElementById("Passwd").value', tab_index=0, windex=1) | 238 'document.getElementById("Passwd").value', tab_index=0, windex=1) |
| 234 self.assertEqual(incognito_passwd, password, | 239 self.assertEqual(incognito_passwd, PASSWORD, |
| 235 msg='Password creds did not autofill in incognito mode.') | 240 msg='Password creds did not autofill in incognito mode.') |
| 236 | 241 |
| 237 def testInfoBarDisappearByNavigatingPage(self): | 242 def testInfoBarDisappearByNavigatingPage(self): |
| 238 """Test password infobar is dismissed when navigating to different page.""" | 243 """Test password infobar is dismissed when navigating to different page.""" |
| 239 creds = self.GetPrivateInfo()['test_google_account'] | 244 creds = self.GetPrivateInfo()['test_google_account'] |
| 240 # Disable one-click login infobar for sync. | 245 # Disable one-click login infobar for sync. |
| 241 self.SetPrefs(pyauto.kReverseAutologinEnabled, False) | 246 self.SetPrefs(pyauto.kReverseAutologinEnabled, False) |
| 242 # Login to Google account. | 247 # Login to Google account. |
| 243 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) | 248 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) |
| 244 self.PerformActionOnInfobar( | 249 self.PerformActionOnInfobar( |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 password = creds['password'] | 351 password = creds['password'] |
| 347 # Block cookies for Google accounts domain. | 352 # Block cookies for Google accounts domain. |
| 348 self.SetPrefs(pyauto.kContentSettingsPatternPairs, | 353 self.SetPrefs(pyauto.kContentSettingsPatternPairs, |
| 349 {'https://accounts.google.com/': {'cookies': 2}}) | 354 {'https://accounts.google.com/': {'cookies': 2}}) |
| 350 test_utils.GoogleAccountsLogin(self, username, password) | 355 test_utils.GoogleAccountsLogin(self, username, password) |
| 351 test_utils.WaitForInfobarTypeAndGetIndex(self, self.INFOBAR_TYPE) | 356 test_utils.WaitForInfobarTypeAndGetIndex(self, self.INFOBAR_TYPE) |
| 352 | 357 |
| 353 | 358 |
| 354 if __name__ == '__main__': | 359 if __name__ == '__main__': |
| 355 pyauto_functional.Main() | 360 pyauto_functional.Main() |
| OLD | NEW |