Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 pyauto_functional # Must be imported before pyauto | 6 import pyauto_functional # Must be imported before pyauto |
| 7 import pyauto | 7 import pyauto |
| 8 | 8 |
| 9 import re | |
| 10 import logging | |
| 9 | 11 |
| 10 class PasswordTest(pyauto.PyUITest): | 12 class PasswordTest(pyauto.PyUITest): |
| 11 """Tests that passwords work correctly""" | 13 """Tests that passwords work correctly""" |
| 12 | 14 |
| 13 def Debug(self): | 15 def Debug(self): |
| 14 """Test method for experimentation. | 16 """Test method for experimentation. |
| 15 | 17 |
| 16 This method will not run automatically. | 18 This method will not run automatically. |
| 17 """ | 19 """ |
| 18 while True: | 20 while True: |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 34 'signon_realm': 'https://www.example.com/', | 36 'signon_realm': 'https://www.example.com/', |
| 35 'time': 1279650942.0, | 37 'time': 1279650942.0, |
| 36 'origin_url': 'https://www.example.com/login', | 38 'origin_url': 'https://www.example.com/login', |
| 37 'username_element': 'username', | 39 'username_element': 'username', |
| 38 'password_element': 'password', | 40 'password_element': 'password', |
| 39 'submit_element': 'submit', | 41 'submit_element': 'submit', |
| 40 'action_target': 'https://www.example.com/login/', | 42 'action_target': 'https://www.example.com/login/', |
| 41 'blacklist': False } | 43 'blacklist': False } |
| 42 self.assertTrue(self.AddSavedPassword(password1)) | 44 self.assertTrue(self.AddSavedPassword(password1)) |
| 43 self.assertEquals(self.GetSavedPasswords(), [password1]) | 45 self.assertEquals(self.GetSavedPasswords(), [password1]) |
| 46 | |
| 47 def testInfoBarDisappearByNavigatingPage(self): | |
| 48 """Test that Password info is dismissed by navigating to different page.""" | |
| 49 self.NavigateToURL('https://www.google.com/accounts/ServiceLogin') | |
| 50 self.ExecuteJavascript('document.getElementById("Email").value = "etouchqa"; window.domAutomationController.send("done")') | |
|
Nirnimesh
2010/11/10 00:02:18
Please do not use these usernames/passwds in tests
| |
| 51 self.ExecuteJavascript('document.getElementById("Passwd").value = "etouch123 "; window.domAutomationController.send("done")') | |
| 52 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit(); window.domAutomationController.send("done")') | |
| 53 self.assertTrue(self.WaitUntil( | |
| 54 lambda: re.search('Inbox', self.GetActiveTabTitle()))) | |
| 55 self.WaitForInfobarCount(1) | |
| 56 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
|
Nirnimesh
2010/11/10 00:02:18
>80 chars not allowed. Fix elsewhere
| |
| 57 self.NavigateToURL("http://www.google.com") | |
| 58 self.assertTrue(self.WaitUntil( | |
| 59 lambda: re.search('Google', self.GetActiveTabTitle()))) | |
| 60 self.WaitForInfobarCount(0) | |
| 61 logging.info('--------------- %s ' % str(self.GetBrowserInfo()['windows'][0] ['tabs'][0]['infobars'])) | |
| 62 self.assertEqual('Google', self.GetActiveTabTitle()) | |
| 63 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 44 | 64 |
| 45 | 65 |
| 66 def testInfoBarDisappearByReload(self): | |
| 67 """Test that Password info bar disappears by the page reload.""" | |
| 68 self.NavigateToURL('http://www.gmail.com') | |
| 69 self.ExecuteJavascript('document.getElementById("Email").value = "etouchqa"; window.domAutomationController.send("done")') | |
| 70 self.ExecuteJavascript('document.getElementById("Passwd").value = "etouch123 "; window.domAutomationController.send("done")') | |
| 71 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit(); window.domAutomationController.send("done")') | |
| 72 self.assertTrue(self.WaitUntil( | |
| 73 lambda: re.search('Inbox', self.GetActiveTabTitle()))) | |
| 74 self.WaitForInfobarCount(1) | |
| 75 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 76 self.GetBrowserWindow(0).GetTab(0).Reload() | |
| 77 self.assertTrue(self.WaitUntil( | |
| 78 lambda: re.search('Google', self.GetActiveTabTitle()))) | |
| 79 self.WaitForInfobarCount(0) | |
| 80 logging.info('--------------- %s ' % str(self.GetBrowserInfo()['windows'][0] ['tabs'][0]['infobars'])) | |
| 81 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 82 | |
| 83 def testRemoveAllPasswords(self): | |
| 84 """Clear All passwords using Clear Browsing Profile.""" | |
| 85 self.testSavePassword() | |
| 86 self.ClearBrowsingData(['PASSWORDS'],'EVERYTHING') | |
| 87 self.assertEquals(0, len(self.GetSavedPasswords())) | |
| 88 | |
| 46 if __name__ == '__main__': | 89 if __name__ == '__main__': |
| 47 pyauto_functional.Main() | 90 pyauto_functional.Main() |
| OLD | NEW |