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 |
| 7 import pyauto | 7 import pyauto |
| 8 | 8 |
|
Nirnimesh
2010/11/24 10:05:29
leave another blank line
| |
| 9 | |
| 10 class PasswordTest(pyauto.PyUITest): | 9 class PasswordTest(pyauto.PyUITest): |
| 11 """Tests that passwords work correctly""" | 10 """Tests that passwords work correctly""" |
| 12 | 11 |
| 13 def Debug(self): | 12 def Debug(self): |
| 14 """Test method for experimentation. | 13 """Test method for experimentation. |
| 15 | 14 |
| 16 This method will not run automatically. | 15 This method will not run automatically. |
| 17 """ | 16 """ |
| 18 while True: | 17 while True: |
| 19 raw_input('Interact with the browser and hit <enter> to dump passwords. ') | 18 raw_input('Interact with the browser and hit <enter> to dump passwords. ') |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 35 'time': 1279650942.0, | 34 'time': 1279650942.0, |
| 36 'origin_url': 'https://www.example.com/login', | 35 'origin_url': 'https://www.example.com/login', |
| 37 'username_element': 'username', | 36 'username_element': 'username', |
| 38 'password_element': 'password', | 37 'password_element': 'password', |
| 39 'submit_element': 'submit', | 38 'submit_element': 'submit', |
| 40 'action_target': 'https://www.example.com/login/', | 39 'action_target': 'https://www.example.com/login/', |
| 41 'blacklist': False } | 40 'blacklist': False } |
| 42 self.assertTrue(self.AddSavedPassword(password1)) | 41 self.assertTrue(self.AddSavedPassword(password1)) |
| 43 self.assertEquals(self.GetSavedPasswords(), [password1]) | 42 self.assertEquals(self.GetSavedPasswords(), [password1]) |
| 44 | 43 |
| 44 def _Login(self, url, username, password): | |
|
Nirnimesh
2010/11/24 10:05:29
use a similar function from test_utils
| |
| 45 """Method to login into a website. | |
| 46 Takes url, username and password as input. """ | |
| 47 | |
| 48 self.NavigateToURL(url) | |
| 49 email_id = 'document.getElementById("Email").value = \"%s\"; ' % username | |
| 50 email_id = email_id + 'window.domAutomationController.send("done")' | |
| 51 password = 'document.getElementById("Passwd").value = \"%s\"; ' % password | |
| 52 password = password + 'window.domAutomationController.send("done")' | |
| 53 self.ExecuteJavascript(email_id); | |
| 54 self.ExecuteJavascript(password); | |
| 55 self.ExecuteJavascript('document.getElementById("gaia_loginform").submit(); ' | |
|
Nirnimesh
2010/11/24 10:05:29
80+ chars
| |
| 56 'window.domAutomationController.send("done")') | |
| 57 | |
| 58 def testInfoBarDisappearByNavigatingPage(self): | |
| 59 """Test that Password info is dismissed by navigating to different page.""" | |
|
Nirnimesh
2010/11/24 10:05:29
s/info/infobar/
| |
| 60 | |
| 61 url = 'https://www.google.com/accounts/Login?hl=en&continue=https://www.goog le.com/' | |
|
Nirnimesh
2010/11/24 10:05:29
80+ chars
| |
| 62 creds = self.GetPrivateInfo()['test_google_account'] | |
| 63 username = creds['username'] | |
| 64 password = creds['password'] | |
| 65 | |
| 66 #Login to Google a/c | |
|
Nirnimesh
2010/11/24 10:05:29
leave a space after #
Repeat everywhere
| |
| 67 self._Login(url, username, password) | |
| 68 | |
| 69 #Wait for the info bar to appear | |
| 70 self.WaitForInfobarCount(1) | |
|
Nirnimesh
2010/11/24 10:05:29
wrap this inside self.assertTrue()
| |
| 71 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 72 self.NavigateToURL('chrome://history') | |
| 73 self.WaitForInfobarCount(0) | |
|
Nirnimesh
2010/11/24 10:05:29
wrap this inside self.assertTrue()
| |
| 74 self.assertEqual('History', self.GetActiveTabTitle()) | |
|
Nirnimesh
2010/11/24 10:05:29
why?
| |
| 75 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 76 | |
|
Nirnimesh
2010/11/24 10:05:29
remove extra blank line
| |
| 77 | |
| 78 def testInfoBarDisappearByReload(self): | |
| 79 """Test that Password info bar disappears by the page reload.""" | |
|
Nirnimesh
2010/11/24 10:05:29
s/info bar/infobar/
| |
| 80 | |
| 81 url = 'https://www.google.com/accounts/Login?hl=en&continue=https://www.goog le.com/' | |
|
Nirnimesh
2010/11/24 10:05:29
80+ chars
| |
| 82 creds = self.GetPrivateInfo()['test_google_account'] | |
| 83 username = creds['username'] | |
| 84 password = creds['password'] | |
| 85 | |
| 86 #Login to Google a/c | |
| 87 self._Login(url, username, password) | |
| 88 | |
| 89 #Wait for the info bar to appear | |
| 90 self.WaitForInfobarCount(1) | |
| 91 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 92 self.GetBrowserWindow(0).GetTab(0).Reload() | |
| 93 self.WaitForInfobarCount(0) | |
| 94 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | |
| 95 | |
| 45 | 96 |
| 46 if __name__ == '__main__': | 97 if __name__ == '__main__': |
| 47 pyauto_functional.Main() | 98 pyauto_functional.Main() |
| OLD | NEW |