diff --git a/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js b/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js index dc8097a9e0bf..1a971c83de26 100644 --- a/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js +++ b/browser/extensions/formautofill/test/unit/test_getAdaptedProfiles_locales.js @@ -91,7 +91,109 @@ const FR_TESTCASES = [ }, ]; -const TESTCASES = [FR_TESTCASES]; +const DE_TESTCASES = [ + { + description: "Use placeholder to adjust cc-exp format [mm / jj].", + 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 / JJ].", + 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 / jjjj].", + 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 / JJJJ].", + 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 - jj].", + 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 - JJ].", + 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 - jjjj].", + 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 - JJJJ].", + 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 [jjjj - mm].", + document: ``, + profileData: [Object.assign({}, DEFAULT_CREDITCARD_RECORD)], + expectedResult: [ + Object.assign({}, DEFAULT_CREDITCARD_RECORD, { + "cc-exp": "2025-01", + }), + ], + }, +]; + +const TESTCASES = [FR_TESTCASES, DE_TESTCASES]; for (let localeTests of TESTCASES) { for (let testcase of localeTests) { diff --git a/toolkit/components/formautofill/FormAutofillHandler.jsm b/toolkit/components/formautofill/FormAutofillHandler.jsm index 8599f1ae2772..de69d7d3af81 100644 --- a/toolkit/components/formautofill/FormAutofillHandler.jsm +++ b/toolkit/components/formautofill/FormAutofillHandler.jsm @@ -1087,10 +1087,11 @@ class FormAutofillCreditCardSection extends FormAutofillSection { // 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 + // For example, FR locales may use "A" to represent year. + // For example, DE locales may use "J" 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 yearChars = "yaj"; let monthFirstCheck = new RegExp( "(?:\\b|^)((?:[" +