зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1371131 - Part 1. Replace the "cc-number-masked" field name in form autofill storage with "cc-number". r=lchang
MozReview-Commit-ID: 1RGL4gu7JrK --HG-- extra : rebase_source : a88e2bef04b47f76ac7e3ebb901fb958d73aa6aa
This commit is contained in:
Родитель
3efa760176
Коммит
3a5dd6f9cc
|
@ -58,8 +58,8 @@
|
|||
*
|
||||
* // credit card fields
|
||||
* cc-name,
|
||||
* cc-number, // e.g. ************1234
|
||||
* cc-number-encrypted,
|
||||
* cc-number-masked, // e.g. ************1234
|
||||
* cc-exp-month,
|
||||
* cc-exp-year, // 2-digit year will be converted to 4 digits
|
||||
* // upon saving
|
||||
|
@ -178,8 +178,8 @@ const VALID_ADDRESS_COMPUTED_FIELDS = [
|
|||
|
||||
const VALID_CREDIT_CARD_FIELDS = [
|
||||
"cc-name",
|
||||
"cc-number",
|
||||
"cc-number-encrypted",
|
||||
"cc-number-masked",
|
||||
"cc-exp-month",
|
||||
"cc-exp-year",
|
||||
];
|
||||
|
@ -1463,7 +1463,6 @@ class CreditCards extends AutofillRecords {
|
|||
_normalizeFields(creditCard) {
|
||||
// Fields that should not be set by content.
|
||||
delete creditCard["cc-number-encrypted"];
|
||||
delete creditCard["cc-number-masked"];
|
||||
|
||||
// Validate and encrypt credit card numbers, and calculate the masked numbers
|
||||
if (creditCard["cc-number"]) {
|
||||
|
@ -1478,9 +1477,9 @@ class CreditCards extends AutofillRecords {
|
|||
// e.g. creditCard["cc-number-encrypted"] = Encrypt(creditCard["cc-number"]);
|
||||
|
||||
if (ccNumber.length > 4) {
|
||||
creditCard["cc-number-masked"] = "*".repeat(ccNumber.length - 4) + ccNumber.substr(-4);
|
||||
creditCard["cc-number"] = "*".repeat(ccNumber.length - 4) + ccNumber.substr(-4);
|
||||
} else {
|
||||
creditCard["cc-number-masked"] = ccNumber;
|
||||
creditCard["cc-number"] = ccNumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,11 @@ let reCCNumber = /^(\*+)(.{4})$/;
|
|||
let do_check_credit_card_matches = (creditCardWithMeta, creditCard) => {
|
||||
for (let key in creditCard) {
|
||||
if (key == "cc-number") {
|
||||
do_check_eq(creditCardWithMeta["cc-number"], undefined);
|
||||
|
||||
// check "cc-number-encrypted" after encryption lands (bug 1337314).
|
||||
|
||||
let matches = reCCNumber.exec(creditCardWithMeta["cc-number-masked"]);
|
||||
let matches = reCCNumber.exec(creditCardWithMeta["cc-number"]);
|
||||
do_check_neq(matches, null);
|
||||
do_check_eq(creditCardWithMeta["cc-number-masked"].length, creditCard["cc-number"].length);
|
||||
do_check_eq(creditCardWithMeta["cc-number"].length, creditCard["cc-number"].length);
|
||||
do_check_eq(creditCard["cc-number"].endsWith(matches[2]), true);
|
||||
} else {
|
||||
do_check_eq(creditCardWithMeta[key], creditCard[key]);
|
||||
|
@ -256,7 +254,7 @@ add_task(async function test_validate() {
|
|||
do_check_eq(creditCards[1]["cc-exp-year"],
|
||||
parseInt(TEST_CREDIT_CARD_WITH_2_DIGITS_YEAR["cc-exp-year"], 10) + 2000);
|
||||
|
||||
do_check_eq(creditCards[2]["cc-number-masked"].length, 16);
|
||||
do_check_eq(creditCards[2]["cc-number"].length, 16);
|
||||
// TODO: Check the decrypted numbers should not contain spaces after
|
||||
// decryption lands (bug 1337314).
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче