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

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

Issue 6850007: Fixed a few Autofill automation failures and added new tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 8 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/functional/PYAUTO_TESTS ('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 81512)
+++ chrome/test/functional/autofill.py (working copy)
@@ -90,8 +90,123 @@
self.assertEqual([without_invalid],
self.GetAutofillProfile()['profiles'])
- def testFilterIncompleteAddresses(self):
- """Test Autofill filters out profile with incomplete address info."""
+ def testAutofillPrefsStringSavedAsIs(self):
+ """Test invalid credit card numbers typed in prefs should be saved as-is."""
+ credit_card = {'CREDIT_CARD_NUMBER': 'Not_0123-5Checked'}
+ expected_credit_card = {'CREDIT_CARD_NUMBER': 'Not_0123-5Checked'}
dennis_jeffrey 2011/04/14 21:53:03 Since "credit_card" is identical to "expected_cred
dyu1 2011/04/15 00:06:09 Done.
+ self.FillAutofillProfile(credit_cards=[credit_card])
+ self.assertEqual([expected_credit_card],
+ self.GetAutofillProfile()['credit_cards'],
+ msg='Credit card number in prefs not saved as-is.')
dennis_jeffrey 2011/04/14 21:53:03 Indent by 1 fewer space.
dyu1 2011/04/15 00:06:09 Done.
+
+ def testInvalidCreditCardNumberIsNotAggregated(self):
+ """Test credit card info with an invalid cc number is not aggregated.
dennis_jeffrey 2011/04/14 21:53:03 Remove "cc"; I think it's already implied within t
dyu1 2011/04/15 00:06:09 Done.
+
+ When filling out a form with an invalid CC number, one that does not pass
dennis_jeffrey 2011/04/14 21:53:03 "cc" --> "credit card" (for clarity).
dyu1 2011/04/15 00:06:09 Done.
+ the Luhn test, the credit card info is not saved into Autofill preferences.
dennis_jeffrey 2011/04/14 21:53:03 Instead of using commas around "one that does not
dennis_jeffrey 2011/04/14 21:53:03 "is not saved" --> "should not be saved"
dyu1 2011/04/15 00:06:09 Done.
dyu1 2011/04/15 00:06:09 Done.
+ """
+ invalid_cc_info = {'CREDIT_CARD_NAME': 'Bob Smith',
+ 'CREDIT_CARD_NUMBER': '4408 0412 3456 7890',
dennis_jeffrey 2011/04/14 21:53:03 Would it be easy to add a brief comment to explain
dyu1 2011/04/15 00:06:09 I added a helper function instead to do the checki
+ 'CREDIT_CARD_EXP_MONTH': '12',
+ 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2014'}
+ url = self.GetHttpURLForDataPath(
+ os.path.join('autofill', 'autofill_creditcard_form.html'))
+ self.NavigateToURL(url)
+ for key, value in invalid_cc_info.iteritems():
+ script = ('document.getElementById("%s").value = "%s"; '
+ 'window.domAutomationController.send("done");') % (key, value)
+ self.ExecuteJavascript(script, 0, 0)
+ js_code = """
+ document.getElementById("cc_submit").submit();
+ window.addEventListener("unload", function() {
+ window.domAutomationController.send("done");
+ });
+ """
+ self.ExecuteJavascript(js_code, 0, 0)
+ # Wait until form is submitted and page completes loading.
dennis_jeffrey 2011/04/14 21:53:03 "form" --> "the form" "page" --> "the page"
dyu1 2011/04/15 00:06:09 Done.
+ self.WaitUntil(
+ lambda: self.GetDOMValue('document.readyState'),
+ expect_retval='complete')
+ cc_infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']
+ self.assertFalse(cc_infobar,
+ msg='Save credit card infobar offered to save CC info.')
+
+ def testWhiteSpacesStrippedForValidCCNums(self):
+ """Test whitespaces are stripped for valid CC numbers.
dennis_jeffrey 2011/04/14 21:53:03 "CC" --> "credit card"
dyu1 2011/04/15 00:06:09 Done.
+
+ Credit Card Number entered must pass the Luhn test. For reference:
dennis_jeffrey 2011/04/14 21:53:03 "The credit card number used in this test passes t
dyu1 2011/04/15 00:06:09 Done.
+ http://www.merriampark.com/anatomycc.htm
+ """
+ credit_card_info = {'CREDIT_CARD_NAME': 'Bob Smith',
+ 'CREDIT_CARD_NUMBER': '4408 0412 3456 7893',
+ 'CREDIT_CARD_EXP_MONTH': '12',
+ 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2014'}
+
+ url = self.GetHttpURLForDataPath(
+ os.path.join('autofill', 'autofill_creditcard_form.html'))
+ self.NavigateToURL(url)
+ for key, value in credit_card_info.iteritems() :
dennis_jeffrey 2011/04/14 21:53:03 Remove the space before the ':'
dyu1 2011/04/15 00:06:09 Done.
+ script = ('document.getElementById("%s").value = "%s"; '
+ 'window.domAutomationController.send("done");') % (key, value)
+ self.ExecuteJavascript(script, 0, 0)
+ js_code = """
+ document.getElementById("cc_submit").submit();
+ window.addEventListener("unload", function() {
+ window.domAutomationController.send("done");
+ });
+ """
+ self.ExecuteJavascript(js_code, 0, 0)
+ # Wait until form is submitted and page completes loading.
dennis_jeffrey 2011/04/14 21:53:03 "form" --> "the form" "page" --> "the page"
dyu1 2011/04/15 00:06:09 Done.
+ self.WaitUntil(
+ lambda: self.GetDOMValue('document.readyState'),
+ expect_retval='complete')
+ cc_infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']
+ self.PerformActionOnInfobar('accept', infobar_index=0)
+ cc_expected = credit_card_info['CREDIT_CARD_NUMBER'].replace(' ', '')
+ self.assertEqual(
+ cc_expected,
+ self.GetAutofillProfile()['credit_cards'][0]['CREDIT_CARD_NUMBER'],
+ msg='White spaces not stripped from a valid cc number.')
dennis_jeffrey 2011/04/14 21:53:03 "White spaces" --> "Whitespaces"
dyu1 2011/04/15 00:06:09 Done.
+
+ def testCharSeparatorsStrippedForValidCCNums(self):
+ """Test char seperators are stripped for valid CC numbers.
dennis_jeffrey 2011/04/14 21:53:03 "seperators" --> "separators"
dennis_jeffrey 2011/04/14 21:53:03 "CC" --> "credit card"
dyu1 2011/04/15 00:06:09 Done.
dyu1 2011/04/15 00:06:09 Done.
+
+ Credit Card Number entered must pass the Luhn test. For reference:
dennis_jeffrey 2011/04/14 21:53:03 Same comment as line 137 above.
dyu1 2011/04/15 00:06:09 Done.
+ http://www.merriampark.com/anatomycc.htm
+ """
+ credit_card_info = {'CREDIT_CARD_NAME': 'Jane Doe',
+ 'CREDIT_CARD_NUMBER': '4417-1234-5678-9112',
+ 'CREDIT_CARD_EXP_MONTH': '10',
+ 'CREDIT_CARD_EXP_4_DIGIT_YEAR': '2013'}
+
+ url = self.GetHttpURLForDataPath(
+ os.path.join('autofill', 'autofill_creditcard_form.html'))
+ self.NavigateToURL(url)
+ for key, value in credit_card_info.iteritems() :
dennis_jeffrey 2011/04/14 21:53:03 Remove space before ':'
dyu1 2011/04/15 00:06:09 Done.
+ script = ('document.getElementById("%s").value = "%s"; '
+ 'window.domAutomationController.send("done");') % (key, value)
+ self.ExecuteJavascript(script, 0, 0)
+ js_code = """
+ document.getElementById("cc_submit").submit();
+ window.addEventListener("unload", function() {
+ window.domAutomationController.send("done");
+ });
+ """
+ self.ExecuteJavascript(js_code, 0, 0)
+ # Wait until form is submitted and page completes loading.
dennis_jeffrey 2011/04/14 21:53:03 "form" --> "the form" "page" --> "the page"
dyu1 2011/04/15 00:06:09 Done.
+ self.WaitUntil(
+ lambda: self.GetDOMValue('document.readyState'),
+ expect_retval='complete')
+ cc_infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']
+ self.PerformActionOnInfobar('accept', infobar_index=0)
+ cc_expected = credit_card_info['CREDIT_CARD_NUMBER'].replace('-', '')
+ self.assertEqual(
+ cc_expected,
+ self.GetAutofillProfile()['credit_cards'][0]['CREDIT_CARD_NUMBER'],
+ msg='Character separators not stripped from a valid cc number.')
+
+ def testProfilesNotAggregatedWithNoAddress(self):
+ """Test Autofill does not aggregate profiles with no address info."""
profile = {'NAME_FIRST': 'Bob',
'NAME_LAST': 'Smith',
'EMAIL_ADDRESS': 'bsmith@example.com',
@@ -113,8 +228,8 @@
self.ExecuteJavascript(js_code, 0, 0)
self.assertEqual([], self.GetAutofillProfile()['profiles'])
dennis_jeffrey 2011/04/14 21:53:03 Add a msg='...' in case this assertion fails.
dyu1 2011/04/15 00:06:09 Done.
- def testFilterMalformedEmailAddresses(self):
- """Test Autofill filters out malformed email address during form submit."""
+ def testProfilesNotAggregatedWithInvalidEmail(self):
+ """Test Autofill does not aggregate profiles with an invalid Email."""
dennis_jeffrey 2011/04/14 21:53:03 "Email" --> "email"
dyu1 2011/04/15 00:06:09 Done.
profile = {'NAME_FIRST': 'Bob',
'NAME_LAST': 'Smith',
'EMAIL_ADDRESS': 'garbage',
@@ -138,8 +253,7 @@
});
"""
self.ExecuteJavascript(js_code, 0, 0)
- if 'EMAIL_ADDRESS' in self.GetAutofillProfile()['profiles'][0]:
- raise KeyError('TEST FAIL: Malformed email address is saved in profiles.')
+ self.assertEqual([], self.GetAutofillProfile()['profiles'])
dennis_jeffrey 2011/04/14 21:53:03 Add a msg='...' in case this assertion fails.
dyu1 2011/04/15 00:06:09 Done.
def _SendKeyEventsToPopulateForm(self, tab_index=0, windex=0):
"""Send key events to populate a web form with Autofill profile data.
@@ -186,7 +300,7 @@
js_returning_field_value, 0, 0)
self.assertEqual(
form_values[key], value,
- ('Original profile not equal to expected profile at key: "%s"\n'
+ msg=('Original profile not equal to expected profile at key: "%s"\n'
'Expected: "%s"\nReturned: "%s"' % (key, value, form_values[key])))
dennis_jeffrey 2011/04/14 21:53:03 Indent this line 4 more spaces.
dyu1 2011/04/15 00:06:09 Done.
def testCCInfoNotStoredWhenAutocompleteOff(self):
@@ -220,8 +334,8 @@
lambda: self.GetDOMValue('document.readyState'),
expect_retval='complete')
cc_infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']
- self.assertEqual(0, len(cc_infobar),
- 'Save credit card infobar offered to save CC info.')
+ self.assertFalse(cc_infobar,
+ msg='Save credit card infobar offered to save CC info.')
def testNoAutofillForReadOnlyFields(self):
"""Test that Autofill does not fill in read-only fields."""
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698