Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 self.WaitUntil( | 95 self.WaitUntil( |
| 96 lambda: self.GetDOMValue('document.readyState'), | 96 lambda: self.GetDOMValue('document.readyState'), |
| 97 expect_retval='complete') | 97 expect_retval='complete') |
| 98 self.assertTrue(self.WaitForInfobarCount(1), | 98 self.assertTrue(self.WaitForInfobarCount(1), |
| 99 'Save password infobar did not appear.') | 99 'Save password infobar did not appear.') |
| 100 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] | 100 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] |
| 101 self.assertEqual(infobar[0]['type'], 'confirm_infobar') | 101 self.assertEqual(infobar[0]['type'], 'confirm_infobar') |
| 102 self.PerformActionOnInfobar('accept', infobar_index=0) | 102 self.PerformActionOnInfobar('accept', infobar_index=0) |
| 103 self.NavigateToURL(url_logout) | 103 self.NavigateToURL(url_logout) |
| 104 self.AppendTab(pyauto.GURL(url_https)) # New tab to avoid bug 70694 | 104 self.AppendTab(pyauto.GURL(url_https)) # New tab to avoid bug 70694 |
| 105 # Wait until accounts page load to detect value in username field. | 105 # Wait until username is filled by the Password manager on the login page. |
| 106 self.WaitUntil(lambda: self.GetDOMValue('document.readyState', 0, 1), | 106 self.WaitUntil( |
|
Nirnimesh
2011/08/28 07:15:16
wrap inside assertTrue
Venkat Yellapu
2011/08/30 00:03:03
Done.
| |
| 107 expect_retval='complete') | 107 lambda: self.GetDOMValue('document.getElementById("Email").value', |
| 108 0, 0) != "") | |
| 108 test_utils.VerifyGoogleAccountCredsFilled(self, username, password, | 109 test_utils.VerifyGoogleAccountCredsFilled(self, username, password, |
| 109 tab_index=1, windex=0) | 110 tab_index=1, windex=0) |
| 110 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit();' | 111 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit();' |
| 111 'window.domAutomationController.send("done")', | 112 'window.domAutomationController.send("done")', |
| 112 0, 1) | 113 0, 1) |
| 113 test_utils.ClearPasswords(self) | 114 test_utils.ClearPasswords(self) |
| 114 | 115 |
| 115 def testNeverSavePasswords(self): | 116 def testNeverSavePasswords(self): |
| 116 """Verify passwords not saved/deleted when 'never for this site' chosen.""" | 117 """Verify passwords not saved/deleted when 'never for this site' chosen.""" |
| 117 creds1 = self.GetPrivateInfo()['test_google_account'] | 118 creds1 = self.GetPrivateInfo()['test_google_account'] |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 self.NavigateToURL('chrome://history') | 174 self.NavigateToURL('chrome://history') |
| 174 self.assertTrue(self.WaitForInfobarCount(0)) | 175 self.assertTrue(self.WaitForInfobarCount(0)) |
| 175 # To make sure user is navigated to History page. | 176 # To make sure user is navigated to History page. |
| 176 self.assertEqual('History', self.GetActiveTabTitle()) | 177 self.assertEqual('History', self.GetActiveTabTitle()) |
| 177 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | 178 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| 178 | 179 |
| 179 def testInfoBarDisappearByReload(self): | 180 def testInfoBarDisappearByReload(self): |
| 180 """Test that Password infobar disappears by the page reload.""" | 181 """Test that Password infobar disappears by the page reload.""" |
| 181 creds = self.GetPrivateInfo()['test_google_account'] | 182 creds = self.GetPrivateInfo()['test_google_account'] |
| 182 # Login to Google a/c | 183 # Login to Google a/c |
| 184 raw_input() | |
|
Nirnimesh
2011/08/28 07:15:16
??
Venkat Yellapu
2011/08/30 00:03:03
Done.
| |
| 183 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) | 185 test_utils.GoogleAccountsLogin(self, creds['username'], creds['password']) |
| 186 raw_input() | |
|
Nirnimesh
2011/08/28 07:15:16
??
Venkat Yellapu
2011/08/30 00:03:03
Done.
| |
| 184 # Wait for the infobar to appear | 187 # Wait for the infobar to appear |
| 185 self.assertTrue(self.WaitForInfobarCount(1)) | 188 self.assertTrue(self.WaitForInfobarCount(1)) |
| 186 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | 189 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| 187 self.GetBrowserWindow(0).GetTab(0).Reload() | 190 self.GetBrowserWindow(0).GetTab(0).Reload() |
| 191 raw_input() | |
|
Nirnimesh
2011/08/28 07:15:16
??
Please run the tests before submitting for rev
Venkat Yellapu
2011/08/30 00:03:03
Done.
| |
| 188 self.assertTrue(self.WaitForInfobarCount(0)) | 192 self.assertTrue(self.WaitForInfobarCount(0)) |
| 189 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | 193 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| 190 | 194 |
| 191 def testPasswdInfoNotStoredWhenAutocompleteOff(self): | 195 def testPasswdInfoNotStoredWhenAutocompleteOff(self): |
| 192 """Verify that password infobar does not appear when autocomplete is off. | 196 """Verify that password infobar does not appear when autocomplete is off. |
| 193 | 197 |
| 194 If the password field has autocomplete turned off, then the password infobar | 198 If the password field has autocomplete turned off, then the password infobar |
| 195 should not offer to save the password info. | 199 should not offer to save the password info. |
| 196 """ | 200 """ |
| 197 password_info = {'Email': 'test@google.com', | 201 password_info = {'Email': 'test@google.com', |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 243 into the Email field. | 247 into the Email field. |
| 244 """ | 248 """ |
| 245 user_creds = self._ConstructPasswordDictionary( | 249 user_creds = self._ConstructPasswordDictionary( |
| 246 'user1@example.com', 'test1.password', | 250 'user1@example.com', 'test1.password', |
| 247 'https://www.google.com/', | 251 'https://www.google.com/', |
| 248 'https://www.google.com/accounts/ServiceLogin', | 252 'https://www.google.com/accounts/ServiceLogin', |
| 249 'username', 'password', | 253 'username', 'password', |
| 250 'https://www.google.com/accounts/ServiceLogin') | 254 'https://www.google.com/accounts/ServiceLogin') |
| 251 | 255 |
| 252 url = 'https://www.google.com/accounts/ServiceLogin' | 256 url = 'https://www.google.com/accounts/ServiceLogin' |
| 253 self.AddSavedPassword(user_creds) | 257 user_creds = self.GetPrivateInfo()['test_google_account'] |
| 254 self.NavigateToURL(url) | 258 test_utils.GoogleAccountsLogin(self, user_creds['username'], user_creds['pas sword']) |
|
Nirnimesh
2011/08/28 07:15:16
80+ chars not allowed
Venkat Yellapu
2011/08/30 00:03:03
I'm not going to change this function in this CL.
| |
| 259 | |
| 260 #self.AddSavedPassword(user_creds) | |
| 261 raw_input() | |
|
Nirnimesh
2011/08/28 07:15:16
??
Venkat Yellapu
2011/08/30 00:03:03
Done.
| |
| 262 #self.NavigateToURL(url) | |
| 263 #raw_input() | |
| 255 self.WaitUntil( | 264 self.WaitUntil( |
| 256 lambda: self.GetDOMValue('document.readyState'), | 265 lambda: self.GetDOMValue('document.readyState'), |
| 257 expect_retval='complete') | 266 expect_retval='complete') |
| 258 test_utils.VerifyGoogleAccountCredsFilled( | 267 test_utils.VerifyGoogleAccountCredsFilled( |
| 259 self, user_creds['username_value'], user_creds['password_value'], | 268 self, user_creds['username_value'], user_creds['password_value'], |
| 260 tab_index=0, windex=0) | 269 tab_index=0, windex=0) |
| 261 clear_username_field = ( | 270 clear_username_field = ( |
| 262 'document.getElementById("Email").value = ""; ' | 271 'document.getElementById("Email").value = ""; ' |
| 263 'window.domAutomationController.send("done");') | 272 'window.domAutomationController.send("done");') |
| 264 set_focus = ( | 273 set_focus = ( |
| 265 'document.getElementById("Email").focus(); ' | 274 'document.getElementById("Email").focus(); ' |
| 266 'window.domAutomationController.send("done");') | 275 'window.domAutomationController.send("done");') |
| 267 self.ExecuteJavascript(clear_username_field, 0, 0) | 276 self.ExecuteJavascript(clear_username_field, 0, 0) |
| 268 self.ExecuteJavascript(set_focus, 0, 0) | 277 self.ExecuteJavascript(set_focus, 0, 0) |
| 269 self._SendCharToPopulateField('t', tab_index=0, windex=0) | 278 self._SendCharToPopulateField('t', tab_index=0, windex=0) |
| 270 passwd_value = self.GetDOMValue('document.getElementById("Passwd").value') | 279 passwd_value = self.GetDOMValue('document.getElementById("Passwd").value') |
| 271 self.assertFalse(passwd_value, | 280 self.assertFalse(passwd_value, |
| 272 msg='Password field not empty for new username.') | 281 msg='Password field not empty for new username.') |
| 273 test_utils.ClearPasswords(self) | 282 test_utils.ClearPasswords(self) |
| 274 | 283 |
| 275 | 284 |
| 276 if __name__ == '__main__': | 285 if __name__ == '__main__': |
| 277 pyauto_functional.Main() | 286 pyauto_functional.Main() |
| OLD | NEW |