diff --git a/browser/extensions/formautofill/test/fixtures/third_party/Ebay/Checkout_Payment_FR.html b/browser/extensions/formautofill/test/fixtures/third_party/Ebay/Checkout_Payment_FR.html deleted file mode 100644 index 83717a6c173af..0000000000000 --- a/browser/extensions/formautofill/test/fixtures/third_party/Ebay/Checkout_Payment_FR.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - Checkout Payment - Ebay - FR - - - -
-
- -
-

Finalisation de l'achat

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Visa, Mastercard ou Discover
-
    -
  • Il s'agit du numéro à 3 chiffres situé au - verso de votre carte, à côté de l'emplacement réservé à la - signature.
  • -
-
American Express
-
    -
  • Il s'agit du numéro à 4 chiffres situé au - recto de votre carte au-dessus de son numéro.
  • -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - -
-
-
-
- - - diff --git a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js b/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js deleted file mode 100644 index ab9c743d4b498..0000000000000 --- a/browser/extensions/formautofill/test/unit/heuristics/third_party/test_Ebay.js +++ /dev/null @@ -1,42 +0,0 @@ -/* global runHeuristicsTest */ - -"use strict"; - -runHeuristicsTest( - [ - { - fixturePath: "Checkout_Payment_FR.html", - expectedResult: [ - [ - [ - { - section: "", - addressType: "", - contactType: "", - fieldName: "cc-number", - }, - { - section: "", - addressType: "", - contactType: "", - fieldName: "cc-exp" - }, - { - section: "", - addressType: "", - contactType: "", - fieldName: "cc-given-name" - }, - { - section: "", - addressType: "", - contactType: "", - fieldName: "cc-family-name" - }, - ], - ], - ], - }, - ], - "../../../fixtures/third_party/Ebay/" -) diff --git a/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles.js b/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles.js index f17e81b74bc43..7db8aa9435ce4 100644 --- a/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles.js +++ b/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles.js @@ -970,13 +970,6 @@ const TESTCASES = [ ], expectedOptionElements: [], }, - { - description: "Fill a cc-exp without placeholder on the cc-exp field", - document: `
-
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - }, { description: "Use placeholder to adjust cc-exp format [mm/yy].", document: `
@@ -1043,6 +1036,17 @@ const TESTCASES = [ }), ], }, + { + description: "Use placeholder to adjust cc-exp format [yyy-mm].", + document: ` +
`, + profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], + expectedResult: [ + Object.assign({}, DEFAULT_CREDITCARD_RECORD, { + "cc-exp": "025-01", + }), + ], + }, { description: "Use placeholder to adjust cc-exp format [mmm yyyy].", document: `
diff --git a/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js b/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js deleted file mode 100644 index dc8097a9e0bf7..0000000000000 --- a/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js +++ /dev/null @@ -1,138 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. -http://creativecommons.org/publicdomain/zero/1.0/ */ - -/* - * Test to ensure locale specific placeholders for credit card fields are properly used - * to transform various values in the profile. - */ - -"use strict"; - -let FormAutofillHandler; -add_task(async function() { - ({ FormAutofillHandler } = ChromeUtils.import( - "resource://autofill/FormAutofillHandler.jsm" - )); -}); - -const DEFAULT_CREDITCARD_RECORD = { - guid: "123", - "cc-exp-month": 1, - "cc-exp-year": 2025, - "cc-exp": "2025-01", -}; - -const FR_TESTCASES = [ - { - description: "Use placeholder to adjust cc-exp format [mm/aa].", - document: ` -
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [ - Object.assign({}, DEFAULT_CREDITCARD_RECORD, { - "cc-exp": "01/25", - }), - ], - }, - { - description: "Use placeholder to adjust cc-exp format [mm / aa].", - document: `
-
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [ - Object.assign({}, DEFAULT_CREDITCARD_RECORD, { - "cc-exp": "01/25", - }), - ], - }, - { - description: "Use placeholder to adjust cc-exp format [MM / AA].", - document: `
-
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [ - Object.assign({}, DEFAULT_CREDITCARD_RECORD, { - "cc-exp": "01/25", - }), - ], - }, - { - description: "Use placeholder to adjust cc-exp format [mm / aaaa].", - document: `
-
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [ - Object.assign({}, DEFAULT_CREDITCARD_RECORD, { - "cc-exp": "01/2025", - }), - ], - }, - { - description: "Use placeholder to adjust cc-exp format [mm - aaaa].", - document: `
-
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [ - Object.assign({}, DEFAULT_CREDITCARD_RECORD, { - "cc-exp": "01-2025", - }), - ], - }, - { - description: "Use placeholder to adjust cc-exp format [aaaa-mm].", - document: `
-
`, - profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], - expectedResult: [ - Object.assign({}, DEFAULT_CREDITCARD_RECORD, { - "cc-exp": "2025-01", - }), - ], - }, -]; - -const TESTCASES = [FR_TESTCASES]; - -for (let localeTests of TESTCASES) { - for (let testcase of localeTests) { - add_task(async function() { - info("Starting testcase: " + testcase.description); - - let doc = MockDocument.createTestDocument( - "http://localhost:8080/test/", - testcase.document - ); - let form = doc.querySelector("form"); - let formLike = FormLikeFactory.createFromForm(form); - let handler = new FormAutofillHandler(formLike); - - handler.collectFormFields(); - handler.focusedInput = form.elements[0]; - let adaptedRecords = handler.activeSection.getAdaptedProfiles( - testcase.profileData - ); - Assert.deepEqual(adaptedRecords, testcase.expectedResult); - - if (testcase.expectedOptionElements) { - testcase.expectedOptionElements.forEach((expectedOptionElement, i) => { - for (let field in expectedOptionElement) { - let select = form.querySelector(`[autocomplete=${field}]`); - let expectedOption = doc.getElementById( - expectedOptionElement[field] - ); - Assert.notEqual(expectedOption, null); - - let value = testcase.profileData[i][field]; - let cache = handler.activeSection._cacheValue.matchingSelectOption.get( - select - ); - let targetOption = cache[value] && cache[value].get(); - Assert.notEqual(targetOption, null); - - Assert.equal(targetOption, expectedOption); - } - }); - } - }); - } -} diff --git a/browser/extensions/formautofill/test/unit/xpcshell.ini b/browser/extensions/formautofill/test/unit/xpcshell.ini index 2c1ff6ed0f63d..9a707a17673f9 100644 --- a/browser/extensions/formautofill/test/unit/xpcshell.ini +++ b/browser/extensions/formautofill/test/unit/xpcshell.ini @@ -4,42 +4,6 @@ head = head.js support-files = ../fixtures/** -[heuristics/test_basic.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/test_cc_exp.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/test_de_fields.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/test_known_strings.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/test_multiple_section.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_BestBuy.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_CDW.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_CostCo.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_Ebay.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_HomeDepot.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_Macys.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_NewEgg.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_OfficeDepot.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_QVC.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_Sears.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_Staples.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_Walmart.js] -skip-if = (os == "linux") && ccov # bug 1614100 -[heuristics/third_party/test_Lush.js] -skip-if = (os == "linux") && ccov # bug 1614100 [test_activeStatus.js] [test_addressDataLoader.js] [test_addressRecords.js] @@ -58,7 +22,6 @@ skip-if = [test_extractLabelStrings.js] [test_findLabelElements.js] [test_getAdaptedProfiles.js] -[test_getAdaptedProfiles_locales.js] [test_getCategoriesFromFieldNames.js] [test_getFormInputDetails.js] [test_getInfo.js] diff --git a/toolkit/components/formautofill/FormAutofillHandler.jsm b/toolkit/components/formautofill/FormAutofillHandler.jsm index 29978b32bc784..2efb7746f2b64 100644 --- a/toolkit/components/formautofill/FormAutofillHandler.jsm +++ b/toolkit/components/formautofill/FormAutofillHandler.jsm @@ -1040,51 +1040,25 @@ class FormAutofillCreditCardSection extends FormAutofillSection { ccExpYear = profile["cc-exp-year"], placeholder = element.placeholder; - // Bug 1687681: This is a short term fix to other locales having - // different characters to represent year. - // For example, FR locales may use "A" instead of "Y" to represent year - // This approach will not scale well and should be investigated in a follow up bug. - let monthChars = "m"; - let yearChars = "ya"; - - let monthFirstCheck = new RegExp( - "(?:\\b|^)((?:[" + - monthChars + - "]{2}){1,2})\\s*([\\-/])\\s*((?:[" + - yearChars + - "]{2}){1,2})(?:\\b|$)", - "i" + result = /(?:[^m]|\b)(m{1,2})\s*([-/\\]*)\s*(y{2,4})(?!y)/i.exec( + placeholder ); - - // If the month first check finds a result, where placeholder is "mm - yyyy", - // the result will be structured as such: ["mm - yyyy", "mm", "-", "yyyy"] - result = monthFirstCheck.exec(placeholder); if (result) { profile["cc-exp"] = - ccExpMonth.toString().padStart(result[1].length, "0") + + String(ccExpMonth).padStart(result[1].length, "0") + result[2] + - ccExpYear.toString().substr(-1 * result[3].length); + String(ccExpYear).substr(-1 * result[3].length); return; } - let yearFirstCheck = new RegExp( - "(?:\\b|^)((?:[" + - yearChars + - "]{2}){1,2})\\s*([\\-/])\\s*((?:[" + // either one or two counts of 'yy' or 'aa' sequence - monthChars + - "]){1,2})(?:\\b|$)", - "i" // either one or two counts of a 'm' sequence + result = /(?:[^y]|\b)(y{2,4})\s*([-/\\]*)\s*(m{1,2})(?!m)/i.exec( + placeholder ); - - // If the year first check finds a result, where placeholder is "yyyy mm", - // the result will be structured as such: ["yyyy mm", "yyyy", " ", "mm"] - result = yearFirstCheck.exec(placeholder); - if (result) { profile["cc-exp"] = - ccExpYear.toString().substr(-1 * result[1].length) + + String(ccExpYear).substr(-1 * result[1].length) + result[2] + - ccExpMonth.toString().padStart(result[3].length, "0"); + String(ccExpMonth).padStart(result[3].length, "0"); } }