summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-04 23:10:27 +0000
committerdyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-04 23:10:27 +0000
commit22796b1a1791a0d1e84bf2d0eeba82d08d0687c1 (patch)
tree0fecb974f308197635feb9abc328454192395432
parent5eefb6c856f22a50634ecde5573f3d5cccf2e446 (diff)
downloadchromium_src-22796b1a1791a0d1e84bf2d0eeba82d08d0687c1.zip
chromium_src-22796b1a1791a0d1e84bf2d0eeba82d08d0687c1.tar.gz
chromium_src-22796b1a1791a0d1e84bf2d0eeba82d08d0687c1.tar.bz2
Revert 80379 - Add an Autofill test to verify that Autofill does not fill in read-only fields.
- testNoAutofillForReadOnlyField - read_only_field_test.html BUG=none TEST=none Review URL: http://codereview.chromium.org/6737017 TBR=dyu@chromium.org Review URL: http://codereview.chromium.org/6720039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80389 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/test/data/autofill/read_only_field_test.html32
-rw-r--r--chrome/test/functional/autofill.py63
2 files changed, 12 insertions, 83 deletions
diff --git a/chrome/test/data/autofill/read_only_field_test.html b/chrome/test/data/autofill/read_only_field_test.html
deleted file mode 100755
index 15dc35c..0000000
--- a/chrome/test/data/autofill/read_only_field_test.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<!-- HTML form used by autofill.AutofillTest.testNoAutofillForReadOnlyFields to
-test that Autofill does not fill in read-only fields. -->
-<html>
- <head>
- <title>AutoFill Form</title>
- <style>
- [readonly] { border-color: red; }
- </style>
- </head>
- <body>
- <form name="autofill_profile" action="" method="post">
- <p>
- <!-- Profile -->
- <label for="firstname">First Name:</label> <input type="text" id="firstname" name="firstname"><br/>
- <label for="middlename">Middle Name:</label> <input type="text" id="middlename" name="middlename"><br/>
- <label for="lastname">Last Name:</label> <input type="text" id="lastname" name="lastname"><br/>
- <label for="email">Email:</label> <input type="text" id="email" name="email" readonly><br/>
- <label for="company">Company:</label> <input type="text" id="company" name="company"><br/>
- <label for="address">Address:</label> <input type="text" id="address" name="address"><br/>
- <label for="address2">Address 2:</label> <input type="text" id="address2" name="address2"><br/>
- <label for="city">City:</label> <input type="text" id="city" name="city"><br/>
- <label for="state">State:</label> <input type="text" id="state" name="state"><br/>
- <label for="zipcode">Zip:</label> <input type="text" id="zipcode" name="zipcode"><br/>
- <label for="country">Country:</label> <input type="text" id="country" name="country"><br/>
- <label for="phone">Phone:</label> <input type="text" id="phone" name="phone"><br/>
- <label for="fax">Fax:</label> <input type="text" id="fax" name="fax"><br/>
- <input type="submit" value="Send"> <input type="reset">
- </p>
- </form>
- </body>
-</html>
diff --git a/chrome/test/functional/autofill.py b/chrome/test/functional/autofill.py
index 45e362b..a5bed7d 100644
--- a/chrome/test/functional/autofill.py
+++ b/chrome/test/functional/autofill.py
@@ -12,6 +12,9 @@ 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"""
@@ -56,6 +59,7 @@ class AutofillTest(pyauto.PyUITest):
file_path = os.path.join(self.DataDir(), 'autofill', 'crazy_autofill.txt')
profiles = self.EvalDataFrom(file_path)
self.FillAutofillProfile(profiles=profiles)
+
self.assertEqual(profiles, self.GetAutofillProfile()['profiles'])
# Adding credit cards.
@@ -147,22 +151,6 @@ 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.
@@ -181,7 +169,14 @@ class AutofillTest(pyauto.PyUITest):
os.path.join('autofill', 'form_phones.html'))
for profile_expected in profiles_expected:
self.NavigateToURL(url)
- self._SendKeyEventsToPopulateForm()
+ # 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)
form_values = {}
for key, value in profile_expected.iteritems():
js_returning_field_value = (
@@ -228,40 +223,6 @@ 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.