diff options
author | dyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 18:14:28 +0000 |
---|---|---|
committer | dyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 18:14:28 +0000 |
commit | cc708db7e74a3723389a55efd2de85c2930b8f73 (patch) | |
tree | 16636c337fcbac7c4336be3008bb97d8e9f49060 /chrome/test/functional | |
parent | c7c9809761404ceb4d8357010ac77674f2d22990 (diff) | |
download | chromium_src-cc708db7e74a3723389a55efd2de85c2930b8f73.zip chromium_src-cc708db7e74a3723389a55efd2de85c2930b8f73.tar.gz chromium_src-cc708db7e74a3723389a55efd2de85c2930b8f73.tar.bz2 |
Add an Autofill test to verify that Autofill does not fill in read-only fields.
- testNoAutofillForReadOnlyField
- read_only_field_test.html
Fixed incorrect permissions for html file from 775 to 640.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6792035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r-- | chrome/test/functional/autofill.py | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/chrome/test/functional/autofill.py b/chrome/test/functional/autofill.py index a5bed7d..1867f79 100644 --- a/chrome/test/functional/autofill.py +++ b/chrome/test/functional/autofill.py @@ -12,9 +12,6 @@ import autofill_dataset_generator import pyauto_functional # Must be imported before pyauto import pyauto -TAB_KEYPRESS = 0x09 # Tab keyboard key press. -DOWN_KEYPRESS = 0x28 # Down arrow keyboard key press. -RETURN_KEYPRESS = 0x0D # Return keyboard key press. class AutofillTest(pyauto.PyUITest): """Tests that autofill works correctly""" @@ -151,6 +148,22 @@ class AutofillTest(pyauto.PyUITest): if 'EMAIL_ADDRESS' in self.GetAutofillProfile()['profiles'][0]: raise KeyError('TEST FAIL: Malformed email address is saved in profiles.') + def _SendKeyEventsToPopulateForm(self, tab_index=0, windex=0): + """Send key events to populate a web form with Autofill profile data. + + Args: + tab_index: The tab index, default is 0. + windex: The window index, default is 0. + """ + TAB_KEYPRESS = 0x09 # Tab keyboard key press. + DOWN_KEYPRESS = 0x28 # Down arrow keyboard key press. + RETURN_KEYPRESS = 0x0D # Return keyboard key press. + + self.SendWebkitKeyEvent(TAB_KEYPRESS, tab_index, windex) + self.SendWebkitKeyEvent(DOWN_KEYPRESS, tab_index, windex) + self.SendWebkitKeyEvent(DOWN_KEYPRESS, tab_index, windex) + self.SendWebkitKeyEvent(RETURN_KEYPRESS, tab_index, windex) + def testComparePhoneNumbers(self): """Test phone fields parse correctly from a given profile. @@ -169,14 +182,7 @@ class AutofillTest(pyauto.PyUITest): os.path.join('autofill', 'form_phones.html')) for profile_expected in profiles_expected: self.NavigateToURL(url) - # Tab keyboard key press. - self.SendWebkitKeyEvent(TAB_KEYPRESS, tab_index=0, windex=0) - # Down arrow keyboard key press. - self.SendWebkitKeyEvent(DOWN_KEYPRESS, tab_index=0, windex=0) - # Down arrow keyboard key press. - self.SendWebkitKeyEvent(DOWN_KEYPRESS, tab_index=0, windex=0) - # Return keyboard key press. - self.SendWebkitKeyEvent(RETURN_KEYPRESS, tab_index=0, windex=0) + self._SendKeyEventsToPopulateForm() form_values = {} for key, value in profile_expected.iteritems(): js_returning_field_value = ( @@ -223,6 +229,40 @@ class AutofillTest(pyauto.PyUITest): self.assertEqual(0, len(cc_infobar), 'Save credit card infobar offered to save CC info.') + def testNoAutofillForReadOnlyFields(self): + """Test that Autofill does not fill in read-only fields.""" + profile = {'NAME_FIRST': 'Bob', + 'NAME_LAST': 'Smith', + 'EMAIL_ADDRESS': 'bsmith@gmail.com', + 'ADDRESS_HOME_LINE1': '1234 H St.', + 'ADDRESS_HOME_CITY': 'San Jose', + 'ADDRESS_HOME_STATE': 'CA', + 'ADDRESS_HOME_ZIP': '95110', + 'COMPANY_NAME': 'Company X', + 'PHONE_HOME_WHOLE_NUMBER': '408-123-4567',} + + self.FillAutofillProfile(profiles=[profile]) + url = self.GetHttpURLForDataPath( + os.path.join('autofill', 'read_only_field_test.html')) + self.NavigateToURL(url) + self._SendKeyEventsToPopulateForm() + js_return_readonly_field = ( + 'var field_value = document.getElementById("email").value;' + 'window.domAutomationController.send(field_value);') + readonly_field_value = self.ExecuteJavascript( + js_return_readonly_field, 0, 0) + js_return_addrline1_field = ( + 'var field_value = document.getElementById("address").value;' + 'window.domAutomationController.send(field_value);') + addrline1_field_value = self.ExecuteJavascript( + js_return_addrline1_field, 0, 0) + self.assertNotEqual( + readonly_field_value, profile['EMAIL_ADDRESS'], + 'Autofill filled in value for a read-only field.') + self.assertEqual( + addrline1_field_value, profile['ADDRESS_HOME_LINE1'], + 'Unexpected value in the Address field.') + def FormFillLatencyAfterSubmit(self): """Test latency time on form submit with lots of stored Autofill profiles. |