Bug 1480393 - Explicitly declare what is being imported with ChromeUtils.import; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 22 Aug 2018 10:44:43 +1200
changeset 32021 7973e4623106e0a0360f416156ea872ded1d8c8e
parent 32020 a7e1bc3b72c34743c612012a4ea327f42fd68c05
child 32022 6e3e6d278a7bddedbacb41b33044f7e648f02ab8
push id2308
push userclokep@gmail.com
push dateWed, 05 Sep 2018 00:34:58 +0000
treeherdercomm-beta@e326b2dcd127 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen
bugs1480393
Bug 1480393 - Explicitly declare what is being imported with ChromeUtils.import; r=Fallen
calendar/base/backend/icaljs/calDateTime.js
calendar/base/backend/icaljs/calDuration.js
calendar/base/backend/icaljs/calICSService.js
calendar/base/backend/icaljs/calPeriod.js
calendar/base/backend/icaljs/calRecurrenceRule.js
calendar/base/content/agenda-listbox.js
calendar/base/content/agenda-listbox.xml
calendar/base/content/calendar-base-view.xml
calendar/base/content/calendar-chrome-startup.js
calendar/base/content/calendar-clipboard.js
calendar/base/content/calendar-common-sets.js
calendar/base/content/calendar-daypicker.xml
calendar/base/content/calendar-dnd-listener.js
calendar/base/content/calendar-extract.js
calendar/base/content/calendar-invitations-manager.js
calendar/base/content/calendar-item-bindings.xml
calendar/base/content/calendar-item-editing.js
calendar/base/content/calendar-management.js
calendar/base/content/calendar-menus.xml
calendar/base/content/calendar-month-view.xml
calendar/base/content/calendar-multiday-view.xml
calendar/base/content/calendar-statusbar.js
calendar/base/content/calendar-task-editing.js
calendar/base/content/calendar-task-tree.js
calendar/base/content/calendar-task-tree.xml
calendar/base/content/calendar-task-view.js
calendar/base/content/calendar-ui-utils.js
calendar/base/content/calendar-unifinder.js
calendar/base/content/calendar-view-core.xml
calendar/base/content/calendar-views.js
calendar/base/content/calendar-views.xml
calendar/base/content/dialogs/calendar-alarm-dialog.js
calendar/base/content/dialogs/calendar-creation.js
calendar/base/content/dialogs/calendar-dialog-utils.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
calendar/base/content/dialogs/calendar-event-dialog-recurrence-preview.xml
calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
calendar/base/content/dialogs/calendar-event-dialog-reminder.js
calendar/base/content/dialogs/calendar-event-dialog-timezone.js
calendar/base/content/dialogs/calendar-invitations-dialog.js
calendar/base/content/dialogs/calendar-invitations-list.xml
calendar/base/content/dialogs/calendar-migration-dialog.js
calendar/base/content/dialogs/calendar-print-dialog.js
calendar/base/content/dialogs/calendar-properties-dialog.js
calendar/base/content/dialogs/calendar-providerUninstall-dialog.js
calendar/base/content/dialogs/calendar-subscriptions-dialog.js
calendar/base/content/dialogs/calendar-summary-dialog.js
calendar/base/content/dialogs/chooseCalendarDialog.js
calendar/base/content/import-export.js
calendar/base/content/preferences/alarms.js
calendar/base/content/preferences/categories.js
calendar/base/content/preferences/editCategory.js
calendar/base/content/preferences/general.js
calendar/base/content/preferences/views.js
calendar/base/content/today-pane.js
calendar/base/content/widgets/calendar-alarm-widget.xml
calendar/base/content/widgets/calendar-list-tree.xml
calendar/base/content/widgets/calendar-widgets.xml
calendar/base/content/widgets/minimonth.xml
calendar/base/modules/calExtract.jsm
calendar/base/modules/calHashedArray.jsm
calendar/base/modules/calRecurrenceUtils.jsm
calendar/base/modules/calUtils.jsm
calendar/base/modules/shim/calAlarmUtils.jsm
calendar/base/modules/shim/calAsyncUtils.jsm
calendar/base/modules/shim/calAuthUtils.jsm
calendar/base/modules/shim/calItemUtils.jsm
calendar/base/modules/shim/calIteratorUtils.jsm
calendar/base/modules/shim/calItipUtils.jsm
calendar/base/modules/shim/calPrintUtils.jsm
calendar/base/modules/shim/calProviderUtils.jsm
calendar/base/modules/shim/calViewUtils.jsm
calendar/base/modules/shim/calXMLUtils.jsm
calendar/base/modules/utils/calAsyncUtils.jsm
calendar/base/modules/utils/calEmailUtils.jsm
calendar/base/modules/utils/calItemUtils.jsm
calendar/base/modules/utils/calItipUtils.jsm
calendar/base/modules/utils/calProviderUtils.jsm
calendar/base/modules/utils/calUnifinderUtils.jsm
calendar/base/src/calAlarm.js
calendar/base/src/calAlarmMonitor.js
calendar/base/src/calAlarmService.js
calendar/base/src/calAttachment.js
calendar/base/src/calAttendee.js
calendar/base/src/calCachedCalendar.js
calendar/base/src/calCalendarManager.js
calendar/base/src/calCalendarSearchService.js
calendar/base/src/calDateTimeFormatter.js
calendar/base/src/calDefaultACLManager.js
calendar/base/src/calDeletedItems.js
calendar/base/src/calEvent.js
calendar/base/src/calFilter.js
calendar/base/src/calFreeBusyService.js
calendar/base/src/calIcsParser.js
calendar/base/src/calIcsSerializer.js
calendar/base/src/calItemBase.js
calendar/base/src/calItipItem.js
calendar/base/src/calRecurrenceDate.js
calendar/base/src/calRecurrenceInfo.js
calendar/base/src/calRelation.js
calendar/base/src/calSleepMonitor.js
calendar/base/src/calStartupService.js
calendar/base/src/calTimezone.js
calendar/base/src/calTimezoneService.js
calendar/base/src/calTodo.js
calendar/base/src/calTransactionManager.js
calendar/base/src/calWeekInfoService.js
calendar/import-export/calHtmlExport.js
calendar/import-export/calIcsImportExport.js
calendar/import-export/calListFormatter.js
calendar/import-export/calMonthGridPrinter.js
calendar/import-export/calOutlookCSVImportExport.js
calendar/import-export/calWeekPrinter.js
calendar/itip/calItipEmailTransport.js
calendar/lightning/components/calItipProtocolHandler.js
calendar/lightning/components/lightningTextCalendarConverter.js
calendar/lightning/content/imip-bar.js
calendar/lightning/content/lightning-item-iframe.js
calendar/lightning/content/lightning-item-panel.js
calendar/lightning/content/lightning-utils.js
calendar/lightning/content/messenger-overlay-sidebar.js
calendar/lightning/modules/ltnInvitationUtils.jsm
calendar/providers/caldav/calDavCalendar.js
calendar/providers/caldav/calDavRequestHandlers.js
calendar/providers/caldav/content/caldav-lightning-utils.js
calendar/providers/composite/calCompositeCalendar.js
calendar/providers/gdata/components/calGoogleCalendar.js
calendar/providers/gdata/content/browserRequest.js
calendar/providers/gdata/content/gdata-calendar-creation.js
calendar/providers/gdata/content/gdata-event-dialog-reminder.js
calendar/providers/gdata/content/gdata-lightning-item-iframe.js
calendar/providers/gdata/content/gdata-migration.js
calendar/providers/gdata/modules/OAuth2.jsm
calendar/providers/gdata/modules/calUtilsShim.jsm
calendar/providers/gdata/modules/gdataLogging.jsm
calendar/providers/gdata/modules/gdataRequest.jsm
calendar/providers/gdata/modules/gdataSession.jsm
calendar/providers/gdata/modules/gdataUtils.jsm
calendar/providers/ics/calICSCalendar.js
calendar/providers/memory/calMemoryCalendar.js
calendar/providers/storage/calStorageCalendar.js
calendar/providers/storage/calStorageHelpers.jsm
calendar/providers/storage/calStorageUpgrade.jsm
calendar/providers/wcap/calWcapCalendar.js
calendar/providers/wcap/calWcapCalendarItems.js
calendar/providers/wcap/calWcapCalendarModule.js
calendar/providers/wcap/calWcapErrors.js
calendar/providers/wcap/calWcapRequest.js
calendar/providers/wcap/calWcapSession.js
calendar/providers/wcap/calWcapUtils.js
calendar/resources/content/calendarCreation.js
calendar/resources/content/datetimepickers/datetimepickers.xml
calendar/resources/content/mouseoverPreviews.js
calendar/resources/content/publish.js
calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
calendar/test/mozmill/recurrenceRotated/testWeeklyUntilRecurrence.js
calendar/test/mozmill/recurrenceRotated/testWeeklyWithExceptionRecurrence.js
calendar/test/mozmill/shared-modules/test-calendar-utils.js
calendar/test/mozmill/testAlarmDefaultValue.js
calendar/test/mozmill/testBasicFunctionality.js
calendar/test/mozmill/testLocalICS.js
calendar/test/mozmill/testTodayPane.js
calendar/test/mozmill/views/testDayView.js
calendar/test/mozmill/views/testMonthView.js
calendar/test/mozmill/views/testMultiweekView.js
calendar/test/mozmill/views/testWeekView.js
calendar/test/unit/head_consts.js
calendar/test/unit/test_alarmservice.js
calendar/test/unit/test_alarmutils.js
calendar/test/unit/test_attachment.js
calendar/test/unit/test_attendee.js
calendar/test/unit/test_bug1199942.js
calendar/test/unit/test_bug1204255.js
calendar/test/unit/test_bug1209399.js
calendar/test/unit/test_bug523860.js
calendar/test/unit/test_bug653924.js
calendar/test/unit/test_bug668222.js
calendar/test/unit/test_calmgr.js
calendar/test/unit/test_extract.js
calendar/test/unit/test_freebusy_service.js
calendar/test/unit/test_gdata_provider.js
calendar/test/unit/test_hashedarray.js
calendar/test/unit/test_items.js
calendar/test/unit/test_itip_utils.js
calendar/test/unit/test_ltninvitationutils.js
calendar/test/unit/test_search_service.js
calendar/test/unit/test_webcal.js
common/src/Overlays.jsm
common/src/customizeToolbar.js
common/src/extensionSupport.jsm
--- a/calendar/base/backend/icaljs/calDateTime.js
+++ b/calendar/base/backend/icaljs/calDateTime.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/ical.js");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { ICAL, unwrap, unwrapSetter } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
 
 var UNIX_TIME_TO_PRTIME = 1000000;
 
 function calDateTime(innerObject) {
     this.wrappedJSObject = this;
     this.innerObject = innerObject || ICAL.Time.epochTime.clone();
 }
 
--- a/calendar/base/backend/icaljs/calDuration.js
+++ b/calendar/base/backend/icaljs/calDuration.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/ical.js");
+var { ICAL, unwrap } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
 
 function calDuration(innerObject) {
     this.innerObject = innerObject || new ICAL.Duration();
     this.wrappedJSObject = this;
 }
 
 calDuration.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calIDuration]),
--- a/calendar/base/backend/icaljs/calICSService.js
+++ b/calendar/base/backend/icaljs/calICSService.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/ical.js");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calIcalProperty(innerObject) {
     this.innerObject = innerObject || new ICAL.Property();
     this.wrappedJSObject = this;
 }
 
 calIcalProperty.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calIIcalProperty]),
--- a/calendar/base/backend/icaljs/calPeriod.js
+++ b/calendar/base/backend/icaljs/calPeriod.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/ical.js");
+var { ICAL, unwrapSetter, wrapGetter } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
 
 function calPeriod(innerObject) {
     this.innerObject = innerObject || new ICAL.Period({});
     this.wrappedJSObject = this;
 }
 
 calPeriod.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calIPeriod]),
--- a/calendar/base/backend/icaljs/calRecurrenceRule.js
+++ b/calendar/base/backend/icaljs/calRecurrenceRule.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/ical.js");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function calRecurrenceRule(innerObject) {
     this.innerObject = innerObject || new ICAL.Recur();
     this.wrappedJSObject = this;
 }
 
 var calRecurrenceRuleInterfaces = [
--- a/calendar/base/content/agenda-listbox.js
+++ b/calendar/base/content/agenda-listbox.js
@@ -1,17 +1,16 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function Synthetic(aHeader, aDuration, aMultiday) {
     this.open = aHeader.getAttribute("checked") == "true";
     this.duration = aDuration;
     this.multiday = aMultiday;
 }
 
 var agendaListbox = {
@@ -951,17 +950,17 @@ agendaListbox.calendarObserver.onModifyI
             agendaListbox.agendaListboxControl.clearSelection();
             agendaListbox.agendaListboxControl.ensureElementIsVisible(listItem);
             agendaListbox.agendaListboxControl.selectedItem = listItem;
         }
     }
     setCurrentEvent();
 };
 
