зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1413110 - [Form Autofill] Skip tombstones when migrating records and computing fields. r=steveck
MozReview-Commit-ID: JEsXVjsCoYc --HG-- extra : rebase_source : 2352948654a8c2ae027a2f56fc87867575b16d39
This commit is contained in:
Родитель
6a561c1f1f
Коммит
ad2cdd6f16
|
@ -1116,6 +1116,10 @@ class AutofillRecords {
|
||||||
_migrateRecord(record) {
|
_migrateRecord(record) {
|
||||||
let hasChanges = false;
|
let hasChanges = false;
|
||||||
|
|
||||||
|
if (record.deleted) {
|
||||||
|
return hasChanges;
|
||||||
|
}
|
||||||
|
|
||||||
if (!record.version || isNaN(record.version) || record.version < 1) {
|
if (!record.version || isNaN(record.version) || record.version < 1) {
|
||||||
this.log.warn("Invalid record version:", record.version);
|
this.log.warn("Invalid record version:", record.version);
|
||||||
|
|
||||||
|
@ -1196,6 +1200,10 @@ class Addresses extends AutofillRecords {
|
||||||
|
|
||||||
let hasNewComputedFields = false;
|
let hasNewComputedFields = false;
|
||||||
|
|
||||||
|
if (address.deleted) {
|
||||||
|
return hasNewComputedFields;
|
||||||
|
}
|
||||||
|
|
||||||
// Compute name
|
// Compute name
|
||||||
if (!("name" in address)) {
|
if (!("name" in address)) {
|
||||||
let name = FormAutofillNameUtils.joinNameParts({
|
let name = FormAutofillNameUtils.joinNameParts({
|
||||||
|
@ -1459,6 +1467,10 @@ class CreditCards extends AutofillRecords {
|
||||||
|
|
||||||
let hasNewComputedFields = false;
|
let hasNewComputedFields = false;
|
||||||
|
|
||||||
|
if (creditCard.deleted) {
|
||||||
|
return hasNewComputedFields;
|
||||||
|
}
|
||||||
|
|
||||||
// Compute split names
|
// Compute split names
|
||||||
if (!("cc-given-name" in creditCard)) {
|
if (!("cc-given-name" in creditCard)) {
|
||||||
let nameParts = FormAutofillNameUtils.splitName(creditCard["cc-name"]);
|
let nameParts = FormAutofillNameUtils.splitName(creditCard["cc-name"]);
|
||||||
|
|
|
@ -101,6 +101,23 @@ const ADDRESS_TESTCASES = [
|
||||||
name: "Timothy",
|
name: "Timothy",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "The migration shouldn't be invoked on tombstones.",
|
||||||
|
record: {
|
||||||
|
guid: "test-guid",
|
||||||
|
timeLastModified: 12345,
|
||||||
|
deleted: true,
|
||||||
|
},
|
||||||
|
expectedResult: {
|
||||||
|
guid: "test-guid",
|
||||||
|
timeLastModified: 12345,
|
||||||
|
deleted: true,
|
||||||
|
|
||||||
|
// Make sure no new fields are appended.
|
||||||
|
version: undefined,
|
||||||
|
name: undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const CREDIT_CARD_TESTCASES = [
|
const CREDIT_CARD_TESTCASES = [
|
||||||
|
@ -194,6 +211,23 @@ const CREDIT_CARD_TESTCASES = [
|
||||||
"cc-given-name": "Timothy",
|
"cc-given-name": "Timothy",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "The migration shouldn't be invoked on tombstones.",
|
||||||
|
record: {
|
||||||
|
guid: "test-guid",
|
||||||
|
timeLastModified: 12345,
|
||||||
|
deleted: true,
|
||||||
|
},
|
||||||
|
expectedResult: {
|
||||||
|
guid: "test-guid",
|
||||||
|
timeLastModified: 12345,
|
||||||
|
deleted: true,
|
||||||
|
|
||||||
|
// Make sure no new fields are appended.
|
||||||
|
version: undefined,
|
||||||
|
"cc-given-name": undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let do_check_record_matches = (expectedRecord, record) => {
|
let do_check_record_matches = (expectedRecord, record) => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче