Bug 1395019 - [Form Autofill] Part 1: The raw data of credit card fields shouldn't include "cc-exp". r=seanlee
MozReview-Commit-ID: 4OSOgeEgWh9
--- a/browser/extensions/formautofill/ProfileStorage.jsm
+++ b/browser/extensions/formautofill/ProfileStorage.jsm
@@ -64,16 +64,17 @@
* cc-exp-year, // 2-digit year will be converted to 4 digits
* // upon saving
*
* // computed fields (These fields are computed based on the above fields
* // and are not allowed to be modified directly.)
* cc-given-name,
* cc-additional-name,
* cc-family-name,
+ * cc-exp,
*
* // metadata
* timeCreated, // in ms
* timeLastUsed, // in ms
* timeLastModified, // in ms
* timesUsed
* _sync: { ... optional sync metadata },
* }
@@ -185,16 +186,17 @@ const VALID_CREDIT_CARD_FIELDS = [
"cc-exp-month",
"cc-exp-year",
];
const VALID_CREDIT_CARD_COMPUTED_FIELDS = [
"cc-given-name",
"cc-additional-name",
"cc-family-name",
+ "cc-exp",
];
const INTERNAL_FIELDS = [
"guid",
"version",
"timeCreated",
"timeLastUsed",
"timeLastModified",
--- a/browser/extensions/formautofill/test/unit/test_creditCardRecords.js
+++ b/browser/extensions/formautofill/test/unit/test_creditCardRecords.js
@@ -123,21 +123,23 @@ add_task(async function test_getAll() {
do_check_eq(creditCards.length, 2);
do_check_credit_card_matches(creditCards[0], TEST_CREDIT_CARD_1);
do_check_credit_card_matches(creditCards[1], TEST_CREDIT_CARD_2);
// Check computed fields.
do_check_eq(creditCards[0]["cc-given-name"], "John");
do_check_eq(creditCards[0]["cc-family-name"], "Doe");
+ do_check_eq(creditCards[0]["cc-exp"], "2017-04");
// Test with rawData set.
creditCards = profileStorage.creditCards.getAll({rawData: true});
do_check_eq(creditCards[0]["cc-given-name"], undefined);
do_check_eq(creditCards[0]["cc-family-name"], undefined);
+ do_check_eq(creditCards[0]["cc-exp"], undefined);
// Modifying output shouldn't affect the storage.
creditCards[0]["cc-name"] = "test";
do_check_credit_card_matches(profileStorage.creditCards.getAll()[0], TEST_CREDIT_CARD_1);
});
add_task(async function test_get() {
let path = getTempFile(TEST_STORE_FILE_NAME).path;