-agendaListbox.calendarObserver.onError = function(cal, errno, msg) {};
+agendaListbox.calendarObserver.onError = function(_cal, errno, msg) {};
 
 agendaListbox.calendarObserver.onPropertyChanged = function(aCalendar, aName, aValue, aOldValue) {
     switch (aName) {
         case "disabled":
             this.agendaListbox.refreshCalendarQuery();
             break;
         case "color":
             for (let node = agendaListbox.agendaListboxControl.firstChild;
--- a/calendar/base/content/agenda-listbox.xml
+++ b/calendar/base/content/agenda-listbox.xml
@@ -42,20 +42,19 @@
     <content>
       <xul:treenode-checkbox class="agenda-checkbox" anonid="agenda-checkbox-widget"
                                                    flex="1"
                                                    xbl:inherits="selected,label,hidden,disabled"/>
     </content>
     <implementation>
       <field name="kCheckbox">null</field>;
       <constructor><![CDATA[
-          this.dispatchEvent(new CustomEvent("bindingattached", { bubbles: false }));
+          this.kCheckbox = document.getAnonymousElementByAttribute(this, "anonid", "agenda-checkbox-widget");
 
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-          this.kCheckbox = document.getAnonymousElementByAttribute(this, "anonid", "agenda-checkbox-widget");
+          this.dispatchEvent(new CustomEvent("bindingattached", { bubbles: false }));
       ]]></constructor>
 
       <method name="getItem">
         <body><![CDATA[
             return this.mItem;
         ]]></body>
       </method>
 
@@ -108,17 +107,16 @@
           </xul:hbox>
         </xul:vbox>
       </xul:hbox>
     </content>
     <implementation>
       <field name="mAllDayItem">null</field>;
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           this.mAllDayItem = document.getAnonymousElementByAttribute(this, "anonid", "allday-item");
       ]]></constructor>
 
       <method name="setOccurrence">
         <parameter name="aOccurrence"/>
         <parameter name="aPeriod"/>
         <body><![CDATA[
             this.mOccurrence = aOccurrence;
--- a/calendar/base/content/calendar-base-view.xml
+++ b/calendar/base/content/calendar-base-view.xml
@@ -215,19 +215,18 @@
               onDefaultCalendarChanged: function(aNewDefaultCalendar) {
                   // don't care, for now
               }
           })
       ]]></field>
 
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Services.jsm");
-          ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource:///modules/gloda/log4moz.js");
+          const { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
 
           const kWorkdaysCommand = "calendar_toggle_workdays_only_command";
           const kTasksInViewCommand = "calendar_toggle_tasks_in_view_command";
           const kShowCompleted = "calendar_toggle_show_completed_in_view_command";
           const kOrientation = "calendar_toggle_orientation_command";
 
           this.workdaysOnly = (document.getElementById(kWorkdaysCommand)
                                   .getAttribute("checked") == "true");
--- a/calendar/base/content/calendar-chrome-startup.js
+++ b/calendar/base/content/calendar-chrome-startup.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 /* exported commonInitCalendar, commonFinishCalendar */
 
 /**
  * Common initialization steps for calendar chrome windows.
--- a/calendar/base/content/calendar-clipboard.js
+++ b/calendar/base/content/calendar-clipboard.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /* exported cutToClipboard, pasteFromClipboard */
 
 /**
  * Test if a writable calendar is selected, and if the clipboard has items that
  * can be pasted into Calendar. The data must be of type "text/calendar" or
  * "text/unicode".
  *
--- a/calendar/base/content/calendar-common-sets.js
+++ b/calendar/base/content/calendar-common-sets.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /* exported injectCalendarCommandController, removeCalendarCommandController,
  *          setupContextItemType, minimonthPick, getSelectedItems,
  *          deleteSelectedItems, calendarUpdateNewItemsCommand
  */
 
 var CalendarDeleteCommandEnabled = false;
 var CalendarNewEventsCommandEnabled = false;
--- a/calendar/base/content/calendar-daypicker.xml
+++ b/calendar/base/content/calendar-daypicker.xml
@@ -228,17 +228,17 @@
                     }
                 }
             }
             return days;
         ]]></getter>
       </property>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
           let mainbox =
               document.getAnonymousElementByAttribute(
                   this, "anonid", "mainbox");
           let numRows = mainbox.childNodes.length;
           let child = null;
           for (let i = 0; i < numRows; i++) {
               let row = mainbox.childNodes[i];
               let numChilds = row.childNodes.length;
--- a/calendar/base/content/calendar-dnd-listener.js
+++ b/calendar/base/content/calendar-dnd-listener.js
@@ -1,15 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 /* exported invokeEventDragSession, calendarViewDNDObserver,
  *          calendarMailButtonDNDObserver, calendarCalendarButtonDNDObserver,
  *          calendarTaskButtonDNDObserver
  */
 
--- a/calendar/base/content/calendar-extract.js
+++ b/calendar/base/content/calendar-extract.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calExtract.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { Extractor } = ChromeUtils.import("resource://calendar/modules/calExtract.jsm", null);
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var calendarExtract = {
     onShowLocaleMenu: function(target) {
         let localeList = document.getElementById(target.id);
         let langs = [];
         let chrome = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
--- a/calendar/base/content/calendar-invitations-manager.js
+++ b/calendar/base/content/calendar-invitations-manager.js
@@ -1,15 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 /* exported getInvitationsManager */
 
 /**
  * This object contains functions to take care of manipulating requests.
  */
 var gInvitationsRequestManager = {
     mRequestStatusList: {},
--- a/calendar/base/content/calendar-item-bindings.xml
+++ b/calendar/base/content/calendar-item-bindings.xml
@@ -25,20 +25,16 @@
                  xbl:inherits="align"/>
       <xul:textbox readonly="true"
                    class="selectable-label plain"
                    anonid="item-datetime-value"/>
     </content>
     <implementation>
       <field name="mItem">null</field>
 
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <property name="mode"
                 readonly="true">
         <getter><![CDATA[
             if (this.hasAttribute("mode")) {
                 return this.getAttribute("mode");
             } else {
                 return "start";
             }
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /* exported modifyEventWithDialog, undo, redo, setContextPartstat */
 
 /**
  * Takes a job and makes sure the dispose function on it is called. If there is
  * no dispose function or the job is null, ignore it.
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -4,19 +4,18 @@
 
 /* exported promptDeleteCalendar, loadCalendarManager, unloadCalendarManager,
  *         updateSortOrderPref, calendarListTooltipShowing,
  *         calendarListSetupContextMenu, ensureCalendarVisible, toggleCalendarVisible,
  *         showAllCalendars, showOnlyCalendar, openCalendarSubscriptionsDialog,
  *         calendarOfflineManager
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /**
  * Get this window's currently selected calendar.
  *
  * @return      The currently selected calendar.
  */
 function getSelectedCalendar() {
--- a/calendar/base/content/calendar-menus.xml
+++ b/calendar/base/content/calendar-menus.xml
@@ -12,17 +12,17 @@
 
   <binding id="task-menupopup" extends="xul:menupopup">
     <implementation>
       <field name="mType">null</field>;
       <field name="mPopupHandler">null</field>
       <field name="mParentMenuPopup">null</field>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
           this.mPopupHandler = () => { this.changeMenuByPropertyName(); };
           this.mParentMenuPopup = cal.view.getParentNodeOrThis(this, "menupopup");
           this.mParentMenuPopup.addEventListener("popupshowing", this.mPopupHandler, true);
       ]]></constructor>
 
       <destructor><![CDATA[
           this.mParentMenuPopup.removeEventListener("popupshowing", this.mPopupHandler, true);
--- a/calendar/base/content/calendar-month-view.xml
+++ b/calendar/base/content/calendar-month-view.xml
@@ -64,20 +64,16 @@
                 </xul:hbox>
               </xul:stack>
             </xul:box>
           </xul:box>
         </xul:hbox>
       </xul:vbox>
     </content>
     <implementation>
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <property name="occurrence">
         <getter><![CDATA[
             return this.mOccurrence;
         ]]></getter>
         <setter><![CDATA[
             cal.ASSERT(!this.mOccurrence, "Code changes needed to set the occurrence twice", true);
             this.mOccurrence = val;
             if (cal.item.isEvent(val)) {
@@ -138,20 +134,16 @@
                    xbl:inherits="relation,selected,value"/>
       </xul:hbox>
       <xul:vbox anonid="day-items" class="calendar-month-day-box-items-box" flex="1">
         <children/>
       </xul:vbox>
     </content>
 
     <implementation>
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <field name="mDate">null</field>
       <field name="mItemHash">{}</field>
       <field name="mShowMonthLabel">false</field>
 
       <property name="date"
                 onget="return this.mDate"
                 onset="this.setDate(val); return val;"/>
 
@@ -418,17 +410,16 @@
           </xul:rows>
         </xul:grid>
       </xul:vbox>
     </content>
 
     <implementation implements="calICalendarView">
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           // Set the preference for the default start of the week
           this.weekStartOffset = Preferences.get("calendar.week.start", 0);
 
           for (let i = 0; i < 7; i++) {
               let hdr = createXULElement("calendar-day-label");
               this.labeldaybox.appendChild(hdr);
               hdr.weekDay = (i + this.mWeekStartOffset) % 7;
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -88,17 +88,17 @@
       </method>
 
       <property name="pixelsPerMinute"
                 onget="return this.mPixPerMin"
                 onset="if (this.mPixPerMin != val) { this.mPixPerMin = val; this.relayout(); } return val;"/>
 
       <method name="relayout">
         <body><![CDATA[
-            ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+            const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
             let topbox = document.getAnonymousElementByAttribute(this, "anonid", "topbox");
             let orient = topbox.getAttribute("orient");
 
             function makeTimeBox(timestr, size) {
                 let box = createXULElement("box");
                 box.setAttribute("orient", orient);
 
                 if (orient == "horizontal") {
@@ -240,17 +240,17 @@
           <xul:label anonid="fgdragbox-endlabel" class="fgdragbox-label"/>
         </xul:box>
       </xul:stack>
       <xul:calendar-event-box anonid="config-box" hidden="true" xbl:inherits="orient"/>
     </content>
 
     <implementation>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
           this.mEventInfos = [];
           this.mTimezone = cal.dtz.UTC;
           this.mSelectedItemIds = {};
       ]]></constructor>
 
       <!-- fields -->
       <field name="mPixPerMin">0.6</field>
@@ -1938,17 +1938,17 @@
             // So we really don't have anything to do here.
         ]]></body>
       </method>
 
       <method name="updateDragLabels">
         <parameter name="aFirstColumn"/>
         <parameter name="aLastColumn"/>
         <body><![CDATA[
-            ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+            const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
             if (!this.mDragState) {
                 return;
             }
 
             let firstColumn = aFirstColumn || this;
             let lastColumn = aLastColumn || this;
             let realstartmin = this.mDragState.startMin + this.mStartMin;
             let realendmin = this.mDragState.endMin + this.mStartMin;
@@ -2100,18 +2100,16 @@
   <binding id="calendar-header-container" extends="chrome://calendar/content/widgets/calendar-widgets.xml#dragndropContainer">
     <content xbl:inherits="selected" flex="1" class="calendar-event-column-header">
       <children/>
     </content>
 
     <implementation>
       <field name="mItemBoxes">null</field>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
           this.mItemBoxes = [];
       ]]></constructor>
 
       <property name="date">
         <getter><![CDATA[
             return this.mDate;
         ]]></getter>
         <setter><![CDATA[
@@ -2292,18 +2290,16 @@
             </xul:stack>
           </xul:box>
         </xul:box>
       </xul:box>
     </content>
 
     <implementation>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
           this.orient = this.getAttribute("orient");
       ]]></constructor>
 
       <!-- fields -->
       <field name="mParentColumn">null</field>
 
       <!-- methods/properties -->
       <method name="setAttribute">
@@ -2510,17 +2506,16 @@
                    equalsize="always"/>
         </xul:scrollbox>
       </xul:box>
     </content>
 
     <implementation implements="calICalendarView">
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           // get day start/end hour from prefs and set on the view
           this.setDayStartEndMinutes(Preferences.get("calendar.view.daystarthour", 8) * 60,
                                      Preferences.get("calendar.view.dayendhour", 17) * 60);
 
           // initially scroll to the day start hour in the view
           this.scrollToMinute(this.mDayStartMin);
 
--- a/calendar/base/content/calendar-statusbar.js
+++ b/calendar/base/content/calendar-statusbar.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /* exported gCalendarStatusFeedback */
 
 /**
  * This code might change soon if we support Thunderbird's activity manager.
  * NOTE: The naming "Meteors" is historical.
  */
 var gCalendarStatusFeedback = {
--- a/calendar/base/content/calendar-task-editing.js
+++ b/calendar/base/content/calendar-task-editing.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Used by the "quick add" feature for tasks, for example in the task view or
  * the uniinder-todo.
  *
  * NOTE: many of the following methods are called without taskEdit being the
  * |this| object.
  */
--- a/calendar/base/content/calendar-task-tree.js
+++ b/calendar/base/content/calendar-task-tree.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported addCalendarNames, calendars, changeContextMenuForTask,
  *          contextChangeTaskCalendar, contextChangeTaskPriority,
  *          contextPostponeTask, modifyTaskFromContext, deleteToDoCommand,
  *          tasksToMail, tasksToEvents, toggleCompleted,
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Add registered calendars to the given menupopup. Removes all previous
  * children.
  *
  * XXX Either replace the existing items using replaceNode, or use helper
  * functions (cal.removeChildren).
  *
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -107,18 +107,17 @@
         <xul:treechildren tooltip="taskTreeTooltip" ondblclick="mTreeView.onDoubleClick(event)"/>
       </xul:tree>
     </content>
 
     <implementation implements="nsIObserver">
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
           ChromeUtils.import("resource://gre/modules/Services.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-          ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
           // set up the tree filter
           this.mFilter = new calFilter();
 
           // set up the custom tree view
           let tree = document.getAnonymousElementByAttribute(this, "anonid", "calendar-task-tree");
           this.mTreeView.tree = tree;
           tree.view = this.mTreeView;
@@ -1149,20 +1148,16 @@
           invokeEventDragSession(item, event.target);
       ]]></handler>
     </handlers>
 
   </binding>
 
   <binding id="calendar-task-tree-todaypane" extends="chrome://calendar/content/calendar-task-tree.xml#calendar-task-tree">
     <implementation>
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <method name="getInitialDate">
         <body><![CDATA[
             let initialDate = agendaListbox.today ? agendaListbox.today.start : cal.dtz.now();
             return initialDate ? initialDate : cal.dtz.now();
         ]]></body>
       </method>
 
       <method name="updateFilter">
--- a/calendar/base/content/calendar-task-view.js
+++ b/calendar/base/content/calendar-task-view.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 /* exported taskDetailsView, sendMailToOrganizer, taskViewCopyLink */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const { recurrenceRule2String } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 var taskDetailsView = {
 
     /**
      * Task Details Events
      *
--- a/calendar/base/content/calendar-ui-utils.js
+++ b/calendar/base/content/calendar-ui-utils.js
@@ -7,17 +7,17 @@
  *          enableElementWithLock, uncheckChildNodes, removeChildren,
  *          appendCalendarItems, setAttributeToChildren, checkRadioControl,
  *          processEnableCheckbox, updateListboxDeleteButton,
  *          updateUnitLabelPlural, updateMenuLabelsPlural, menuListSelectItem,
  *          getOptimalMinimumWidth, getOptimalMinimumHeight,
  *          getOtherOrientation, updateSelectedLabel, setupAttendanceMenu
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 
 /**
  * Helper function for filling the form,
  * Set the value of a property of a XUL element
  *
  * @param aElement      ID of XUL element to set, or the element node itself
  * @param aNewValue     value to set property to ( if undefined no change is made )
--- a/calendar/base/content/calendar-unifinder.js
+++ b/calendar/base/content/calendar-unifinder.js
@@ -11,19 +11,18 @@
  *
  * This is a hacked in interface to the unifinder. We will need to
  * improve this to make it usable in general.
  *
  * NOTE: Including this file will cause a load handler to be added to the
  * window.
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 // Set this to true when the calendar event tree is clicked to allow for
 // multiple selection
 var gCalendarEventTreeClicked = false;
 
 // Store the start and enddate, because the providers can't be trusted when
 // dealing with all-day events. So we need to filter later. See bug 306157
 
--- a/calendar/base/content/calendar-view-core.xml
+++ b/calendar/base/content/calendar-view-core.xml
@@ -56,17 +56,16 @@
             </xul:box>
           </xul:box>
         </xul:hbox>
       </xul:vbox>
     </content>
 
     <implementation>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
           this.eventNameTextbox.onblur = () => {
               this.stopEditing(true);
           };
           this.eventNameTextbox.onkeypress = (event) => {
               // save on enter
               if (event.key == "Enter") {
--- a/calendar/base/content/calendar-views.js
+++ b/calendar/base/content/calendar-views.js
@@ -4,19 +4,18 @@
 
 /* exported switchToView, getSelectedDay, scheduleMidnightUpdate,
  *          updateStyleSheetForViews, observeViewDaySelect, toggleOrientation,
  *          toggleWorkdaysOnly, toggleTasksInView, toggleShowCompletedInView,
  *          goToDate, getLastCalendarView, deleteSelectedEvents,
  *          editSelectedEvents, selectAllEvents
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /**
  * Controller for the views
  * @see calIcalendarViewController
  */
 var calendarViewController = {
     QueryInterface: ChromeUtils.generateQI([Ci.calICalendarViewController]),
@@ -680,17 +679,16 @@ function selectAllEvents() {
 
     // Need to move one day out to get all events
     let end = currentView().endDay.clone();
     end.day += 1;
 
     composite.getItems(filter, 0, currentView().startDay, end, listener);
 }
 
-var cal = cal || {};
 cal.navigationBar = {
     setDateRange: function(aStartDate, aEndDate) {
         let docTitle = "";
         if (aStartDate) {
             let intervalLabel = document.getElementById("intervalDescription");
             let firstWeekNo = cal.getWeekInfoService().getWeekTitle(aStartDate);
             let secondWeekNo = firstWeekNo;
             let weekLabel = document.getElementById("calendarWeek");
--- a/calendar/base/content/calendar-views.xml
+++ b/calendar/base/content/calendar-views.xml
@@ -7,19 +7,16 @@
           xmlns="http://www.mozilla.org/xbl"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="calendar-day-view"
            extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
     <implementation implements="calICalendarView">
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
       <property name="observerID">
         <getter><![CDATA[
             return "day-view-observer";
         ]]></getter>
       </property>
       <property name="supportsWorkdaysOnly"
                 readonly="true"
                 onget="return false;"/>
@@ -51,18 +48,16 @@
       </method>
     </implementation>
   </binding>
 
   <binding id="calendar-week-view"
            extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
     <implementation implements="calICalendarView">
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
           // add a listener for the mode change
           this.mModeHandler = (event) => {
               if (event.attrName == "mode") {
                   this.onModeChanged(event);
               }
           };
           document.getElementById("modeBroadcaster").addEventListener("DOMAttrModified", this.mModeHandler, true);
       ]]></constructor>
@@ -118,17 +113,16 @@
       </method>
     </implementation>
   </binding>
 
   <binding id="calendar-multiweek-view" extends="chrome://calendar/content/calendar-month-view.xml#calendar-month-base-view">
     <implementation implements="calICalendarView">
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           this.mWeeksInView = Preferences.get("calendar.weeks.inview", 4);
       ]]></constructor>
 
       <field name="mWeeksInView">4</field>
 
       <property name="weeksInView">
         <getter><![CDATA[
             return this.mWeeksInView;
@@ -223,20 +217,16 @@
             }
         ]]></body>
       </method>
     </implementation>
   </binding>
 
   <binding id="calendar-month-view" extends="chrome://calendar/content/calendar-month-view.xml#calendar-month-base-view">
     <implementation implements="calICalendarView">
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <property name="observerID">
         <getter><![CDATA[
             return "month-view-observer";
         ]]></getter>
       </property>
 
       <!--Public methods-->
       <method name="goToDay">
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.js
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.js
@@ -2,17 +2,17 @@
  * 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/. */
 
 /* exported onDismissAllAlarms, setupWindow, finishWindow, addWidgetFor,
  *         removeWidgetFor, onSelectAlarm, ensureCalendarVisible
  */
 
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /**
  * Helper function to get the alarm service and cache it.
  *
  * @return The alarm service component
  */
 function getAlarmService() {
--- a/calendar/base/content/dialogs/calendar-creation.js
+++ b/calendar/base/content/dialogs/calendar-creation.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported openLocalCalendar */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Shows the filepicker and creates a new calendar with a local file using the ICS
  * provider.
  */
 function openLocalCalendar() {
     const nsIFilePicker = Components.interfaces.nsIFilePicker;
     let picker = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
--- a/calendar/base/content/dialogs/calendar-dialog-utils.js
+++ b/calendar/base/content/dialogs/calendar-dialog-utils.js
@@ -3,23 +3,21 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported gInTab, gMainWindow, gTabmail, intializeTabOrWindowVariables,
  *          dispose, setDialogId, loadReminders, saveReminder,
  *          commonUpdateReminder, updateLink, rearrangeAttendees,
  *          adaptScheduleAgent
  */
 
-ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 // Variables related to whether we are in a tab or a window dialog.
 var gInTab = false;
 var gMainWindow = null;
 var gTabmail = null;
 
 /**
  * Initialize variables for tab vs window.
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
@@ -2,17 +2,17 @@
  * 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/. */
 
 /* exported onLoad, onAccept, onCancel, zoomWithButtons, updateStartTime,
  *          endWidget, updateEndTime, editStartTimezone, editEndTimezone,
  *          changeAllDay, onNextSlot, onPreviousSlot
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 var gStartDate = null;
 var gEndDate = null;
 var gStartTimezone = null;
 var gEndTimezone = null;
 var gDuration = null;
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
@@ -19,20 +19,16 @@
       <field name="mRowHeight">0</field>
       <field name="mNumColumns">3</field>
       <field name="mIsOffline">0</field>
       <field name="mIsReadOnly">false</field>
       <field name="mIsInvitation">false</field>
       <field name="mPopupOpen">false</field>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-          ChromeUtils.import("resource://gre/modules/Services.jsm");
-          ChromeUtils.import("resource:///modules/mailServices.js");
-
           this.mMaxAttendees = 0;
 
           window.addEventListener("load", this.onLoad.bind(this), true);
       ]]></constructor>
 
       <method name="onLoad">
         <body><![CDATA[
             this.onInitialize();
@@ -1099,17 +1095,16 @@
             this.mRatio = val;
             this.update();
             return val;
         ]]></setter>
       </property>
 
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           this.initTimeRange();
 
           // The basedate is the date/time from which the display
           // of the timebar starts. The range is the number of days
           // we should be able to show. the start- and enddate
           // is the time the event is scheduled for.
           this.mRange = Number(this.getAttribute("range"));
--- a/calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
@@ -373,17 +373,16 @@
         ]]></setter>
         <getter><![CDATA[
             return this.mScrollOffset;
         ]]></getter>
       </property>
 
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           let args = window.arguments[0];
           let startTime = args.startTime;
           let endTime = args.endTime;
 
           this.initTimeRange();
 
           // The basedate is the date/time from which the display
@@ -609,17 +608,16 @@
             let container = document.getAnonymousElementByAttribute(this, "anonid", "container");
             container.x = offset;
             return val;
         ]]></setter>
       </property>
 
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           this.initTimeRange();
           let grid = document.getElementById("freebusy-grid");
           this.mRange = Number(grid.getAttribute("range"));
           this.onLoad();
       ]]></constructor>
 
       <method name="onLoad">
@@ -958,17 +956,16 @@
             let rowcount = this.getRowCount();
             this.scrollToIndex(Math.floor(rowcount * val));
             return val;
         ]]></setter>
       </property>
 
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           this.initTimeRange();
 
           let grid = document.getElementById("freebusy-grid");
           this.mRange = Number(grid.getAttribute("range"));
 
           this.mMaxFreeBusy = 0;
           this.mPendingRequests = [];
--- a/calendar/base/content/dialogs/calendar-event-dialog-recurrence-preview.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-recurrence-preview.xml
@@ -28,18 +28,16 @@
     </content>
 
     <implementation>
       <field name="mRecurrenceInfo">null</field>
       <field name="mResizeHandler">null</field>
       <field name="mDateTime">null</field>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
           this.mResizeHandler = this.onResize.bind(this);
           window.addEventListener("resize", this.mResizeHandler, true);
       ]]></constructor>
 
       <destructor><![CDATA[
           window.removeEventListener("resize", this.mResizeHandler, true);
       ]]></destructor>
 
--- a/calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-recurrence.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 /* exported onLoad, onAccept, onCancel */
 
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { splitRecurrenceRules } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm", null);
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gIsReadOnly = false;
 var gStartTime = null;
 var gEndTime = null;
 var gUntilDate = null;
 
 /**
@@ -497,40 +497,16 @@ function disableRecurrenceFields(aAttrib
 function enableRecurrenceFields(aAttributeName) {
     let enableElements = document.getElementsByAttribute(aAttributeName, "true");
     for (let i = 0; i < enableElements.length; i++) {
         enableElements[i].removeAttribute("disabled");
     }
 }
 
 /**
- * Split rules into negative and positive rules.
- *
- * XXX This function is duplicate from calendar-dialog-utils.js, which we may
- * want to include in this dialog.
- *
- * @param recurrenceInfo    An item's recurrence info to parse.
- * @return                  An array with two elements: an array of positive
- *                            rules and an array of negative rules.
- */
-function splitRecurrenceRules(recurrenceInfo) {
-    let recItems = recurrenceInfo.getRecurrenceItems({});
-    let rules = [];
-    let exceptions = [];
-    for (let recItem of recItems) {
-        if (recItem.isNegative) {
-            exceptions.push(recItem);
-        } else {
-            rules.push(recItem);
-        }
-    }
-    return [rules, exceptions];
-}
-
-/**
  * Handler function to update the period-deck when an item from the period-list
  * is selected. Also updates the controls on that deck.
  */
 function updateRecurrenceDeck() {
     document.getElementById("period-deck")
             .selectedIndex = Number(getElementValue("period-list"));
     updateRecurrenceControls();
 }
--- a/calendar/base/content/dialogs/calendar-event-dialog-reminder.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-reminder.js
@@ -4,17 +4,17 @@
 
 /* exported onLoad, onReminderSelected, updateReminder, onNewReminder,
  *          onRemoveReminder, onAccept, onCancel
  */
 
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var allowedActionsMap = {};
 
 /**
  * Sets up the reminder dialog.
  */
 function onLoad() {
     let calendar = window.arguments[0].calendar;
--- a/calendar/base/content/dialogs/calendar-event-dialog-timezone.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-timezone.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported onLoad, onAccept, onCancel */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Sets up the timezone dialog from the window arguments, also setting up all
  * dialog controls from the window's dates.
  */
 function onLoad() {
     let args = window.arguments[0];
     window.time = args.time;
--- a/calendar/base/content/dialogs/calendar-invitations-dialog.js
+++ b/calendar/base/content/dialogs/calendar-invitations-dialog.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
 /* exported onLoad, onUnload, onAccept, onCancel */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Sets up the invitations dialog from the window arguments, retrieves the
  * invitations from the invitations manager.
  */
 function onLoad() {
     let operationListener = {
         QueryInterface: ChromeUtils.generateQI([Ci.calIOperationListener]),
--- a/calendar/base/content/dialogs/calendar-invitations-list.xml
+++ b/calendar/base/content/dialogs/calendar-invitations-list.xml
@@ -113,17 +113,17 @@
                 this, "anonid", "icon");
             icon.setAttribute("status", val);
             return val;
         ]]></setter>
       </property>
 
       <!-- constructor -->
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
           this.mDateFormatter = cal.getDateFormatter();
       ]]></constructor>
 
       <!-- methods -->
       <method name="setCalendarItem">
         <parameter name="aItem"/>
         <body><![CDATA[
             this.mCalendarItem = aItem;
--- a/calendar/base/content/dialogs/calendar-migration-dialog.js
+++ b/calendar/base/content/dialogs/calendar-migration-dialog.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 var FIREFOX_UID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 //
 // The front-end wizard bits.
 //
 var gMigrateWizard = {
--- a/calendar/base/content/dialogs/calendar-print-dialog.js
+++ b/calendar/base/content/dialogs/calendar-print-dialog.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
 /* exported loadCalendarPrintDialog, printAndClose, onDatePick */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var printContent = "";
 
 /**
  * Gets the calendar view from the opening window
  */
 function getCalendarView() {
     let theView = window.opener.currentView();
--- a/calendar/base/content/dialogs/calendar-properties-dialog.js
+++ b/calendar/base/content/dialogs/calendar-properties-dialog.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported onLoad, onAcceptDialog, unsubscribeCalendar */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 
 /**
  * The calendar to modify, is retrieved from window.arguments[0].calendar
  */
 var gCalendar;
 
 /**
--- a/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js
+++ b/calendar/base/content/dialogs/calendar-providerUninstall-dialog.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported onLoad, onAccept, onCancel */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function onLoad() {
     let extension = window.arguments[0].extension;
     document.getElementById("provider-name-label").value = extension.name;
 
     let calendars = cal.getCalendarManager().getCalendars({})
                        .filter(x => x.providerID == extension.id);
 
--- a/calendar/base/content/dialogs/calendar-subscriptions-dialog.js
+++ b/calendar/base/content/dialogs/calendar-subscriptions-dialog.js
@@ -1,17 +1,17 @@
 /* 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/. */
 
 /* exported onLoad, onUnload, onKeyPress, onTextBoxKeyPress, onAccept,
  *          onCancel, onSubscribe, onUnsubscribe
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Cancels any pending search operations.
  */
 var gCurrentSearchOperation = null;
 function cancelPendingSearchOperation() {
     if (gCurrentSearchOperation && gCurrentSearchOperation.isPending) {
         gCurrentSearchOperation.cancel(Components.interfaces.calIErrors.OPERATION_CANCELLED);
--- a/calendar/base/content/dialogs/calendar-summary-dialog.js
+++ b/calendar/base/content/dialogs/calendar-summary-dialog.js
@@ -1,18 +1,18 @@
 /* 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/. */
 
 /* exported onLoad, onUnload, onAccept, onCancel, updatePartStat, browseDocument,
  *          sendMailToOrganizer, openAttachment, reply
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const { recurrenceRule2String } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm", null);
 
 /**
  * Sets up the summary dialog, setting all needed fields on the dialog from the
  * item received in the window arguments.
  */
 function onLoad() {
     let args = window.arguments[0];
     let item = args.calendarEvent;
--- a/calendar/base/content/dialogs/chooseCalendarDialog.js
+++ b/calendar/base/content/dialogs/chooseCalendarDialog.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 /* exported loadCalendars, doOK, doExtra1 */
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function loadCalendars() {
     const calendarManager = Components.classes["@mozilla.org/calendar/manager;1"]
                                     .getService(Components.interfaces.calICalendarManager);
     let listbox = document.getElementById("calendar-list");
     let composite = cal.view.getCompositeCalendar(window.opener);
     let selectedIndex = 0;
     let calendars;
--- a/calendar/base/content/import-export.js
+++ b/calendar/base/content/import-export.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /* exported loadEventsFromFile, exportEntireCalendar */
 
 // File constants copied from file-utils.js
 var MODE_RDONLY = 0x01;
 var MODE_WRONLY = 0x02;
 var MODE_CREATE = 0x08;
 var MODE_TRUNCATE = 0x20;
--- a/calendar/base/content/preferences/alarms.js
+++ b/calendar/base/content/preferences/alarms.js
@@ -1,15 +1,14 @@
 /* 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/. */
 
 /* exported gAlarmsPane */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Global Object to hold methods for the alarms pref pane
  */
 var gAlarmsPane = {
     /**
      * Initialize the alarms pref pane. Sets up dialog controls to match the
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported gCategoriesPane */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 var gCategoryList;
 var categoryPrefBranch = Services.prefs.getBranch("calendar.category.color.");
 
 /**
  * Global Object to hold methods for the categories pref pane
--- a/calendar/base/content/preferences/editCategory.js
+++ b/calendar/base/content/preferences/editCategory.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported editCategoryLoad, doOK, categoryNameChanged, clickColor, delay */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 // Global variable, set to true if the user has picked a custom color.
 var customColorSelected = false;
 
 /**
  * Load Handler, called when the edit category dialog is loaded
  */
 function editCategoryLoad() {
--- a/calendar/base/content/preferences/general.js
+++ b/calendar/base/content/preferences/general.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 /* exported gCalendarGeneralPane */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Global Object to hold methods for the general pref pane
  */
 var gCalendarGeneralPane = {
     /**
      * Initialize the general pref pane. Sets up dialog controls to match the
      * values set in prefs.
--- a/calendar/base/content/preferences/views.js
+++ b/calendar/base/content/preferences/views.js
@@ -19,17 +19,17 @@ var gViewsPane = {
         this.initializeViewStartEndMenus();
     },
 
     /**
      * Initialize the strings for the  "day starts at" and "day ends at"
      * menulists. This is needed to respect locales that use AM/PM.
      */
     initializeViewStartEndMenus: function() {
-        ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+        const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
         let labelIdStart;
         let labelIdEnd;
 
         let calTime = cal.createDateTime();
         calTime.minute = 0;
 
         let timeFormatter = cal.getDateFormatter();
 
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Namespace object to hold functions related to the today pane.
  */
 var TodayPane = {
     paneViews: null,
     start: null,
     cwlabel: null,
--- a/calendar/base/content/widgets/calendar-alarm-widget.xml
+++ b/calendar/base/content/widgets/calendar-alarm-widget.xml
@@ -48,20 +48,16 @@
         </xul:button>
         <xul:button anonid="alarm-dismiss-button"
                     label="&calendar.alarm.dismiss.label;"
                     oncommand="dismissAlarm()"/>
       </xul:vbox>
     </content>
 
     <implementation>
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <field name="mItem">null</field>
       <field name="mAlarm">null</field>
 
       <property name="item"
                 onget="return this.mItem;"
                 onset="this.mItem = val; this.updateLabels(); return val;"/>
       <property name="alarm"
                 onget="return this.mAlarm;"
@@ -255,17 +251,16 @@
                            class="snooze-popup-button snooze-popup-cancel-button"
                            aria-label="&calendar.alarm.snooze.cancel;"
                            oncommand="snoozeCancel()"/>
       </xul:hbox>
     </content>
     <implementation>
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           let snoozePref = Preferences.get("calendar.alarms.defaultsnoozelength", 0);
           if (snoozePref <= 0) {
               snoozePref = 5;
           }
 
           let unitList = document.getAnonymousElementByAttribute(this, "anonid", "snooze-unit-menulist");
           let unitValue = document.getAnonymousElementByAttribute(this, "anonid", "snooze-value-textbox");
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -11,20 +11,18 @@
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
   <binding id="full-calendar-list-tree" extends="#calendar-list-tree">
     <!--
       - This binding implements a full calendar list, that automatically adds
       - and removes calendars when a calendar is registered or unregistered.
       -->
     <implementation>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           let calMgr = cal.getCalendarManager();
           calMgr.addObserver(this.calMgrObserver);
-
       ]]></constructor>
       <destructor><![CDATA[
           let calMgr = cal.getCalendarManager();
           calMgr.removeObserver(this.calMgrObserver);
           this.calMgrObserver.listTree = null;
       ]]></destructor>
 
       <field name="mAddingFromComposite">false</field>
@@ -225,18 +223,16 @@
       <field name="ruleCache">null</field>
       <field name="mCachedSheet">null</field>
 
       <field name="mCycleCalendarFlag">null</field>
       <field name="mCycleTimer">null</field>
       <field name="cycleDebounce">200</field>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-          ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
           this.tree.view = this;
           this.ruleCache = {};
           this.mCycleCalendarFlag = {};
       ]]></constructor>
       <destructor><![CDATA[
           // Clean up the calendar manager observers. Do not use removeCalendar
           // here since that will remove the calendar from the composite calendar.
           for (let calendar of this.mCalendarList) {
--- a/calendar/base/content/widgets/calendar-widgets.xml
+++ b/calendar/base/content/widgets/calendar-widgets.xml
@@ -31,17 +31,16 @@
       </xul:stack>
       <xul:label class="toolbarbutton-text" crop="right" flex="1"
                  xbl:inherits="value=label,accesskey,crop,toolbarmode,buttonstyle"/>
       <xul:image class="toolbarbutton-icon-end" xbl:inherits="validate,src-end=image,toolbarmode,buttonstyle"/>
     </content>
 
     <implementation>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           this.setUpTodayDate();
       ]]></constructor>
 
       <method name="setUpTodayDate">
         <body><![CDATA[
             let dayNumber = cal.l10n.getDateFmtString(`day.${cal.dtz.now().day}.number`);
             document.getAnonymousElementByAttribute(this, "anonid", "day-label").value = dayNumber;
         ]]></body>
@@ -306,20 +305,16 @@
   <!-- This binding may server as a droptarget container for arbitrary items
        it contains methods to add DropShadows. This binding is meant to be used
        as a parent binding. The methods may be overwritten. -->
   <binding id="dragndropContainer">
     <implementation>
       <field name="mDropShadows">[]</field>
       <field name="mCalendarView">null</field>
 
-      <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-      ]]></constructor>
-
       <!-- The ViewController that supports the interface 'calICalendarView'-->
       <property name="calendarView"
                 onget="return this.mCalendarView;"
                 onset="return (this.mCalendarView = val);"/>
 
       <!-- method to add individual code e.g to set up the new item during
        'ondrop' -->
       <method name="onDropItem">
--- a/calendar/base/content/widgets/minimonth.xml
+++ b/calendar/base/content/widgets/minimonth.xml
@@ -129,17 +129,17 @@
       </xul:popupset>
     </content>
     <implementation>
       <field name="kMinimonth">null</field>
       <field name="mPopup">null</field>
       <field name="mScrollYearsHandler">null</field>
       <field name="mPixelScrollDelta">0</field>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
           this.kMinimonth = cal.view.getParentNodeOrThis(this, "minimonth");
           document.getAnonymousElementByAttribute(this, "anonid", "back-button").kMinimonth = this.kMinimonth;
           document.getAnonymousElementByAttribute(this, "anonid", "today-button").kMinimonth = this.kMinimonth;
           document.getAnonymousElementByAttribute(this, "anonid", "forward-button").kMinimonth = this.kMinimonth;
 
           this.mScrollYearsHandler = this.scrollYears.bind(this);
           document.getAnonymousElementByAttribute(this, "anonid", "years-popup")
@@ -432,17 +432,16 @@
       <field name="mPixelScrollDelta">0</field>
       <field name="mIsReadOnly">false</field>
       <field name="mObservesComposite">false</field>
       <field name="mShowWeekNumber">true</field>
 
       <constructor><![CDATA[
           ChromeUtils.import("resource://gre/modules/Services.jsm");
           ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 
           this.mToday = false;
           this.mSelected = false;
           this.mExtra = false;
           this.mValue = new Date(); // Default to "today"
           this.mFocused = null;
           // save references for convenience
           if (this.hasAttribute("readonly")) {
--- a/calendar/base/modules/calExtract.jsm
+++ b/calendar/base/modules/calExtract.jsm
@@ -1,14 +1,14 @@
 /* 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/. */
 
 this.EXPORTED_SYMBOLS = ["Extractor"];
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /**
 * Initializes extraction
 *
 * @param fallbackLocale  locale to use when others are not found or
 *                            detection is disabled
--- a/calendar/base/modules/calHashedArray.jsm
+++ b/calendar/base/modules/calHashedArray.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var EXPORTED_SYMBOLS = ["cal"]; // even though it's defined in calUtils.jsm, import needs this
 
 /**
  * An unsorted array of hashable items with some extra functions to quickly
  * retrieve the item by its hash id.
  *
  * Performance Considerations:
--- a/calendar/base/modules/calRecurrenceUtils.jsm
+++ b/calendar/base/modules/calRecurrenceUtils.jsm
@@ -1,16 +1,16 @@
 /* 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/. */
 
 /* exported recurrenceRule2String, splitRecurrenceRules, checkRecurrenceRule */
 
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["recurrenceRule2String", "splitRecurrenceRules", "checkRecurrenceRule"];
 
 /**
  * This function takes the recurrence info passed as argument and creates a
  * literal string representing the repeat pattern in natural language.
  *
  * @param recurrenceInfo    An item's recurrence info to parse.
--- a/calendar/base/modules/calUtils.jsm
+++ b/calendar/base/modules/calUtils.jsm
@@ -1,15 +1,15 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/Console.jsm");
+const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 // Usually the backend loader gets loaded via profile-after-change, but in case
 // a calendar component hooks in earlier, its very likely it will use calUtils.
 // Getting the service here will load if its not already loaded
 Components.classes["@mozilla.org/calendar/backend-loader;1"].getService();
 
 // The calendar console instance
@@ -478,10 +478,10 @@ function makeQI(aInterfaces) {
             }
         }
 
         throw Cr.NS_ERROR_NO_INTERFACE;
     };
 }
 
 // Backwards compatibility for bug 905097. Please remove with Thunderbird 61.
-ChromeUtils.import("resource://calendar/modules/calUtilsCompat.jsm");
+const { injectCalUtilsCompat } = ChromeUtils.import("resource://calendar/modules/calUtilsCompat.jsm", null);
 injectCalUtilsCompat(cal);
--- a/calendar/base/modules/shim/calAlarmUtils.jsm
+++ b/calendar/base/modules/shim/calAlarmUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calAlarmUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calAsyncUtils.jsm
+++ b/calendar/base/modules/shim/calAsyncUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calAsyncUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calAuthUtils.jsm
+++ b/calendar/base/modules/shim/calAuthUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calAuthUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calItemUtils.jsm
+++ b/calendar/base/modules/shim/calItemUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calItemUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calIteratorUtils.jsm
+++ b/calendar/base/modules/shim/calIteratorUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calIteratorUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calItipUtils.jsm
+++ b/calendar/base/modules/shim/calItipUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calItipUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calPrintUtils.jsm
+++ b/calendar/base/modules/shim/calPrintUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calPrintUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calProviderUtils.jsm
+++ b/calendar/base/modules/shim/calProviderUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calProviderUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calViewUtils.jsm
+++ b/calendar/base/modules/shim/calViewUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calViewUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/shim/calXMLUtils.jsm
+++ b/calendar/base/modules/shim/calXMLUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 Deprecated.warning("calXMLUtils.jsm must no longer be imported directly, it" +
                    " is already available via calUtils.jsm",
                    "https://bugzilla.mozilla.org/show_bug.cgi?id=905097",
                    Components.stack.caller);
--- a/calendar/base/modules/utils/calAsyncUtils.jsm
+++ b/calendar/base/modules/utils/calAsyncUtils.jsm
@@ -1,14 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 /*
  * Asynchronous tools for handling calendar operations
  */
 
 // NOTE: This module should not be loaded directly, it is available when
 // including calUtils.jsm under the cal.async namespace.
 
--- a/calendar/base/modules/utils/calEmailUtils.jsm
+++ b/calendar/base/modules/utils/calEmailUtils.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/mailServices.js");
+const { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
 /*
  * Functions for processing email addresses and sending email
  */
 
--- a/calendar/base/modules/utils/calItemUtils.jsm
+++ b/calendar/base/modules/utils/calItemUtils.jsm
@@ -1,20 +1,17 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Deprecated.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calHashedArray.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calHashedArray.jsm", null);
 
 /*
  * Calendar item related functions
  */
 
 // NOTE: This module should not be loaded directly, it is available when
 // including calUtils.jsm under the cal.item namespace.
 
--- a/calendar/base/modules/utils/calItipUtils.jsm
+++ b/calendar/base/modules/utils/calItipUtils.jsm
@@ -1,16 +1,16 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource:///modules/mailServices.js");
+const { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
 /*
  * Scheduling and iTIP helper code
  */
 
 // NOTE: This module should not be loaded directly, it is available when
--- a/calendar/base/modules/utils/calProviderUtils.jsm
+++ b/calendar/base/modules/utils/calProviderUtils.jsm
@@ -1,17 +1,17 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/mailServices.js");
+const { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+const { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 ChromeUtils.defineModuleGetter(this, "Deprecated", "resource://gre/modules/Deprecated.jsm");
 
 /*
  * Helpers and base class for calendar providers
  */
 
--- a/calendar/base/modules/utils/calUnifinderUtils.jsm
+++ b/calendar/base/modules/utils/calUnifinderUtils.jsm
@@ -1,13 +1,12 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/mailServices.js");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "cal", "resource://calendar/modules/calUtils.jsm", "cal");
 
 /*
  * Helpers for the unifinder
  */
 
--- a/calendar/base/src/calAlarm.js
+++ b/calendar/base/src/calAlarm.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var ALARM_RELATED_ABSOLUTE = Components.interfaces.calIAlarm.ALARM_RELATED_ABSOLUTE;
 var ALARM_RELATED_START = Components.interfaces.calIAlarm.ALARM_RELATED_START;
 var ALARM_RELATED_END = Components.interfaces.calIAlarm.ALARM_RELATED_END;
 
 function calAlarm() {
     this.wrappedJSObject = this;
     this.mProperties = new cal.data.PropertyMap();
--- a/calendar/base/src/calAlarmMonitor.js
+++ b/calendar/base/src/calAlarmMonitor.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 function peekAlarmWindow() {
     return Services.wm.getMostRecentWindow("Calendar:AlarmWindow");
 }
 
--- a/calendar/base/src/calAlarmService.js
+++ b/calendar/base/src/calAlarmService.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 
 var kHoursBetweenUpdates = 6;
 
 function nowUTC() {
--- a/calendar/base/src/calAttachment.js
+++ b/calendar/base/src/calAttachment.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 //
 // calAttachment.js
 //
 function calAttachment() {
     this.wrappedJSObject = this;
     this.mProperties = new cal.data.PropertyMap();
 }
--- a/calendar/base/src/calAttendee.js
+++ b/calendar/base/src/calAttendee.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calAttendee() {
     this.wrappedJSObject = this;
     this.mProperties = new cal.data.PropertyMap();
 }
 
 calAttendee.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calIAttendee]),
--- a/calendar/base/src/calCachedCalendar.js
+++ b/calendar/base/src/calCachedCalendar.js
@@ -1,15 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 var calICalendar = Components.interfaces.calICalendar;
 var cICL = Components.interfaces.calIChangeLog;
 var cIOL = Components.interfaces.calIOperationListener;
 
 var gNoOpListener = {
     QueryInterface: ChromeUtils.generateQI([Components.interfaces.calIOperationListener]),
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var REGISTRY_BRANCH = "calendar.registry.";
 var DB_SCHEMA_VERSION = 10;
 var MAX_INT = Math.pow(2, 31) - 1;
 var MIN_INT = -MAX_INT;
 
 function calCalendarManager() {
     this.wrappedJSObject = this;
--- a/calendar/base/src/calCalendarSearchService.js
+++ b/calendar/base/src/calCalendarSearchService.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calCalendarSearchListener(numOperations, finalListener) {
     this.mFinalListener = finalListener;
     this.mNumOperations = numOperations;
     this.mResults = [];
 
     this.opGroup = new cal.data.OperationGroup(() => {
         this.notifyResult(null);
--- a/calendar/base/src/calDateTimeFormatter.js
+++ b/calendar/base/src/calDateTimeFormatter.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calDateTimeFormatter() {
     this.wrappedJSObject = this;
     this.mDateStringBundle = Services.strings.createBundle("chrome://calendar/locale/dateFormat.properties");
 }
 calDateTimeFormatter.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calIDateTimeFormatter]),
     classID: Components.ID("{4123da9a-f047-42da-a7d0-cc4175b9f36a}"),
--- a/calendar/base/src/calDefaultACLManager.js
+++ b/calendar/base/src/calDefaultACLManager.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /* calDefaultACLManager */
 function calDefaultACLManager() {
     this.mCalendarEntries = {};
 }
 
 calDefaultACLManager.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calICalendarACLManager]),
--- a/calendar/base/src/calDeletedItems.js
+++ b/calendar/base/src/calDeletedItems.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
 
 /**
  * Handles remembering deleted items.
  *
  * This is (currently) not a real trashcan. Only ids and time deleted is stored.
--- a/calendar/base/src/calEvent.js
+++ b/calendar/base/src/calEvent.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 //
 // constructor
 //
 function calEvent() {
     this.initItemBase();
 
--- a/calendar/base/src/calFilter.js
+++ b/calendar/base/src/calFilter.js
@@ -1,15 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Object that contains a set of filter properties that may be used by a calFilter object
  * to filter a set of items.
  * Supported filter properties:
  *   start, end:   Specifies the relative date range to use when calculating the filter date
  *               range. The relative date range may relative to the current date and time, the
  *               currently selected date, or the dates range of the current view. The actual
--- a/calendar/base/src/calFreeBusyService.js
+++ b/calendar/base/src/calFreeBusyService.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calFreeBusyListener(numOperations, finalListener) {
     this.mFinalListener = finalListener;
     this.mNumOperations = numOperations;
 
     this.opGroup = new cal.data.OperationGroup(() => {
         this.notifyResult(null);
     });
--- a/calendar/base/src/calIcsParser.js
+++ b/calendar/base/src/calIcsParser.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 function calIcsParser() {
     this.wrappedJSObject = this;
     this.mItems = [];
     this.mParentlessItems = [];
     this.mComponents = [];
     this.mProperties = [];
--- a/calendar/base/src/calIcsSerializer.js
+++ b/calendar/base/src/calIcsSerializer.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calIcsSerializer() {
     this.wrappedJSObject = this;
     this.mItems = [];
     this.mProperties = [];
     this.mComponents = [];
 }
 calIcsSerializer.prototype = {
--- a/calendar/base/src/calItemBase.js
+++ b/calendar/base/src/calItemBase.js
@@ -1,15 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * calItemBase prototype definition
  *
  * @implements calIItemBase
  * @constructor
  */
 function calItemBase() {
--- a/calendar/base/src/calItipItem.js
+++ b/calendar/base/src/calItipItem.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Constructor of calItipItem object
  */
 function calItipItem() {
     this.wrappedJSObject = this;
     this.mCurrentItemIndex = 0;
 }
--- a/calendar/base/src/calRecurrenceDate.js
+++ b/calendar/base/src/calRecurrenceDate.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calRecurrenceDate() {
     this.wrappedJSObject = this;
 }
 
 var calRecurrenceDateClassID = Components.ID("{806b6423-3aaa-4b26-afa3-de60563e9cec}");
 var calRecurrenceDateInterfaces = [
     Components.interfaces.calIRecurrenceItem,
--- a/calendar/base/src/calRecurrenceInfo.js
+++ b/calendar/base/src/calRecurrenceInfo.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function getRidKey(date) {
     if (!date) {
         return null;
     }
     let timezone = date.timezone;
     if (!timezone.isUTC && !timezone.isFloating) {
         date = date.getInTimezone(cal.dtz.UTC);
--- a/calendar/base/src/calRelation.js
+++ b/calendar/base/src/calRelation.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * calRelation prototype definition
  *
  * @implements calIRelation
  * @constructor
  */
 function calRelation() {
--- a/calendar/base/src/calSleepMonitor.js
+++ b/calendar/base/src/calSleepMonitor.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 
 function calSleepMonitor() {
     this.wrappedJSObject = this;
 }
 
--- a/calendar/base/src/calStartupService.js
+++ b/calendar/base/src/calStartupService.js
@@ -1,13 +1,12 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
 
 /**
  * Helper function to asynchronously call a certain method on the objects passed
  * in 'services' in order (i.e wait until the first completes before calling the
  * second
  *
--- a/calendar/base/src/calTimezone.js
+++ b/calendar/base/src/calTimezone.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/ical.js");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+var { ICAL } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
 
 function calICALJSTimezone(innerObject) {
     this.innerObject = innerObject || new ICAL.Timezone();
     this.wrappedJSObject = this;
 }
 
 calICALJSTimezone.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calITimezone]),
--- a/calendar/base/src/calTimezoneService.js
+++ b/calendar/base/src/calTimezoneService.js
@@ -1,20 +1,19 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/ical.js");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+var { ICAL, unwrapSingle } = ChromeUtils.import("resource://calendar/modules/ical.js", null);
 
 function calStringEnumerator(stringArray) {
     this.mIndex = 0;
     this.mStringArray = stringArray;
 }
 calStringEnumerator.prototype = {
     // nsIUTF8StringEnumerator:
     hasMore: function() {
--- a/calendar/base/src/calTodo.js
+++ b/calendar/base/src/calTodo.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 //
 // constructor
 //
 function calTodo() {
     this.initItemBase();
 
--- a/calendar/base/src/calTransactionManager.js
+++ b/calendar/base/src/calTransactionManager.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calTransactionManager() {
     this.wrappedJSObject = this;
     if (!this.transactionManager) {
         this.transactionManager =
             Components.classes["@mozilla.org/transactionmanager;1"]
                       .createInstance(Components.interfaces.nsITransactionManager);
     }
--- a/calendar/base/src/calWeekInfoService.js
+++ b/calendar/base/src/calWeekInfoService.js
@@ -1,13 +1,12 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 function calWeekInfoService() {
     this.wrappedJSObject = this;
 }
 calWeekInfoService.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calIWeekInfoService]),
     classID: Components.ID("{6877bbdd-f336-46f5-98ce-fe86d0285cc1}"),
--- a/calendar/import-export/calHtmlExport.js
+++ b/calendar/import-export/calHtmlExport.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * HTML Export Plugin
  */
 function calHtmlExporter() {
     this.wrappedJSObject = this;
 }
 
--- a/calendar/import-export/calIcsImportExport.js
+++ b/calendar/import-export/calIcsImportExport.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * ICS Import and Export Plugin
  */
 
 // Shared functions
 function getIcsFileTypes(aCount) {
     aCount.value = 1;
--- a/calendar/import-export/calListFormatter.js
+++ b/calendar/import-export/calListFormatter.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * A thin wrapper around the html list exporter for the list print format.
  */
 function calListFormatter() {
     this.wrappedJSObject = this;
 }
 
--- a/calendar/import-export/calMonthGridPrinter.js
+++ b/calendar/import-export/calMonthGridPrinter.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Prints a rough month-grid of events/tasks
  */
 function calMonthPrinter() {
     this.wrappedJSObject = this;
 }
 
--- a/calendar/import-export/calOutlookCSVImportExport.js
+++ b/calendar/import-export/calOutlookCSVImportExport.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 var localeEn = {
     headTitle:       "Subject",
     headStartDate:   "Start Date",
     headStartTime:   "Start Time",
     headEndDate:     "End Date",
     headEndTime:     "End Time",
--- a/calendar/import-export/calWeekPrinter.js
+++ b/calendar/import-export/calWeekPrinter.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Prints a two column view of a week of events, much like a paper day-planner
  */
 function calWeekPrinter() {
     this.wrappedJSObject = this;
 }
 
--- a/calendar/itip/calItipEmailTransport.js
+++ b/calendar/itip/calItipEmailTransport.js
@@ -1,18 +1,18 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/mailServices.js");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm");
+const { ltn } = ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm", null);
 
 /**
  * Constructor of calItipEmailTransport object
  */
 function calItipEmailTransport() {
     this.wrappedJSObject = this;
     this._initEmailTransport();
 }
--- a/calendar/lightning/components/calItipProtocolHandler.js
+++ b/calendar/lightning/components/calItipProtocolHandler.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var ITIP_HANDLER_MIMETYPE = "application/x-itip-internal";
 var ITIP_HANDLER_PROTOCOL = "moz-cal-handle-itip";
 var NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
 
 
 function NYI() {
     throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
--- a/calendar/lightning/components/lightningTextCalendarConverter.js
+++ b/calendar/lightning/components/lightningTextCalendarConverter.js
@@ -1,17 +1,16 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const { ltn } = ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm", null);
 
 function ltnMimeConverter() {
     this.wrappedJSObject = this;
 }
 
 ltnMimeConverter.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.nsISimpleMimeConverter]),
     classID: Components.ID("{c70acb08-464e-4e55-899d-b2c84c5409fa}"),
--- a/calendar/lightning/content/imip-bar.js
+++ b/calendar/lightning/content/imip-bar.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const { ltn } = ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 /**
  * This bar lives inside the message window.
  * Its lifetime is the lifetime of the main thunderbird message window.
  */
 var ltnImipBar = {
 
     actionFunc: null,
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -9,23 +9,25 @@
  *          deleteAllAttachments, copyAttachment, attachmentLinkKeyPress,
  *          attachmentDblClick, attachmentClick, notifyUser,
  *          removeNotification, chooseRecentTimezone, showTimezonePopup,
  *          attendeeDblClick, attendeeClick, removeAttendee,
  *          removeAllAttendees, sendMailToUndecidedAttendees, checkUntilDate,
  *          applyValues
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
-ChromeUtils.import("resource:///modules/mailServices.js");
+const {
+    recurrenceRule2String,
+    splitRecurrenceRules,
+    checkRecurrenceRule
+} = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 try {
     ChromeUtils.import("resource:///modules/cloudFileAccounts.js");
 } catch (e) {
     // This will fail on Seamonkey, but thats ok since the pref for cloudfiles
     // is false, which means the UI will not be shown
 }
 
--- a/calendar/lightning/content/lightning-item-panel.js
+++ b/calendar/lightning/content/lightning-item-panel.js
@@ -8,30 +8,19 @@
  *          rotateShowTimeAs, editShowTimeAs, updateShowTimeAs, editToDoStatus,
  *          postponeTask, toggleTimezoneLinks, toggleLink, attachURL,
  *          onCommandViewToolbar, onCommandCustomize, attachFileByAccountKey,
  *          onUnloadLightningItemPanel, openNewEvent, openNewTask,
  *          openNewMessage, openNewCardDialog
  */
 
 // XXX Need to determine which of these we really need here.
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
-ChromeUtils.import("resource:///modules/mailServices.js");
-ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
-ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-try {
-    ChromeUtils.import("resource:///modules/cloudFileAccounts.js");
-} catch (e) {
-    // This will fail on Seamonkey, but thats ok since the pref for cloudfiles
-    // is false, which means the UI will not be shown
-}
+var { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
 
 // gTabmail is null if we are in a dialog window and not in a tab.
 var gTabmail = document.getElementById("tabmail") || null;
 
 if (!gTabmail) {
     // In a dialog window the following menu item functions need to be
     // defined.  In a tab they are defined elsewhere.  To prevent errors in
     // the log they are defined here (before the onLoad function is called).
--- a/calendar/lightning/content/lightning-utils.js
+++ b/calendar/lightning/content/lightning-utils.js
@@ -1,19 +1,19 @@
 /* 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/. */
 
 /* exported ltnInitMailIdentitiesRow, ltnGetMailIdentitySelection,
  *          ltnSaveMailIdentitySelection, ltnNotifyOnIdentitySelection
  */
 
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
-ChromeUtils.import("resource:///modules/mailServices.js");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
+var { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * Initializing the email identity row
  * (shared between calendar creation wizard and properties dialog)
  */
 function ltnInitMailIdentitiesRow() {
     if (!gCalendar) {
         collapseElement("calendar-email-identity-row");
--- a/calendar/lightning/content/messenger-overlay-sidebar.js
+++ b/calendar/lightning/content/messenger-overlay-sidebar.js
@@ -4,19 +4,18 @@
 
 /* exported refreshUIBits, switchCalendarView, rescheduleInvitationsUpdate,
  *          openInvitationsDialog, onToolbarsPopupShowingWithMode,
  *          InitViewCalendarPaneMenu, onToolbarsPopupShowingForTabType,
  *          customizeMailToolbarForTabType
  */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var gLastShownCalendarView = null;
 
 var calendarTabMonitor = {
     monitorName: "lightning",
 
     // Unused, but needed functions
     onTabTitleChanged: function() {},
--- a/calendar/lightning/modules/ltnInvitationUtils.jsm
+++ b/calendar/lightning/modules/ltnInvitationUtils.jsm
@@ -1,16 +1,16 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const { recurrenceRule2String } = ChromeUtils.import("resource://calendar/modules/calRecurrenceUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource:///modules/mailServices.js");
+const { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
 
 this.EXPORTED_SYMBOLS = ["ltn"]; /* exported ltn */
 var ltn = {};
 
 ltn.invitation = {
     /**
      * Returns a header title for an ITIP item depending on the response method
      * @param  {calItipItem}     aItipItem  the itip item to check
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -1,20 +1,20 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/Timer.jsm");
+const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 ChromeUtils.import("resource:///modules/OAuth2.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 //
 // calDavCalendar.js
 //
 
 var xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>\n';
 
 var davNS = "DAV:";
@@ -152,17 +152,17 @@ calDavCalendar.prototype = {
     get displayName() {
         return cal.l10n.getCalString("caldavName");
     },
 
     createCalendar: function() {
         throw NS_ERROR_NOT_IMPLEMENTED;
     },
 
-    deleteCalendar: function(cal, listener) {
+    deleteCalendar: function(_cal, listener) {
         throw NS_ERROR_NOT_IMPLEMENTED;
     },
 
     // calIChangeLog interface
     get offlineStorage() {
         return this.mOfflineStorage;
     },
 
--- a/calendar/providers/caldav/calDavRequestHandlers.js
+++ b/calendar/providers/caldav/calDavRequestHandlers.js
@@ -1,15 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Timer.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 
 /**
  * This is a handler for the etag request in calDavCalendar.js' getUpdatedItem.
  * It uses the SAX parser to incrementally parse the items and compose the
  * resulting multiget.
  *
--- a/calendar/providers/caldav/content/caldav-lightning-utils.js
+++ b/calendar/providers/caldav/content/caldav-lightning-utils.js
@@ -1,18 +1,16 @@
 /* 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/. */
 
 /* exported caldavInitForceEmailScheduling, caldavSaveForceEmailScheduling,
  *          caldavUpdateForceEmailSchedulingControl
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
 /**
  * Initializing calendar creation wizard and properties dialog to display the
  * option to enforce email scheduling for outgoing scheduling operations
  * (shared between calendar creation wizard and properties dialog)
  */
 function caldavInitForceEmailScheduling() {
     if (gCalendar && gCalendar.type == "caldav") {
         let checkbox = document.getElementById("force-email-scheduling");
--- a/calendar/providers/composite/calCompositeCalendar.js
+++ b/calendar/providers/composite/calCompositeCalendar.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 //
 // calCompositeCalendar.js
 //
 
 /**
  * Calendar specific utility functions
  */
--- a/calendar/providers/gdata/components/calGoogleCalendar.js
+++ b/calendar/providers/gdata/components/calGoogleCalendar.js
@@ -1,24 +1,36 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+var { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
+const { stringException } = ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm", null);
+const {
+    calGoogleRequest,
+    getCorrectedDate,
+    API_BASE
+} = ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm", null);
+const { getGoogleSessionManager } = ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm", null);
+const {
+    ItemToJSON,
+    JSONToItem,
+    ItemSaver,
+    checkResolveConflict,
+    getGoogleId,
+    getItemMetadata,
+    saveItemMetadata,
+    deleteItemMetadata,
+    migrateItemMetadata,
+    JSONToAlarm
+} = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm", null);
 
 var cIOL = Components.interfaces.calIOperationListener;
 
 var MIN_REFRESH_INTERVAL = 30;
 
 /**
  * calGoogleCalendar
  * This Implements a calICalendar Object adapted to the Google Calendar
--- a/calendar/providers/gdata/content/browserRequest.js
+++ b/calendar/providers/gdata/content/browserRequest.js
@@ -1,17 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
+var { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
 
 /* exported cancelRequest, loadRequestedUrl, reportUserClosed */
 
 var wpl = Components.interfaces.nsIWebProgressListener;
 
 var reporterListener = {
     _isBusy: false,
     get securityButton() {
--- a/calendar/providers/gdata/content/gdata-calendar-creation.js
+++ b/calendar/providers/gdata/content/gdata-calendar-creation.js
@@ -1,17 +1,15 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+var { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
+const { getGoogleSessionManager } = ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm", null);
+const { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm", null);
 
 (function() {
     function pageorder(anchor, ...pages) {
         let wizard = document.documentElement;
         let page = wizard.getPageById(anchor);
         for (let id of pages) {
             page.next = id;
             page = wizard.getPageById(id);
--- a/calendar/providers/gdata/content/gdata-event-dialog-reminder.js
+++ b/calendar/providers/gdata/content/gdata-event-dialog-reminder.js
@@ -1,18 +1,16 @@
 /* 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/. */
 
 (function() {
     const FOUR_WEEKS_BEFORE = -2419200;
-    ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-    ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
-    ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+    const { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
+    const { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm", null);
 
     // NOTE: This function exits early if its not a gdata calendar
     let item = window.arguments[0].item;
     let calendar = window.arguments[0].calendar;
     if (calendar.type != "gdata") {
         return;
     }
 
--- a/calendar/providers/gdata/content/gdata-lightning-item-iframe.js
+++ b/calendar/providers/gdata/content/gdata-lightning-item-iframe.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+const { monkeyPatch } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm", null);
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
+var { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
 
 (function() {
     monkeyPatch(window, "updateCalendar", function(protofunc, ...args) {
         let rv = protofunc.apply(this, args);
         let calendar = getCurrentCalendar();
         let isGoogleCalendar = (calendar.type == "gdata");
         let isTask = cal.item.isToDo(window.calendarItem);
         let isEvent = cal.item.isEvent(window.calendarItem);
--- a/calendar/providers/gdata/content/gdata-migration.js
+++ b/calendar/providers/gdata/content/gdata-migration.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 /* exported migrateSelectedCalendars */
 
 /**
  * Migrate the calendar selected in the wizard from ics to gdata.
  */
 function migrateSelectedCalendars() {
--- a/calendar/providers/gdata/modules/OAuth2.jsm
+++ b/calendar/providers/gdata/modules/OAuth2.jsm
@@ -3,23 +3,20 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Provides OAuth 2.0 authentication
  */
 var EXPORTED_SYMBOLS = ["OAuth2"]; /* exported OAuth2 */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource:///modules/gloda/log4moz.js");
-ChromeUtils.import("resource://gre/modules/Http.jsm");
+const { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
+const { httpRequest } = ChromeUtils.import("resource://gre/modules/Http.jsm", null);
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
+const { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
 
 function parseURLData(aData) {
     let result = {};
     aData.split(/[?#]/, 2)[1].split("&").forEach((aParam) => {
         let [key, value] = aParam.split("=");
         result[key] = value;
     });
     return result;
--- a/calendar/providers/gdata/modules/calUtilsShim.jsm
+++ b/calendar/providers/gdata/modules/calUtilsShim.jsm
@@ -1,22 +1,24 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 // calAsyncUtils and calAlarmUtils should no longer be injected directly, so first check if it is
 // already on the cal object through newer calUtils.jsm
 if (typeof cal.async == "undefined") {
-    ChromeUtils.import("resource://calendar/modules/calAsyncUtils.jsm");
+    let { cal: temp } = ChromeUtils.import("resource://calendar/modules/calAsyncUtils.jsm", null);
+    cal.async = temp.async;
 }
 if (typeof cal.alarms == "undefined") {
-    ChromeUtils.import("resource://calendar/modules/calAlarmUtils.jsm");
+    let { cal: temp } = ChromeUtils.import("resource://calendar/modules/calAlarmUtils.jsm", null);
+    cal.alarms = temp.alarms;
 }
 
 this.EXPORTED_SYMBOLS = ["cal"];
 
 if (!cal.dtz) {
     cal.dtz = {
         get defaultTimezone() { return cal.calendarDefaultTimezone(); },
         get floating() { return cal.floating(); },
@@ -86,17 +88,18 @@ if (typeof cal.window == "undefined") {
 if (typeof cal.category == "undefined") {
     cal.category = {
         stringToArray: function(aStr) { return cal.categoriesStringToArray(aStr); },
         arrayToString: function(aArr) { return cal.categoriesArrayToString(aArr); }
     };
 }
 
 if (typeof cal.itip == "undefined") {
-    ChromeUtils.import("resource://calendar/modules/calItipUtils.jsm");
+    let { cal: temp } = ChromeUtils.import("resource://calendar/modules/calItipUtils.jsm", null);
+    cal.itip = temp.itip;
 }
 
 if (typeof cal.itip.isInvitation == "undefined") {
     cal.itip.isInvitation = function(aItem) { return cal.isInvitation(aItem); };
 }
 
 if (typeof cal.l10n == "undefined") {
     cal.l10n = {
--- a/calendar/providers/gdata/modules/gdataLogging.jsm
+++ b/calendar/providers/gdata/modules/gdataLogging.jsm
@@ -1,15 +1,15 @@
 /* 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/. */
 
 var EXPORTED_SYMBOLS = ["LOGitem", "LOGverbose", "LOGinterval", "stringException"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 function LOGverbose(aStr) {
     if (Preferences.get("calendar.debug.log.verbose", false)) {
         cal.LOG(aStr);
     }
 }
 
--- a/calendar/providers/gdata/modules/gdataRequest.jsm
+++ b/calendar/providers/gdata/modules/gdataRequest.jsm
@@ -1,22 +1,17 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm");
-
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
+const { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
 
 var cIE = Components.interfaces.calIErrors;
 
 var API_BASE = {
     EVENTS: "https://www.googleapis.com/calendar/v3/",
     TASKS: "https://www.googleapis.com/tasks/v1/"
 };
 
--- a/calendar/providers/gdata/modules/gdataSession.jsm
+++ b/calendar/providers/gdata/modules/gdataSession.jsm
@@ -1,28 +1,28 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gdata-provider/modules/OAuth2.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm");
+const { getProviderString } = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm", null);
+const { LOGinterval } = ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm", null);
+const {
+    calGoogleRequest,
+    API_BASE
+} = ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm", null);
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Timer.jsm");
-
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm", null);
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
+const { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
 
 var cIFBI = Components.interfaces.calIFreeBusyInterval;
 var nIPM = Components.interfaces.nsIPermissionManager;
 
 var NOTIFY_TIMEOUT = 60 * 1000;
 
 var EXPORTED_SYMBOLS = ["getGoogleSessionManager"];
 
--- a/calendar/providers/gdata/modules/gdataUtils.jsm
+++ b/calendar/providers/gdata/modules/gdataUtils.jsm
@@ -1,23 +1,25 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/timezoneMap.jsm");
+const {
+    LOGitem,
+    LOGverbose,
+    stringException
+} = ChromeUtils.import("resource://gdata-provider/modules/gdataLogging.jsm", null);
+const { calGoogleRequest } = ChromeUtils.import("resource://gdata-provider/modules/gdataRequest.jsm", null);
+const { windowsTimezoneMap } = ChromeUtils.import("resource://gdata-provider/modules/timezoneMap.jsm", null);
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
-ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm");
+const { cal } = ChromeUtils.import("resource://gdata-provider/modules/calUtilsShim.jsm", null);
 
 var cIE = Components.interfaces.calIErrors;
 
 var FOUR_WEEKS_IN_MINUTES = 40320;
 
 var EXPORTED_SYMBOLS = [
     "ItemToJSON", "JSONToItem", "ItemSaver",
     "checkResolveConflict", "getGoogleId",
--- a/calendar/providers/ics/calICSCalendar.js
+++ b/calendar/providers/ics/calICSCalendar.js
@@ -1,17 +1,17 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 //
 // calICSCalendar.js
 //
 // This is a non-sync ics file. It reads the file pointer to by uri when set,
 // then writes it on updates. External changes to the file will be
 // ignored and overwritten.
 //
@@ -81,17 +81,17 @@ calICSCalendar.prototype = {
     get displayName() {
         return cal.l10n.getCalString("icsName");
     },
 
     createCalendar: function() {
         throw NS_ERROR_NOT_IMPLEMENTED;
     },
 
-    deleteCalendar: function(cal, listener) {
+    deleteCalendar: function(_cal, listener) {
         throw NS_ERROR_NOT_IMPLEMENTED;
     },
 
     //
     // calICalendar interface
     //
     get type() { return "ics"; },
 
--- a/calendar/providers/memory/calMemoryCalendar.js
+++ b/calendar/providers/memory/calMemoryCalendar.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 //
 // calMemoryCalendar.js
 //
 
 var cICL = Components.interfaces.calIChangeLog;
 
 function calMemoryCalendar() {
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -1,18 +1,22 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calStorageUpgrade.jsm");
-ChromeUtils.import("resource://calendar/modules/calStorageHelpers.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const {
+    DB_SCHEMA_VERSION,
+    getSqlTable,
+    upgradeDB
+} = ChromeUtils.import("resource://calendar/modules/calStorageUpgrade.jsm", null);
+const { CAL_ITEM_FLAG, newDateTime } = ChromeUtils.import("resource://calendar/modules/calStorageHelpers.jsm", null);
 
 var USECS_PER_SECOND = 1000000;
 var kCalICalendar = Components.interfaces.calICalendar;
 var cICL = Components.interfaces.calIChangeLog;
 
 //
 // calStorageCalendar
 //
--- a/calendar/providers/storage/calStorageHelpers.jsm
+++ b/calendar/providers/storage/calStorageHelpers.jsm
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /* exported CAL_ITEM_FLAG, getInUtcOrKeepFloating, dateToText, textToDate,
  *          calStorageTimezone, getTimezone, newDateTime
  */
 
 this.EXPORTED_SYMBOLS = [
     "CAL_ITEM_FLAG",
     "getInUtcOrKeepFloating",
--- a/calendar/providers/storage/calStorageUpgrade.jsm
+++ b/calendar/providers/storage/calStorageUpgrade.jsm
@@ -64,18 +64,23 @@
  *
  * If this documentation isn't sufficient to make upgrading understandable,
  * please file a bug.
  */
 
 /* exported upgradeDB */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calStorageHelpers.jsm");
+const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
+const {
+    CAL_ITEM_FLAG,
+    textToDate,
+    getTimezone,
+    newDateTime
+} = ChromeUtils.import("resource://calendar/modules/calStorageHelpers.jsm", null);
 
 // The current database version. Be sure to increment this when you create a new
 // updater.
 var DB_SCHEMA_VERSION = 22;
 
 var EXPORTED_SYMBOLS = ["DB_SCHEMA_VERSION", "getSql", "getAllSql", "getSqlTable", "upgradeDB", "backupDB"];
 
 /**
--- a/calendar/providers/wcap/calWcapCalendar.js
+++ b/calendar/providers/wcap/calWcapCalendar.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 /**
  * The calendar provider class for WCAP calendars. Usually instanciated through
  * the calendar manager, but may also be created by the wcap session, hence the
  * following optional parameters.
  *
  * @param session       (optional) The calWcapSession for this calendar
--- a/calendar/providers/wcap/calWcapCalendarItems.js
+++ b/calendar/providers/wcap/calWcapCalendarItems.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 calWcapCalendar.prototype.encodeAttendee = function(att) {
     if (LOG_LEVEL > 2) {
         log("attendee.icalProperty.icalString=" + att.icalProperty.icalString, this);
     }
     function encodeAttr(val, attr, params) {
         if (val && val.length > 0) {
             if (params.length > 0) {
--- a/calendar/providers/wcap/calWcapCalendarModule.js
+++ b/calendar/providers/wcap/calWcapCalendarModule.js
@@ -6,17 +6,17 @@
  *          calIWcapCalendar, calIWcapErrors, calICalendar, calIItemBase,
  *          calIOperationListener, calIFreeBusyProvider, calIFreeBusyInterval,
  *          calICalendarSearchProvider, calIErrors, g_privateItemTitle,
  *          g_confidentialItemTitle, g_busyItemTitle,
  *          g_busyPhantomItemUuidPrefix, CACHE_LAST_RESULTS,
  *          CACHE_LAST_RESULTS_INVALIDATE, LOG_LEVEL
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 //
 // init code for globals, prefs:
 //
 
 // constants:
--- a/calendar/providers/wcap/calWcapErrors.js
+++ b/calendar/providers/wcap/calWcapErrors.js
@@ -1,18 +1,16 @@
 /* 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/. */
 
 /* exported checkErrorCode, checkWcapXmlErrno, checkWcapIcalErrno,
  *          errorToString
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-
 var NS_ERROR_INVALID_ARG = Components.results.NS_ERROR_INVALID_ARG;
 
 //
 // Common netwerk errors:
 //
 var NS_ERROR_MODULE_BASE_OFFSET = 0x45;
 var NS_ERROR_MODULE_NETWORK = 6;
 
--- a/calendar/providers/wcap/calWcapRequest.js
+++ b/calendar/providers/wcap/calWcapRequest.js
@@ -16,17 +16,17 @@
    - some data (incl null/undefined) which is the result of the async function,
      indicating that there is no further continuation
 */
 
 /* exported issueNetworkRequest, getWcapRequestStatusString, stringToIcal, stringToXml */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function generateRequestId() {
     if (!generateRequestId.mRequestPrefix) {
         generateRequestId.mRequestPrefix = cal.getUUID() + "-";
         generateRequestId.mRequestId = 0;
     }
     ++generateRequestId.mRequestId;
     return generateRequestId.mRequestPrefix + generateRequestId.mRequestId;
--- a/calendar/providers/wcap/calWcapSession.js
+++ b/calendar/providers/wcap/calWcapSession.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* exported getWcapSessionFor */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calWcapTimezone(tzProvider, tzid_, component_) {
     this.wrappedJSObject = this;
     this.provider = tzProvider;
     this.icalComponent = component_;
     this.tzid = tzid_;
     this.isUTC = false;
     this.isFloating = false;
--- a/calendar/providers/wcap/calWcapUtils.js
+++ b/calendar/providers/wcap/calWcapUtils.js
@@ -4,17 +4,17 @@
 
 /* exported getCalendarSearchService, getDomParser, isParent, filterXmlNodes,
  *          getIcalUTC, getDatetimeFromIcalProp, getWcapString
  */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 Cu.importGlobalProperties(["DOMParser"]);
 
 var g_bShutdown = false;
 
 function initLogging() {
     initLogging.mLogTimezone = cal.dtz.defaultTimezone;
     if (initLogging.mLogFilestream) {
--- a/calendar/resources/content/calendarCreation.js
+++ b/calendar/resources/content/calendarCreation.js
@@ -2,17 +2,17 @@
  * 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/. */
 
 /* exported initLocationPage, initCustomizePage, onSelectProvider,
  *          onInitialAdvance, doCreateCalendar, setCanRewindFalse
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gCalendar;
 
 var errorConstants = {
     SUCCESS: 0,
     INVALID_URI: 1,
     ALREADY_EXISTS: 2
--- a/calendar/resources/content/datetimepickers/datetimepickers.xml
+++ b/calendar/resources/content/datetimepickers/datetimepickers.xml
@@ -54,17 +54,17 @@
     <implementation>
       <field name="mRelativeDates">[]</field>
       <field name="mDayNames">[]</field>
       <field name="mRelationWords">[]</field>
       <field name="mMonthLongNames">[]</field>
       <field name="mMonthShortNames">[]</field>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
           let goButton = document.getAnonymousElementByAttribute(this, "anonid", "date-go-button");
           goButton.setAttribute("label", cal.l10n.getCalString("go"));
           // Load the stuff we're going to use to parse written dates
           this.mRelativeDates = [
               { word: cal.l10n.getCalString("today").toLowerCase(), offset: 0 },
               { word: cal.l10n.getCalString("yesterday").toLowerCase(), offset: -1 },
               { word: cal.l10n.getCalString("tomorrow").toLowerCase(), offset: 1 }];
           for (let i = 1; i <= 7; i++) {
@@ -410,17 +410,17 @@
         </xul:menulist>
       </xul:hbox>
     </content>
 
     <implementation>
       <field name="mForeverStr">null</field>
 
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+          const { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
           this.mForeverStr = cal.l10n.getString("calendar-event-dialog", "eventRecurrenceForeverLabel");
           document.getAnonymousElementByAttribute(this, "anonid", "menuitemForever")
                   .setAttribute("label", this.mForeverStr);
       ]]></constructor>
 
       <method name="parseTextBoxDate">
         <parameter name="aRefresh"/>
@@ -1442,17 +1442,16 @@
     </handlers>
 
   </binding>
 
   <binding id="datetimepicker-base" extends="chrome://global/content/bindings/general.xml#basecontrol"
            inherits="value,onchange">
     <implementation>
       <constructor><![CDATA[
-          ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
           ChromeUtils.import("resource://gre/modules/Services.jsm");
 
           this.kTimeFormatObject = { timeStyle: "short" };
           this.initDateFormat();
           this.initTimeFormat();
       ]]></constructor>
 
       <property name="value"
--- a/calendar/resources/content/mouseoverPreviews.js
+++ b/calendar/resources/content/mouseoverPreviews.js
@@ -15,17 +15,17 @@
              getEventStatusString, getToDoStatusString */
 
 /**
  * PUBLIC: This changes the mouseover preview based on the start and end dates
  * of an occurrence of a (one-time or recurring) calEvent or calToDo.
  * Used by all grid views.
  */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 /**
  * PUBLIC: Displays a tooltip with details when hovering over an item in the views
  *
  * @param   {DOMEvent} occurrenceBoxMouseEvent  the triggering event
  * @returns {boolean}                           true, if the tooltip is displayed
  */
 function onMouseOverItem(occurrenceBoxMouseEvent) {
--- a/calendar/resources/content/publish.js
+++ b/calendar/resources/content/publish.js
@@ -1,18 +1,17 @@
 /* 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/. */
 
 /* exported publishCalendarData, publishCalendarDataDialogResponse,
  *          publishEntireCalendar, publishEntireCalendarDialogResponse
  */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * publishCalendarData
  * Show publish dialog, ask for URL and publish all selected items.
  */
 function publishCalendarData() {
     let args = {};
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyNRecurrence.js
@@ -1,17 +1,17 @@
 /* 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/. */
 
 var MODULE_NAME = "testWeeklyNRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX, CANVAS_BOX;
 var REC_DLG_ACCEPT, REC_DLG_DAYS;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
 var invokeEventDialog, viewForward, deleteCalendars, createCalendar, menulistSelect;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const HOUR = 8;
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyUntilRecurrence.js
@@ -1,17 +1,17 @@
 /* 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/. */
 
 var MODULE_NAME = "testWeeklyUntilRecurrence";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var SHORT_SLEEP, TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX;
 var CANVAS_BOX, REC_DLG_DAYS, REC_DLG_ACCEPT, REC_DLG_UNTIL_INPUT;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
 var invokeEventDialog, viewForward, deleteCalendars, createCalendar, menulistSelect;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
 const ENDDATE = new Date(2009, 0, 26); // last Monday in month
--- a/calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
+++ b/calendar/test/mozmill/cal-recurrence/testWeeklyWithExceptionRecurrence.js
@@ -8,17 +8,17 @@ var MODULE_REQUIRES = ["calendar-utils",
 
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME, EVENTPATH, EVENT_BOX;
 var CANVAS_BOX, REC_DLG_ACCEPT, REC_DLG_DAYS;
 var helpersForController, handleOccurrencePrompt, switchToView, goToDate;
 var invokeEventDialog, viewForward, deleteCalendars, createCalendar, setData;
 var menulistSelect;
 var plan_for_modal_dialog, wait_for_modal_dialog;
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 const HOUR = 8;
 const STARTDATE = new Date(2009, 0, 6);
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         TIMEOUT_MODAL_DIALOG,
--- a/calendar/test/mozmill/recurrenceRotated/testWeeklyUntilRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testWeeklyUntilRecurrence.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var switchToView, goToDate, viewForward, handleOccurrencePrompt;
 var CALENDARNAME, EVENT_BOX, CANVAS_BOX;
 
 var modalDialog = require("../shared-modules/modal-dialog");
 var utils = require("../shared-modules/utils");
 
--- a/calendar/test/mozmill/recurrenceRotated/testWeeklyWithExceptionRecurrence.js
+++ b/calendar/test/mozmill/recurrenceRotated/testWeeklyWithExceptionRecurrence.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var switchToView, goToDate, handleOccurrencePrompt;
 var CALENDARNAME, EVENT_BOX, CANVAS_BOX;
 
 var modalDialog = require("../shared-modules/modal-dialog");
 var utils = require("../shared-modules/utils");
 
--- a/calendar/test/mozmill/shared-modules/test-calendar-utils.js
+++ b/calendar/test/mozmill/shared-modules/test-calendar-utils.js
@@ -2,17 +2,17 @@
  * 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/. */
 
 var MODULE_NAME = "calendar-utils";
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["window-helpers", "folder-display-helpers", "pref-window-helpers"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 var os = {};
 ChromeUtils.import("chrome://mozmill/content/stdlib/os.js", os);
 var frame = {};
 ChromeUtils.import("chrome://mozmill/content/modules/frame.js", frame);
 var utils = {};
 ChromeUtils.import("chrome://mozmill/content/modules/utils.js", utils);
 
 var SHORT_SLEEP = 100;
--- a/calendar/test/mozmill/testAlarmDefaultValue.js
+++ b/calendar/test/mozmill/testAlarmDefaultValue.js
@@ -5,17 +5,17 @@
 /**
  * Test default alarm settings for events and tasks
  */
 
 var MODULE_NAME = "testAlarmDefaultValue";
 var RELATIVE_ROOT = "./shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "keyboard-helpers"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 const DEFVALUE = 43;
 
 var helpersForController, invokeEventDialog, openLightningPrefs, menulistSelect;
 
 function setupModule(module) {
--- a/calendar/test/mozmill/testBasicFunctionality.js
+++ b/calendar/test/mozmill/testBasicFunctionality.js
@@ -1,17 +1,17 @@
 /* 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/. */
 
 var MODULE_NAME = "testBasicFunctionality";
 var RELATIVE_ROOT = "./shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var plan_for_modal_dialog, wait_for_modal_dialog;
 var helpersForController, deleteCalendars, handleNewCalendarWizard;
 var TIMEOUT_MODAL_DIALOG, CALENDARNAME;
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({ plan_for_modal_dialog, wait_for_modal_dialog } =
--- a/calendar/test/mozmill/testLocalICS.js
+++ b/calendar/test/mozmill/testLocalICS.js
@@ -1,17 +1,16 @@
 /* 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/. */
 
 var MODULE_NAME = "testLocalICS";
 var RELATIVE_ROOT = "./shared-modules";
 var MODULE_REQUIRES = ["calendar-utils", "window-helpers"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var plan_for_modal_dialog, wait_for_modal_dialog;
 var helpersForController, invokeEventDialog, switchToView, deleteCalendars;
 var handleNewCalendarWizard, setData;
 var CANVAS_BOX, EVENT_BOX, TIMEOUT_MODAL_DIALOG;
 
 const HOUR = 8;
--- a/calendar/test/mozmill/testTodayPane.js
+++ b/calendar/test/mozmill/testTodayPane.js
@@ -4,17 +4,17 @@
 
 var MODULE_NAME = "testTodayPane";
 var RELATIVE_ROOT = "./shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var CALENDARNAME;
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function setupModule(module) {
     controller = mozmill.getMail3PaneController();
     ({
         helpersForController,
         invokeEventDialog,
         createCalendar,
         deleteCalendars,
--- a/calendar/test/mozmill/views/testDayView.js
+++ b/calendar/test/mozmill/views/testDayView.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var CALENDARNAME;
 
 var TITLE1 = "Day View Event";
 var TITLE2 = "Day View Event Changed";
 var DESC = "Day View Event Description";
 
--- a/calendar/test/mozmill/views/testMonthView.js
+++ b/calendar/test/mozmill/views/testMonthView.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var CALENDARNAME;
 
 var TITLE1 = "Month View Event";
 var TITLE2 = "Month View Event Changed";
 var DESC = "Month View Event Description";
 
--- a/calendar/test/mozmill/views/testMultiweekView.js
+++ b/calendar/test/mozmill/views/testMultiweekView.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var CALENDARNAME;
 
 var TITLE1 = "Multiweek View Event";
 var TITLE2 = "Multiweek View Event Changed";
 var DESC = "Multiweek View Event Description";
 
--- a/calendar/test/mozmill/views/testWeekView.js
+++ b/calendar/test/mozmill/views/testWeekView.js
@@ -1,16 +1,16 @@
 /* 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/. */
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["calendar-utils"];
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 var helpersForController, invokeEventDialog, createCalendar, deleteCalendars;
 var CALENDARNAME;
 
 var TITLE1 = "Week View Event";
 var TITLE2 = "Week View Event Changed";
 var DESC = "Week View Event Description";
 
--- a/calendar/test/unit/head_consts.js
+++ b/calendar/test/unit/head_consts.js
@@ -42,17 +42,17 @@ updateAppInfo();
         manager.addLegacyExtensionManifestLocation(bindir);
     }
 
     // Make sure to load the backend loader as early as possible, as xpcshell doesn't have the
     // normal app flow with profile-after-change et al.
     Components.classes["@mozilla.org/calendar/backend-loader;1"].getService();
 })();
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function createDate(aYear, aMonth, aDay, aHasTime, aHour, aMinute, aSecond, aTimezone) {
     let date = Cc["@mozilla.org/calendar/datetime;1"]
                .createInstance(Ci.calIDateTime);
     date.resetTo(aYear,
                aMonth,
                aDay,
                aHour || 0,
--- a/calendar/test/unit/test_alarmservice.js
+++ b/calendar/test/unit/test_alarmservice.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var EXPECT_NONE = 0;
 var EXPECT_FIRED = 1;
 var EXPECT_TIMER = 2;
 
 function do_check_xor(a, b, aMessage) { return ok((a && !b) || (!a && b), aMessage); }
 
 var alarmObserver = {
--- a/calendar/test/unit/test_alarmutils.js
+++ b/calendar/test/unit/test_alarmutils.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function run_test() {
     do_calendar_startup(run_next_test);
 }
 
 add_task(async function test_setDefaultValues_events() {
     let item, alarm;
 
--- a/calendar/test/unit/test_attachment.js
+++ b/calendar/test/unit/test_attachment.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function run_test() {
     test_serialize();
     test_hashes();
     test_uriattach();
     test_binaryattach();
 }
 
--- a/calendar/test/unit/test_attendee.js
+++ b/calendar/test/unit/test_attendee.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 
 function run_test() {
     test_values();
     test_serialize();
     test_properties();
     test_doubleParameters(); // Bug 875739
 }
 
--- a/calendar/test/unit/test_bug1199942.js
+++ b/calendar/test/unit/test_bug1199942.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function run_test() {
     // Test the graceful handling of attendee ids for bug 1199942
     createAttendee_test();
     serializeEvent_test();
 }
 
 function createAttendee_test() {
--- a/calendar/test/unit/test_bug1204255.js
+++ b/calendar/test/unit/test_bug1204255.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function run_test() {
     // Test attendee duplicate handling for bug 1204255
     test_newAttendee();
     test_fromICS();
 }
 
 function test_newAttendee() {
--- a/calendar/test/unit/test_bug1209399.js
+++ b/calendar/test/unit/test_bug1209399.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function run_test() {
     // Test handling for multiple double quotes leading/trailing to attendee CN for bug 1209399
     test_newAttendee();
     test_fromICS();
 }
 
 function test_newAttendee() {
--- a/calendar/test/unit/test_bug523860.js
+++ b/calendar/test/unit/test_bug523860.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function run_test() {
     // In bug 523860, we found out that in the spec doublequotes should not be
     // escaped.
     let prop = cal.getIcsService().createIcalProperty("DESCRIPTION");
     let expected = "A String with \"quotes\" and 'other quotes'";
 
     prop.value = expected;
--- a/calendar/test/unit/test_bug653924.js
+++ b/calendar/test/unit/test_bug653924.js
@@ -3,11 +3,11 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function run_test() {
     let evt = cal.createEvent();
     let rel = cal.createRelation();
     evt.addRelation(rel);
 
     equal(1, evt.icalString.match(/RELATED-TO/g).length);
-    evt.icalString = evt.icalString;
+    evt.icalString = evt.icalString; // eslint-disable-line no-self-assign
     equal(1, evt.icalString.match(/RELATED-TO/g).length);
 }
--- a/calendar/test/unit/test_bug668222.js
+++ b/calendar/test/unit/test_bug668222.js
@@ -7,16 +7,16 @@ function run_test() {
     attendee.id = "mailto:somebody";
 
     // Set the property and make sure its there
     attendee.setProperty("SCHEDULE-AGENT", "CLIENT");
     equal(attendee.getProperty("SCHEDULE-AGENT"), "CLIENT");
 
     // Reserialize the property, this has caused the property to go away
     // in the past.
-    attendee.icalProperty = attendee.icalProperty;
+    attendee.icalProperty = attendee.icalProperty; // eslint-disable-line no-self-assign
     equal(attendee.getProperty("SCHEDULE-AGENT"), "CLIENT");
 
     // 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.includes("RSVP"));
 }
--- a/calendar/test/unit/test_calmgr.js
+++ b/calendar/test/unit/test_calmgr.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 /**
  * Tests the calICalendarManager interface
  */
 function run_test() {
     do_calendar_startup(run_next_test);
 }
--- a/calendar/test/unit/test_extract.js
+++ b/calendar/test/unit/test_extract.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calExtract.jsm");
+const { Extractor } = ChromeUtils.import("resource://calendar/modules/calExtract.jsm", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 var extractor = new Extractor("en-US", 8);
 
 function run_test() {
     // Sanity check to make sure the base url is still right. If this fails,
     // don't forget to also fix the url in base/content/calendar-extract.js.
     ok(extractor.checkBundle("en-US"));
--- a/calendar/test/unit/test_freebusy_service.js
+++ b/calendar/test/unit/test_freebusy_service.js
@@ -1,14 +1,12 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 var cIFI = Components.interfaces.calIFreeBusyInterval;
 var freebusy = Components.classes["@mozilla.org/calendar/freebusy-service;1"]
                          .getService(Components.interfaces.calIFreeBusyService);
 
 function run_test() {
     do_calendar_startup(really_run_test);
 }
 
--- a/calendar/test/unit/test_gdata_provider.js
+++ b/calendar/test/unit/test_gdata_provider.js
@@ -20,23 +20,26 @@
         xpiFile.append("{a62ef8ec-5fdc-40c2-873c-223b8a6925cc}");
     }
 
     dump("Loading " + xpiFile.path + "\n");
     let manager = Cc["@mozilla.org/component-manager-extra;1"].getService(Ci.nsIComponentManagerExtra);
     manager.addLegacyExtensionManifestLocation(xpiFile);
 })();
 
-ChromeUtils.import("resource://testing-common/httpd.js");
+const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js", null);
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
-ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm");
-ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm");
+const { getGoogleSessionManager } = ChromeUtils.import("resource://gdata-provider/modules/gdataSession.jsm", null);
+const {
+    dateToJSON,
+    JSONToDate,
+    monkeyPatch
+} = ChromeUtils.import("resource://gdata-provider/modules/gdataUtils.jsm", null);
 ChromeUtils.import("resource://testing-common/MockRegistrar.jsm");
 
 var gServer;
 
 var MockConflictPrompt = {
     _origFunc: null,
     overwrite: false,
     register: function() {
--- a/calendar/test/unit/test_hashedarray.js
+++ b/calendar/test/unit/test_hashedarray.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calHashedArray.jsm");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calHashedArray.jsm", null);
 
 function run_test() {
     test_array_base();
     test_array_sorted();
     test_hashAccessor();
 }
 
 /**
--- a/calendar/test/unit/test_items.js
+++ b/calendar/test/unit/test_items.js
@@ -1,14 +1,12 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 function run_test() {
     do_calendar_startup(really_run_test);
 }
 
 function really_run_test() {
     test_aclmanager();
     test_calendar();
     test_immutable();
--- a/calendar/test/unit/test_itip_utils.js
+++ b/calendar/test/unit/test_itip_utils.js
@@ -1,14 +1,13 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
-ChromeUtils.import("resource://testing-common/mailnews/mailTestUtils.js");
+var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 // tests for calItipUtils.jsm
 
 function run_test() {
     test_getMessageSender();
     test_getSequence();
     test_getStamp();
     test_compareSequence();
--- a/calendar/test/unit/test_ltninvitationutils.js
+++ b/calendar/test/unit/test_ltninvitationutils.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm");
-ChromeUtils.import("resource:///modules/mailServices.js");
+const { ltn } = ChromeUtils.import("resource://calendar/modules/ltnInvitationUtils.jsm", null);
+var { MailServices } = ChromeUtils.import("resource:///modules/mailServices.js", null);
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 
 function run_test() {
     do_calendar_startup(run_next_test);
 }
 
 // tests for ltnInvitationUtils.jsm
 
--- a/calendar/test/unit/test_search_service.js
+++ b/calendar/test/unit/test_search_service.js
@@ -1,14 +1,12 @@
 /* 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/. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 var HINT_EXACT_MATCH = Components.interfaces.calICalendarSearchProvider.HINT_EXACT_MATCH;
 var search = Components.classes["@mozilla.org/calendar/calendarsearch-service;1"]
                        .getService(Components.interfaces.calICalendarSearchService);
 
 function run_test() {
     test_found();
     test_failure();
     test_cancel();
--- a/calendar/test/unit/test_webcal.js
+++ b/calendar/test/unit/test_webcal.js
@@ -1,15 +1,15 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
-ChromeUtils.import("resource://testing-common/httpd.js");
+const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js", null);
 
 function run_test() {
     let httpserv = new HttpServer();
     httpserv.registerPrefixHandler("/", {
         handle: function(request, response) {
             response.setStatusLine(request.httpVersion, 200, "OK");
             equal(request.path, "/test_webcal");
         }
--- a/common/src/Overlays.jsm
+++ b/common/src/Overlays.jsm
@@ -5,18 +5,17 @@
 /**
  * Load overlays in a similar way as XUL did for legacy XUL add-ons.
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["Overlays"];
 
-ChromeUtils.import("resource://gre/modules/Console.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm", null);
 ChromeUtils.defineModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
 ChromeUtils.defineModuleGetter(this, "setTimeout", "resource://gre/modules/Timer.jsm");
 
 Cu.importGlobalProperties(["XMLHttpRequest"]);
 
 let oconsole = new ConsoleAPI({
   prefix: "Overlays.jsm",
   consoleID: "overlays-jsm",
--- a/common/src/customizeToolbar.js
+++ b/common/src/customizeToolbar.js
@@ -543,17 +543,17 @@ function updateIconSize(aSize) {
 }
 
 function updateTitlebar() {
   let titlebarCheckbox = document.getElementById("showTitlebar");
   Services.prefs.setBoolPref("mail.tabs.drawInTitlebar", !titlebarCheckbox.checked);
 
   // Bring the customizeToolbar window to front (on linux it's behind the main
   // window). Otherwise the customization window gets left in the background.
-  setTimeout(function() { window.focus() }, 100);
+  setTimeout(() => window.focus(), 100);
 }
 
 function updateToolbarMode(aModeValue) {
   var mode = updateToolboxProperty("mode", aModeValue, "icons");
 
   var iconSizeCheckbox = document.getElementById("smallicons");
   iconSizeCheckbox.disabled = mode == "text";
 
--- a/common/src/extensionSupport.jsm
+++ b/common/src/extensionSupport.jsm
@@ -8,17 +8,17 @@
  */
 
 this.EXPORTED_SYMBOLS = [ "extensionDefaults", "ExtensionSupport" ];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 // ChromeUtils.import("resource://gre/modules/Deprecated.jsm") - needed for warning.
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 ChromeUtils.import("resource:///modules/IOUtils.js");
 
 var extensionHooks = new Map();
 var openWindowList;
 
 /**
  * Reads preferences from addon provided locations (defaults/preferences/*.js)
  * and stores them in the default preferences branch.