Bug 1854422 - Set ICAL.design.strict to false in the main thread. r=mkmelin

Setting this property disappeared when libical was removed. I've added it to calUtils.jsm because that should get loaded before anything tries to use ical.js.

Differential Revision: https://phabricator.services.mozilla.com/D189603

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Geoff Lankow 2023-09-29 09:47:31 +00:00
Родитель 12ced1ee9c
Коммит 1b576ee18d
3 изменённых файлов: 45 добавлений и 0 удалений

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

@ -5,6 +5,9 @@
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { ConsoleAPI } from "resource://gre/modules/Console.sys.mjs";
const { ICAL } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm");
ICAL.design.strict = false;
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
CalDateTime: "resource:///modules/CalDateTime.jsm",

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

@ -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);
});

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

@ -60,6 +60,7 @@ tags = calendar
[test_itip_message_sender.js]
[test_itip_utils.js]
[test_l10n_utils.js]
[test_lenient_parsing.js]
[test_providers.js]
[test_recur.js]
[test_recurrence_utils.js]