Bug 1771581 - Don't accept duplicate property entries in VCardProperties. r=#thunderbird-reviewers,aleca
Differential Revision: https://phabricator.services.mozilla.com/D147567 --HG-- extra : rebase_source : c0107eadd4c8e5ef0b67ae152054ffed6964207f extra : absorb_source : 1b592963fb3a9c9c75974a36be461b03bd6be1d6 extra : histedit_source : 6838aec7f6525e322df9d137b11ad0bfe10e8a4e
This commit is contained in:
Родитель
82a4500e40
Коммит
e1def15304
|
@ -687,6 +687,7 @@ class VCardProperties {
|
|||
* Add an entry to this object.
|
||||
*
|
||||
* @param {VCardPropertyEntry}
|
||||
* @return {boolean} - If the entry was added.
|
||||
*/
|
||||
addEntry(entry) {
|
||||
if (entry.constructor.name != "VCardPropertyEntry") {
|
||||
|
@ -703,7 +704,12 @@ class VCardProperties {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.entries.find(e => e.equals(entry))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.entries.push(entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -303,7 +303,7 @@ add_task(function testEntryMethods() {
|
|||
},
|
||||
};
|
||||
|
||||
props.addEntry(charlie);
|
||||
Assert.ok(props.addEntry(charlie));
|
||||
propertyArrayEqual(
|
||||
props.getAllEntries("email"),
|
||||
[data.charlie],
|
||||
|
@ -321,7 +321,7 @@ add_task(function testEntryMethods() {
|
|||
);
|
||||
propertyArrayEqual(props.entries, [data.charlie], "props has one entry");
|
||||
|
||||
props.addEntry(delta);
|
||||
Assert.ok(props.addEntry(delta));
|
||||
propertyArrayEqual(
|
||||
props.getAllEntries("email"),
|
||||
[data.charlie, data.delta],
|
||||
|
@ -343,6 +343,13 @@ add_task(function testEntryMethods() {
|
|||
"props has two entries"
|
||||
);
|
||||
|
||||
Assert.ok(!props.addEntry(charlie));
|
||||
propertyArrayEqual(
|
||||
props.entries,
|
||||
[data.charlie, data.delta],
|
||||
"props still has two entries"
|
||||
);
|
||||
|
||||
// Update a property entry.
|
||||
|
||||
charlie.value = "juliet@invalid";
|
||||
|
|
Загрузка…
Ссылка в новой задаче