diff options
Diffstat (limited to 'comm/calendar/test/unit/test_lenient_parsing.js')
-rw-r--r-- | comm/calendar/test/unit/test_lenient_parsing.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/comm/calendar/test/unit/test_lenient_parsing.js b/comm/calendar/test/unit/test_lenient_parsing.js new file mode 100644 index 0000000000..7d20584996 --- /dev/null +++ b/comm/calendar/test/unit/test_lenient_parsing.js @@ -0,0 +1,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); +}); |