summaryrefslogtreecommitdiffstats
path: root/comm/calendar/test/unit/test_lenient_parsing.js
blob: 7d205849962c7f881f0c537320d33639443050e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */

/**
 * Tests that ICAL.design.strict is set to false in both the main thread and
 * the ICS parsing worker. If either or both is set to true, this will fail.
 */

add_task(async function () {
  const item = await new Promise((resolve, reject) => {
    Cc["@mozilla.org/calendar/ics-parser;1"].createInstance(Ci.calIIcsParser).parseString(
      dedent`
        BEGIN:VCALENDAR
        BEGIN:VEVENT
        SUMMARY:An event!
        DTSTART:20240331
        DTEND:20240331
        END:VEVENT
        END:VCALENDAR
      `,
      {
        QueryInterface: ChromeUtils.generateQI(["calIIcsParsingListener"]),
        onParsingComplete(rv, parser) {
          if (Components.isSuccessCode(rv)) {
            resolve(parser.getItems()[0]);
          } else {
            reject(rv);
          }
        },
      }
    );
  });

  Assert.equal(item.startDate.year, 2024);
  Assert.equal(item.startDate.month, 2);
  Assert.equal(item.startDate.day, 31);
  Assert.equal(item.endDate.year, 2024);
  Assert.equal(item.endDate.month, 2);
  Assert.equal(item.endDate.day, 31);
});