Bug 1198412 - Use Array.includes in calendar. r=Fallen

This commit is contained in:
Sebastian Hengst 2015-09-22 10:51:50 +02:00
Родитель e042dc4b33
Коммит 1769796a0b
36 изменённых файлов: 91 добавлений и 79 удалений

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

@ -620,7 +620,7 @@
<parameter name="aPreference"/>
<body><![CDATA[
// refresh view if categories seem to have changed
if (aPreference.indexOf("calendar.category.color") == 0) {
if (aPreference.startsWith("calendar.category.color")) {
this.refreshView();
return;
}

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

@ -233,7 +233,7 @@ calDNDBaseObserver.prototype = {
}
// Treat unicode data with VEVENT in it as text/calendar
if (bestFlavor.value == "text/unicode" && data.toString().indexOf("VEVENT") != -1) {
if (bestFlavor.value == "text/unicode" && data.toString().includes("VEVENT")) {
bestFlavor.value = "text/calendar";
}

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

@ -111,7 +111,7 @@ function setDefaultItemValues(aItem, aCalendar=null, aStartDate=null, aEndDate=n
}
let units = Preferences.get("calendar.task.defaultstartoffsetunits", "minutes");
if (["days", "hours", "minutes"].indexOf(units) < 0) {
if (!["days", "hours", "minutes"].includes(units)) {
units = "minutes";
}
let startOffset = cal.createDuration();
@ -156,7 +156,7 @@ function setDefaultItemValues(aItem, aCalendar=null, aStartDate=null, aEndDate=n
let defaultDue = Preferences.get("calendar.task.defaultdue", "none");
let units = Preferences.get("calendar.task.defaultdueoffsetunits", "minutes");
if (["days", "hours", "minutes"].indexOf(units) < 0) {
if (!["days", "hours", "minutes"].includes(units)) {
units = "minutes";
}
let dueOffset = cal.createDuration();

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

@ -928,7 +928,7 @@
let headerkids = document.getAnonymousElementByAttribute(this, "anonid", "labeldaybox").childNodes;
for (var i in columns) {
var dayForColumn = (Number(i) + this.mWeekStartOffset) % 7;
var dayOff = (this.mDaysOffArray.indexOf(dayForColumn) != -1);
var dayOff = this.mDaysOffArray.includes(dayForColumn);
columns[i].collapsed = dayOff && !this.mDisplayDaysOff;
headerkids[i].collapsed = dayOff && !this.mDisplayDaysOff;
}

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

@ -3258,7 +3258,7 @@
workday.makeImmutable();
if (this.mDisplayDaysOff) {
computedDateList.push(workday);
} else if (this.mDaysOffArray.indexOf(startDate.weekday) == -1) {
} else if (!this.mDaysOffArray.includes(startDate.weekday)) {
computedDateList.push(workday);
}
startDate.day += 1;

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

@ -338,7 +338,7 @@ function getDefaultAlarmType() {
let calendar = getCurrentCalendar();
let alarmCaps = calendar.getProperty("capabilities.alarms.actionValues") ||
["DISPLAY"];
return (alarmCaps.indexOf("DISPLAY") < 0 ? alarmCaps[0] : "DISPLAY");
return (alarmCaps.includes("DISPLAY") ? "DISPLAY" : alarmCaps[0]);
}
/**

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

@ -514,7 +514,7 @@
let thisId = abCard.primaryEmail;
if (abCard.displayName.length > 0) {
let rCn = abCard.displayName;
if (rCn.indexOf(",") >= 0) {
if (rCn.includes(",")) {
rCn = '"' + rCn + '"';
}
thisId = rCn + " <" + thisId + ">";

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

@ -1612,7 +1612,7 @@ function updatePrivacy() {
// Hide the toolbar if the value is unsupported or is for a
// specific provider and doesn't belong to the current provider.
if (privacyValues.indexOf(currentPrivacyValue) < 0 ||
if (!privacyValues.includes(currentPrivacyValue) ||
(currentProvider && currentProvider != calendar.type)) {
node.setAttribute("collapsed", "true");
} else {
@ -1641,7 +1641,7 @@ function updatePrivacy() {
// Hide the menu if the value is unsupported or is for a
// specific provider and doesn't belong to the current provider.
if (privacyValues.indexOf(currentPrivacyValue) < 0 ||
if (!privacyValues.includes(currentPrivacyValue) ||
(currentProvider && currentProvider != calendar.type)) {
node.setAttribute("collapsed", "true");
} else {
@ -1670,7 +1670,7 @@ function updatePrivacy() {
// Hide the panel if the value is unsupported or is for a
// specific provider and doesn't belong to the current provider,
// or is not the items privacy value
if (privacyValues.indexOf(currentPrivacyValue) < 0 ||
if (!privacyValues.includes(currentPrivacyValue) ||
(currentProvider && currentProvider != calendar.type) ||
gPrivacy != currentPrivacyValue) {
node.setAttribute("collapsed", "true");

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

@ -279,7 +279,7 @@ function saveEventsToFile(calendarEventArray, aDefaultFileName) {
.getService(Components.interfaces.calIExporter);
let filePath = fp.file.path;
if (filePath.indexOf(".") == -1) {
if (!filePath.includes(".")) {
filePath += "."+exporter.getFileTypes({})[0].defaultExtension;
}

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

@ -49,7 +49,7 @@ var gAlarmsPane = {
readSoundLocation: function gAP_readSoundLocation() {
var soundUrl = document.getElementById("alarmSoundFileField");
soundUrl.value = document.getElementById("calendar.alarms.soundURL").value;
if (soundUrl.value.indexOf("file://") == 0) {
if (soundUrl.value.startsWith("file://")) {
soundUrl.label = this.convertURLToLocalFile(soundUrl.value).leafName;
} else {
soundUrl.label = soundUrl.value;

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

@ -70,9 +70,9 @@ var gCalendarGeneralPane = {
let offsetValues = ["offsetcurrent", "offsetnexthour"];
document.getElementById("default_task_due_offset")
.style.visibility = offsetValues.indexOf(defaultDue) > -1 ? "" : "hidden";
.style.visibility = offsetValues.includes(defaultDue) ? "" : "hidden";
document.getElementById("default_task_start_offset")
.style.visibility = offsetValues.indexOf(defaultStart) > -1 ? "" : "hidden";
.style.visibility = offsetValues.includes(defaultStart) ? "" : "hidden";
updateMenuLabelsPlural("default_task_start_offset_text", "default_task_start_offset_units");
updateMenuLabelsPlural("default_task_due_offset_text", "default_task_due_offset_units");

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

@ -342,8 +342,7 @@
return false;
}
var collapsedModes = this.getAttribute("collapsedinmodes").split(",");
var modeIndex = collapsedModes.indexOf(lMode);
return (modeIndex == -1);
return (!collapsedModes.includes(lMode));
]]></body>
</method>
@ -445,7 +444,7 @@
lModes = modeString.split(",");
}
if (lModes && lModes.length > 0) {
display = lModes.indexOf(lMode) > -1;
display = lModes.includes(lMode);
}
return display;
]]></body>

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

@ -22,7 +22,7 @@ cal.alarms = {
let units = Preferences.get("calendar.alarms." + type + "alarmunit", "minutes");
// Make sure the alarm pref is valid, default to minutes otherwise
if (["weeks", "days", "hours", "minutes", "seconds"].indexOf(units) < 0) {
if (!["weeks", "days", "hours", "minutes", "seconds"].includes(units)) {
units = "minutes";
}
@ -42,7 +42,7 @@ cal.alarms = {
aItem.calendar.getProperty("capabilities.alarms.actionValues")) ||
["DISPLAY"]);
alarm.action = (actionValues.indexOf("DISPLAY") < 0 ? actionValues[0] : "DISPLAY");
alarm.action = (actionValues.includes("DISPLAY") ? "DISPLAY" : actionValues[0]);
aItem.addAlarm(alarm);
}
},

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

@ -403,7 +403,7 @@ Extractor.prototype = {
if (this.isValidDay(day)) {
for (let i = 0; i < 12; i++) {
if (this.months[i].split("|").indexOf(month.toLowerCase()) != -1) {
if (this.months[i].split("|").includes(month.toLowerCase())) {
let rev = this.prefixSuffixStartEnd(res, relation, this.email);
this.guess(year, i + 1, day, null, null,
rev.start, rev.end, rev.pattern, rev.relation, pattern);
@ -448,7 +448,7 @@ Extractor.prototype = {
if (this.isValidDay(day)) {
for (let i = 0; i < 12; i++) {
let ms = this.months[i].unescape().split("|");
if (ms.indexOf(month.toLowerCase()) != -1) {
if (ms.includes(month.toLowerCase())) {
let date = {year: this.now.getFullYear(), month: i + 1, day: day};
if (this.isPastDate(date, this.now)) {
// find next such date
@ -1252,7 +1252,7 @@ Extractor.prototype = {
if (isNaN(r)) {
for (let i = 0; i <= 31; i++) {
let ns = numbers[i].split("|");
if (ns.indexOf(number.toLowerCase()) != -1) {
if (ns.includes(number.toLowerCase())) {
return i;
}
}

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

@ -23,7 +23,7 @@ function launchBrowser(url, event)
// by only allowing URLs starting with http or https.
// XXX: We likely will want to do this using nsIURLs in the future to
// prevent sneaky nasty escaping issues, but this is fine for now.
if (url.indexOf("http") != 0) {
if (!url.startsWith("http")) {
Components.utils.reportError ("launchBrowser: " +
"Invalid URL provided: " + url +
" Only http:// and https:// URLs are valid.");

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

@ -150,7 +150,7 @@ calCalendarManager.prototype = {
// the "cal" namespace defined
let ua = httpChannel.getRequestHeader("User-Agent");
let calUAString = Preferences.get("calendar.useragent.extra");
if (calUAString && ua.indexOf(calUAString) < 0) {
if (calUAString && !ua.includes(calUAString)) {
// User-Agent is not a mergeable header. We need to
// merge the user agent ourselves.
httpChannel.setRequestHeader("User-Agent",

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

@ -355,15 +355,15 @@ calFilter.prototype = {
}
//XXX TODO: Support specifying which fields to search on
for each (let field in ["SUMMARY", "DESCRIPTION", "LOCATION", "URL"]) {
for (let field of ["SUMMARY", "DESCRIPTION", "LOCATION", "URL"]) {
let val = aItem.getProperty(field);
if (val && val.toLowerCase().indexOf(searchText) != -1) {
if (val && val.toLowerCase().includes(searchText)) {
return true;
}
}
return aItem.getCategories({}).some(function(cat) {
return (cat.toLowerCase().indexOf(searchText) != -1);
return cat.toLowerCase().includes(searchText);
});
},
@ -421,7 +421,7 @@ calFilter.prototype = {
cats = props.category;
}
result = cats.some(function(cat) {
return aItem.getCategories({}).indexOf(cat) > -1;
return aItem.getCategories({}).includes(cat);
});
}

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

@ -184,7 +184,7 @@ calTimezoneService.prototype = {
cal.ERROR("Unknown timezone requested\n" + cal.STACK(10));
return null;
}
if (tzid.indexOf("/mozilla.org/") == 0) {
if (tzid.startsWith("/mozilla.org/")) {
// We know that our former tzids look like "/mozilla.org/<dtstamp>/continent/..."
// The ending of the mozilla prefix is the index of that slash before the
// continent. Therefore, we start looking for the prefix-ending slash

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

@ -128,7 +128,7 @@ function saveRecentTimezone(aTzid) {
const MAX_RECENT_TIMEZONES = 5; // We don't need a pref for *everything*.
if (aTzid != calendarDefaultTimezone().tzid &&
recentTimezones.indexOf(aTzid) < 0) {
!recentTimezones.includes(aTzid)) {
// Add the timezone if its not already the default timezone
recentTimezones.unshift(aTzid);
recentTimezones.splice(MAX_RECENT_TIMEZONES);

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

@ -111,7 +111,7 @@ ItipContentHandler.prototype = {
handleContent: function (contentType, windowTarget, request) {
let channel = request.QueryInterface(CI.nsIChannel);
let uri = channel.URI.spec;
if (uri.indexOf(ITIP_HANDLER_PROTOCOL + ":") != 0) {
if (!uri.startsWith(ITIP_HANDLER_PROTOCOL + ":")) {
cal.ERROR("Unexpected iTIP uri: " + uri + "\n");
return Components.results.NS_ERROR_FAILURE;
}

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

@ -565,9 +565,9 @@ calDavCalendar.prototype = {
} // else use outbound email-based iTIP (from cal.ProviderBase)
break;
case "capabilities.tasks.supported":
return (this.supportedItemTypes.indexOf("VTODO") > -1);
return (this.supportedItemTypes.includes("VTODO"));
case "capabilities.events.supported":
return (this.supportedItemTypes.indexOf("VEVENT") > -1);
return (this.supportedItemTypes.includes("VEVENT"));
case "capabilities.autoschedule.supported":
return this.hasAutoScheduling;
}
@ -1843,7 +1843,7 @@ calDavCalendar.prototype = {
if (supportedComponents && supportedComponents.length) {
thisCalendar.mSupportedItemTypes = [ compName
for each (compName in supportedComponents)
if (thisCalendar.mGenerallySupportedItemTypes.indexOf(compName) >= 0)
if (thisCalendar.mGenerallySupportedItemTypes.includes(compName))
];
cal.LOG("Adding supported items: " + thisCalendar.mSupportedItemTypes.join(",") + " for calendar: " + thisCalendar.name);
}
@ -1968,14 +1968,14 @@ calDavCalendar.prototype = {
// URL but a) doesn't use it and b) 405s on etag queries to it
thisCalendar.mShouldPollInbox = false;
}
if (dav && dav.indexOf("calendar-auto-schedule") != -1) {
if (dav && dav.includes("calendar-auto-schedule")) {
if (thisCalendar.verboseLogging()) {
cal.LOG("CalDAV: Calendar " + thisCalendar.name +
" supports calendar-auto-schedule");
}
thisCalendar.hasAutoScheduling = true;
// leave outbound inbox/outbox scheduling off
} else if (dav && dav.indexOf("calendar-schedule") != -1) {
} else if (dav && dav.includes("calendar-schedule")) {
if (thisCalendar.verboseLogging()) {
cal.LOG("CalDAV: Calendar " + thisCalendar.name +
" generally supports calendar-schedule");
@ -1983,7 +1983,7 @@ calDavCalendar.prototype = {
thisCalendar.hasScheduling = true;
}
if (thisCalendar.hasAutoScheduling || (dav && dav.indexOf("calendar-schedule") != -1)) {
if (thisCalendar.hasAutoScheduling || (dav && dav.includes("calendar-schedule"))) {
// XXX - we really shouldn't register with the fb service
// if another calendar with the same principal-URL has already
// done so. We also shouldn't register with the fb service if we
@ -2611,7 +2611,7 @@ calDavCalendar.prototype = {
// value and not null!
return ((this.hasScheduling || this.hasAutoScheduling) &&
(this.mInboxUrl != null) &&
aString.indexOf(this.mInboxUrl.spec) == 0);
aString.startsWith(this.mInboxUrl.spec));
},
/**

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

@ -545,8 +545,7 @@ webDavSyncHandler.prototype = {
if ((!r.getcontenttype || r.getcontenttype == "text/plain") &&
r.href &&
r.href.length >= 4 &&
r.href.substr(r.href.length - 4,4) == ".ics") {
r.href.endsWith(".ics")) {
// If there is no content-type (iCloud) or text/plain was passed
// (iCal Server) for the resource but its name ends with ".ics"
// assume the content type to be text/calendar. Apple
@ -585,7 +584,7 @@ webDavSyncHandler.prototype = {
this.itemsNeedFetching.push(r.href);
}
} else if (r.status &&
r.status.indexOf(" 507") > -1) {
r.status.includes(" 507")) {
// webdav-sync says that if a 507 is encountered and the
// url matches the request, the current token should be
// saved and another request should be made. We don't
@ -604,9 +603,9 @@ webDavSyncHandler.prototype = {
// want to make sure these are not counted as unhandled
// errors in the next block
} else if ((r.getcontenttype &&
r.getcontenttype.substr(0,13) == "text/calendar") ||
r.getcontenttype.startsWith("text/calendar") ||
(r.status &&
r.status.indexOf(" 404") == -1)) {
!r.status.includes(" 404"))) {
// If the response element is still not handled, log an
// error only if the content-type is text/calendar or the
// response status is different than 404 not found. We

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

@ -130,7 +130,7 @@ calGoogleRequest.prototype = {
set type(v) {
let valid = [this.GET, this.ADD, this.MODIFY, this.PATCH, this.DELETE];
if (valid.indexOf(v) < 0) {
if (!valid.includes(v)) {
throw new Components.Exception("Invalid request type: " + v,
Components.results.NS_ERROR_ILLEGAL_VALUE);
}

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

@ -406,7 +406,7 @@ calGoogleSession.prototype = {
aListener.onResult({ status: aStatus }, null);
}.bind(this);
if (aCalId.indexOf("@") < 0 || aCalId.indexOf(".") < 0 ||
if (!aCalId.includes("@") || !aCalId.includes(".") ||
!aCalId.toLowerCase().startsWith("mailto:")) {
// No valid email, screw it
return failSync(Components.results.NS_ERROR_FAILURE, null);

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

@ -84,6 +84,15 @@ function shimIt(global) {
});
}
if (!global.Array.prototype.includes) {
Object.defineProperty(global.Array.prototype, 'includes', {
enumerable: false,
configurable: true,
writable: false,
value: ArrayIncludes
});
}
if (!global.Map) {
global.Map = Map;
}
@ -116,6 +125,13 @@ function StringContains() {
return String.prototype.indexOf.apply(this, arguments) !== -1;
}
/**
* Implementation for Array.prototype.includes.
*/
function ArrayIncludes() {
return Array.prototype.indexOf.apply(this, arguments) !== -1;
}
/**
* forEach implementation for Map and Set, for Thunderbird 24
*/

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

@ -666,9 +666,7 @@ calICSCalendar.prototype = {
function purgeBackupsByType(files, type) {
// filter out backups of the type we care about.
var filteredFiles = files.filter(
function f(v) {
return (v.name.indexOf("calBackupData_"+pseudoID+"_"+type) != -1)
});
v => v.name.includes("calBackupData_"+pseudoID+"_"+type));
// Sort by lastmodifed
filteredFiles.sort(
function s(a,b) {

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

@ -611,7 +611,7 @@ function calWcapCalendar_tunnelXProps(destItem, srcItem) {
try {
var prop = enumerator.getNext().QueryInterface(Components.interfaces.nsIProperty);
var name = prop.name;
if (name.indexOf("X-MOZ-") == 0) {
if (name.startsWith("X-MOZ-")) {
switch (name) {
// keep snooze stamps for occurrences only and if alarm is still set:
case "X-MOZ-SNOOZE-TIME":

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

@ -160,14 +160,14 @@
// Remove commas
val = val.replace(',', '');
if (val.indexOf(' ') == -1) {
if (!val.includes(' ')) {
// Just a single word, or a single date.
return getDateForDay(val);
}
// Replace month names with numbers
for (var i in this.mMonthLongNames) {
if (val.indexOf(this.mMonthLongNames[i]) != -1) {
if (val.includes(this.mMonthLongNames[i])) {
var newVal = val.replace(this.mMonthLongNames[i], Number(i)+1);
newVal = newVal.replace(' ', '/');
return this.parseDateTime(newVal);
@ -176,7 +176,7 @@
// Same for short month names
for (var i in this.mMonthShortNames) {
if (val.indexOf(this.mMonthShortNames[i]) != -1) {
if (val.includes(this.mMonthShortNames[i])) {
var newVal = val.replace(this.mMonthShortNames[i], Number(i)+1);
newVal = newVal.replace(' ', '/');
return this.parseDateTime(newVal);
@ -1929,7 +1929,7 @@
this.amRegExp = new RegExp("^(?:"+amExpr+")$");
this.pmRegExp = new RegExp("^(?:"+pmExpr+")$");
// build time display format that mimics "%x" format without seconds
var ampmSep = (pmProbeString.indexOf(' ') != -1? " " : "");
var ampmSep = (pmProbeString.includes(' ') ? " " : "");
if (this.ampmIndex == PRE_INDEX)
this.kTimeFormatString = "%p" + ampmSep + "%I:%M";
else if (this.ampmIndex == POST_INDEX)

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

@ -254,8 +254,8 @@ function checkTooltip(monthView, row, col, date, startTime, endTime){
let dateTime = new elementslib.Lookup(controller.window.document,
'/id("messengerWindow")/id("calendar-popupset")/id("itemTooltip")/'
+ '{"class":"tooltipBox"}/{"class":"tooltipHeaderGrid"}/[1]/[2]/[1]').getNode().textContent + '';
controller.assertJS(dateTime.indexOf(date) != -1 && dateTime.indexOf(startTime) != -1
&& dateTime.indexOf(endTime) != -1);
controller.assertJS(dateTime.includes(date) && dateTime.includes(startTime)
&& dateTime.includes(endTime));
}
var teardownTest = function(module) {

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

@ -423,7 +423,7 @@ function setData(controller, data) {
+ 'anon({"anonid":"input"})');
let dateService = Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat);
let mac = utils.appInfo.os.toLowerCase().indexOf("darwin") != -1;
let mac = utils.appInfo.os.toLowerCase().includes("darwin");
// wait for input elements' values to be populated
controller.sleep(sleep);

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

@ -93,7 +93,7 @@ var testLocalICS = function () {
cstream.readString(-1, str);
cstream.close();
controller.assertJS(str.value.indexOf("SUMMARY:" + title) != -1);
controller.assertJS(str.value.includes("SUMMARY:" + title));
}
var teardownTest = function(module) {

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

@ -158,7 +158,7 @@ function test_audio_alarm() {
let addedAttachments = alarm.getAttachments({});
equal(addedAttachments.length, 1);
equal(addedAttachments[0], sound);
ok(alarm.icalString.indexOf("ATTACH:file:///sound.wav") > -1);
ok(alarm.icalString.includes("ATTACH:file:///sound.wav"));
// Adding twice shouldn't change anything
alarm.addAttachment(sound);
@ -310,10 +310,10 @@ function test_xprop() {
alarm.description = "test";
alarm.related = Ci.calIAlarm.ALARM_RELATED_START
alarm.offset = createDuration("-PT5M");
ok(alarm.icalComponent.serializeToICS().indexOf(dt.icalString) > -1);
ok(alarm.icalComponent.serializeToICS().includes(dt.icalString));
alarm.deleteProperty("X-MOZ-LASTACK");
ok(!alarm.icalComponent.serializeToICS().indexOf(dt.icalString) > -1);
ok(!alarm.icalComponent.serializeToICS().includes(dt.icalString));
dump("Done\n");
}

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

@ -21,12 +21,12 @@ function test_values() {
// Check if all expected attendees are found
for (let i = 0; i < expectedAttendees.length; i++) {
notEqual(allAttendees.indexOf(expectedAttendees[i]), -1);
ok(allAttendees.includes(expectedAttendees[i]));
}
// Check if all found attendees are expected
for (let i = 0; i < allAttendees.length; i++) {
notEqual(expectedAttendees.indexOf(allAttendees[i]), -1);
ok(expectedAttendees.includes(allAttendees[i]));
}
}
function findById(event, id, a) {

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

@ -18,5 +18,5 @@ function run_test() {
// Also make sure there are no promoted properties set. This does not
// technically belong to this bug, but I almost caused this error while
// writing the patch.
ok(attendee.icalProperty.icalString.indexOf("RSVP") < 0);
ok(!attendee.icalProperty.icalString.includes("RSVP"));
}

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

@ -542,13 +542,13 @@ function test_interface() {
// deleteRecurrenceItem
rinfo.deleteRecurrenceItem(ritems[0]);
ok(item.icalString.indexOf("RRULE") < 0);
ok(!item.icalString.includes("RRULE"));
// deleteRecurrenceItemAt
rinfo.deleteRecurrenceItemAt(1);
itemString = item.icalString;
ok(itemString.indexOf("EXDATE") < 0);
ok(!(itemString.indexOf("RDATE") < 0));
ok(!itemString.includes("EXDATE"));
ok(itemString.includes("RDATE"));
// insertRecurrenceItemAt with exdate
rinfo.insertRecurrenceItemAt(ritems[1], 1);
@ -572,9 +572,9 @@ function test_interface() {
let occDate1 = cal.createDateTime("20020403T114500Z");
let occDate2 = cal.createDateTime("20020404T114500Z");
rinfo.removeOccurrenceAt(occDate1);
ok(!(item.icalString.indexOf("EXDATE") < 0));
ok(item.icalString.includes("EXDATE"));
rinfo.restoreOccurrenceAt(occDate1)
ok(item.icalString.indexOf("EXDATE") < 0);
ok(!item.icalString.includes("EXDATE"));
// modifyException / getExceptionFor
let occ1 = rinfo.getOccurrenceFor(occDate1);
@ -843,10 +843,10 @@ function test_rrule_icalstring() {
recRule.type = "YEARLY";
recRule.setComponent("BYMONTH", 1, [1]);
recRule.setComponent("BYMONTHDAY", 1, [3]);
notEqual(-1, [
ok([
"RRULE:FREQ=YEARLY;BYMONTHDAY=3;BYMONTH=1\r\n",
"RRULE:FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=3\r\n"
].indexOf(recRule.icalString));
].includes(recRule.icalString));
deepEqual(recRule.getComponent("BYMONTH", {}), [1]);
deepEqual(recRule.getComponent("BYMONTHDAY", {}), [3]);
@ -854,10 +854,10 @@ function test_rrule_icalstring() {
recRule.type = "YEARLY";
recRule.setComponent("BYMONTH", 1, [4]);
recRule.setComponent("BYDAY", 1, [3]);
notEqual(-1, [
ok([
"RRULE:FREQ=YEARLY;BYDAY=TU;BYMONTH=4\r\n",
"RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=TU\r\n"
].indexOf(recRule.icalString));
].includes(recRule.icalString));
deepEqual(recRule.getComponent("BYMONTH", {}), [4]);
deepEqual(recRule.getComponent("BYDAY", {}), [3]);
@ -865,10 +865,10 @@ function test_rrule_icalstring() {
recRule.type = "YEARLY";
recRule.setComponent("BYMONTH", 1, [4]);
recRule.setComponent("BYDAY", 1, [10]);
notEqual(-1, [
ok([
"RRULE:FREQ=YEARLY;BYDAY=1MO;BYMONTH=4\r\n",
"RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1MO\r\n"
].indexOf(recRule.icalString));
].includes(recRule.icalString));
deepEqual(recRule.getComponent("BYMONTH", {}), [4]);
deepEqual(recRule.getComponent("BYDAY", {}), [10]);
@ -876,10 +876,10 @@ function test_rrule_icalstring() {
recRule.type = "YEARLY";
recRule.setComponent("BYMONTH", 1, [4]);
recRule.setComponent("BYDAY", 1, [-22]);
notEqual(-1, [
ok([
"RRULE:FREQ=YEARLY;BYDAY=-2FR;BYMONTH=4\r\n",
"RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=-2FR\r\n"
].indexOf(recRule.icalString));
].includes(recRule.icalString));
deepEqual(recRule.getComponent("BYMONTH", {}), [4]);
deepEqual(recRule.getComponent("BYDAY", {}), [-22]);
}

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

@ -49,12 +49,12 @@ function checkRelations(event, expRel) {
// check if all expacted relations are found
for (let i = 0; i < expRel.length; i++) {
notEqual(allRel.indexOf(expRel[i]), -1);
ok(allRel.includes(expRel[i]));
}
// Check if all found relations are expected
for (let i = 0; i < allRel.length; i++) {
notEqual(expRel.indexOf(allRel[i]), -1);
ok(expRel.includes(allRel[i]));
}
}