Bug 1460001 - Ensure alarm attendees and attachments are not added twice. r=MakeMyDay

--HG--
extra : rebase_source : 975acba70599123a4299db99e2c3ba8fdef96532
This commit is contained in:
Philipp Kewisch 2018-09-18 15:22:59 -04:00
Родитель 278d3740e3
Коммит f12ae98ab8
2 изменённых файлов: 42 добавлений и 3 удалений

Просмотреть файл

@ -365,7 +365,11 @@ calAlarm.prototype = {
"DURATION": "duration",
"SUMMARY": "summary",
"DESCRIPTION": "description",
"X-MOZ-LASTACK": "lastAck"
"X-MOZ-LASTACK": "lastAck",
// These have complex setters and will be ignored in setProperty
"ATTACH": true,
"ATTENDEE": true
},
get icalComponent() {
@ -579,7 +583,12 @@ calAlarm.prototype = {
getProperty: function(aName) {
let name = aName.toUpperCase();
if (name in this.promotedProps) {
return this[this.promotedProps[name]];
if (this.promotedProps[name] === true) {
// Complex promoted props will return undefined
return undefined;
} else {
return this[this.promotedProps[name]];
}
} else {
return this.mProperties.get(name);
}
@ -589,7 +598,11 @@ calAlarm.prototype = {
this.ensureMutable();
let name = aName.toUpperCase();
if (name in this.promotedProps) {
this[this.promotedProps[name]] = aValue;
if (this.promotedProps[name] !== true) {
this[this.promotedProps[name]] = aValue;
} else {
cal.WARN(`Attempted to set complex property ${name} to a simple value ${aValue}`);
}
} else {
this.mProperties.set(name, aValue);
}

Просмотреть файл

@ -118,6 +118,19 @@ function test_email_alarm() {
alarm.clearAttendees();
equal(alarm.getAttendees({}).length, 0);
// Make sure attendees are correctly folded/imported
alarm.icalString = dedent`
BEGIN:VALARM
ACTION:EMAIL
TRIGGER;VALUE=DURATION:-PT5M
ATTENDEE:mailto:test@example.com
ATTENDEE:mailto:test@example.com
ATTENDEE:mailto:test2@example.com
END:VALARM
`;
equal(alarm.icalString.match(/ATTENDEE:mailto:test@example.com/g).length, 1);
equal(alarm.icalString.match(/ATTENDEE:mailto:test2@example.com/g).length, 1);
// TODO test attachments
dump("Done\n");
}
@ -187,6 +200,19 @@ function test_audio_alarm() {
addedAttachments = alarm.getAttachments({});
equal(addedAttachments.length, 0);
// AUDIO alarms should only be allowing one attachment, and folding any with the same value
alarm.icalString = dedent`
BEGIN:VALARM
ACTION:AUDIO
TRIGGER;VALUE=DURATION:-PT5M
ATTACH:Basso
UID:28F8007B-FE56-442E-917C-1F4E48DD406A
X-APPLE-DEFAULT-ALARM:TRUE
ATTACH:Basso
END:VALARM
`;
equal(alarm.icalString.match(/ATTACH:Basso/g).length, 1);
dump("Done\n");
}