Bug 1643552 - Fix browser_attendeesDialog.js failing with libical. r+a=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 05 Jun 2020 15:57:30 +1200
changeset 39349 702239e687b7193e92529c63a01afbf764acaf6c
parent 39348 793ed3e01440eb89635ba75d3cfd3ae27c7f7ccc
child 39350 182e267592f0f6447a7352a7614bdea9cbd01e48
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
bugs1643552
Bug 1643552 - Fix browser_attendeesDialog.js failing with libical. r+a=pmorris
calendar/test/browser/eventDialog/browser_attendeesDialog.js
--- a/calendar/test/browser/eventDialog/browser_attendeesDialog.js
+++ b/calendar/test/browser/eventDialog/browser_attendeesDialog.js
@@ -278,36 +278,36 @@ add_task(async () => {
   await testDays(
     cal.createDateTime("20100403T120000"),
     cal.createDateTime("20100403T130000"),
     "20100403",
     "20100407"
   );
   for (let i = -2; i < 0; i++) {
     await testDays(
-      fromToday(`P${i}DT12H`),
-      fromToday(`P${i}DT13H`),
-      fromToday(`P${i}D`).icalString.substring(0, 8),
-      fromToday(`P${i + 4}D`).icalString.substring(0, 8)
+      fromToday({ days: i, hours: 12 }),
+      fromToday({ days: i, hours: 13 }),
+      fromToday({ days: i }).icalString.substring(0, 8),
+      fromToday({ days: i + 4 }).icalString.substring(0, 8)
     );
   }
   for (let i = 0; i < 3; i++) {
     await testDays(
-      fromToday(`P${i}DT12H`),
-      fromToday(`P${i}DT13H`),
-      fromToday("P0D").icalString.substring(0, 8),
-      fromToday("P4D").icalString.substring(0, 8)
+      fromToday({ days: i, hours: 12 }),
+      fromToday({ days: i, hours: 13 }),
+      fromToday({ days: 0 }).icalString.substring(0, 8),
+      fromToday({ days: 4 }).icalString.substring(0, 8)
     );
   }
   for (let i = 3; i < 5; i++) {
     await testDays(
-      fromToday(`P${i}DT12H`),
-      fromToday(`P${i}DT13H`),
-      fromToday(`P${i - 2}D`).icalString.substring(0, 8),
-      fromToday(`P${i + 2}D`).icalString.substring(0, 8)
+      fromToday({ days: i, hours: 12 }),
+      fromToday({ days: i, hours: 13 }),
+      fromToday({ days: i - 2 }).icalString.substring(0, 8),
+      fromToday({ days: i + 2 }).icalString.substring(0, 8)
     );
   }
   await testDays(
     cal.createDateTime("20300403T120000"),
     cal.createDateTime("20300403T130000"),
     "20300401",
     "20300405"
   );
@@ -364,24 +364,28 @@ function openAttendeesWindow(eventWindow
 
 function closeAttendeesWindow(attendeesWindow, buttonAction = "accept") {
   let closedPromise = BrowserTestUtils.domWindowClosed(attendeesWindow);
   let dialog = attendeesWindow.document.querySelector("dialog");
   dialog.getButton(buttonAction).click();
   return closedPromise;
 }
 
-function fromToday(durationString) {
+function fromToday({ days = 0, hours = 0 }) {
   if (!fromToday.today) {
     fromToday.today = cal.dtz.now();
     fromToday.today.hour = fromToday.today.minute = fromToday.today.second = 0;
   }
 
+  let duration = cal.createDuration();
+  duration.days = days;
+  duration.hours = hours;
+
   let value = fromToday.today.clone();
-  value.addDuration(cal.createDuration(durationString));
+  value.addDuration(duration);
   return value;
 }
 
 var freeBusyProvider = {
   pendingRequests: [],
   sendNextResponse() {
     let next = this.pendingRequests.shift();
     if (next) {
@@ -410,18 +414,18 @@ var freeBusyProvider = {
         );
       } else {
         aListener.onResult(null, []);
       }
     });
   },
   data: {
     "mailto:mochitest@invalid": [
-      ["P1DT4H", "PT3H"],
-      ["P1DT8H", "PT3H"],
-      ["P1DT12H", "PT3H"],
-      ["P1DT16H", "PT3H"],
-      ["P2DT4H", "PT3H"],
+      [{ days: 1, hours: 4 }, "PT3H"],
+      [{ days: 1, hours: 8 }, "PT3H"],
+      [{ days: 1, hours: 12 }, "PT3H"],
+      [{ days: 1, hours: 16 }, "PT3H"],
+      [{ days: 2, hours: 4 }, "PT3H"],
     ],
     "mailto:juliet@invalid": [["P1DT9H", "PT8H"]],
     "mailto:romeo@invalid": [["P1DT14H", "PT5H"]],
   },
 };