зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1740446 - Fix credit card expiry placeholder logic when field is using 'j' to represent year. r=sgalich
Differential Revision: https://phabricator.services.mozilla.com/D131167
This commit is contained in:
Родитель
661bf87677
Коммит
1419d85b48
|
@ -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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="mm / jj" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="MM / JJ" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="mm / jjjj" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="MM / JJJJ" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="mm - jj" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="MM - JJ" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="mm - jjjj" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="MM - JJJJ" autocomplete="cc-exp"></form>`,
|
||||||
|
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: `<form><input autocomplete="cc-number">
|
||||||
|
<input placeholder="jjjj - mm" autocomplete="cc-exp"></form>`,
|
||||||
|
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 localeTests of TESTCASES) {
|
||||||
for (let testcase of localeTests) {
|
for (let testcase of localeTests) {
|
||||||
|
|
|
@ -1087,10 +1087,11 @@ class FormAutofillCreditCardSection extends FormAutofillSection {
|
||||||
|
|
||||||
// Bug 1687681: This is a short term fix to other locales having
|
// Bug 1687681: This is a short term fix to other locales having
|
||||||
// different characters to represent year.
|
// 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.
|
// This approach will not scale well and should be investigated in a follow up bug.
|
||||||
let monthChars = "m";
|
let monthChars = "m";
|
||||||
let yearChars = "ya";
|
let yearChars = "yaj";
|
||||||
|
|
||||||
let monthFirstCheck = new RegExp(
|
let monthFirstCheck = new RegExp(
|
||||||
"(?:\\b|^)((?:[" +
|
"(?:\\b|^)((?:[" +
|
||||||
|
|
Загрузка…
Ссылка в новой задаче