Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Unified Diff: chrome/test/functional/autofill.py

Issue 6792035: Add an Autofill test to verify that Autofill does not fill in read-only fields. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/autofill/read_only_field_test.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/autofill.py
===================================================================
--- chrome/test/functional/autofill.py (revision 80394)
+++ chrome/test/functional/autofill.py (working copy)
@@ -12,9 +12,6 @@
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 @@
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 @@
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 @@
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.
« no previous file with comments | « chrome/test/data/autofill/read_only_field_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698