Migrate remaining toolkit/modules/*.jsm files to ES modules. draft
authorMark Banner <standard8@mozilla.com>
Thu, 29 Sep 2022 09:10:55 +0100
changeset 4682706 e34998793859ef0c7b9195d77e39f7fd1e557023
parent 4682705 a03acc7de0696f4a92302e0d2b658df28cf20891
child 4682707 bd791b07a9bc6789b2293b7d3b04e142016eb326
push id858555
push usermbanner@mozilla.com
push dateThu, 29 Sep 2022 09:15:37 +0000
treeherdertry@2112404a6c9e [default view] [failures only]
milestone107.0a1
Migrate remaining toolkit/modules/*.jsm files to ES modules.
browser/base/content/test/performance/browser_startup.js
browser/base/content/test/performance/browser_startup_content.js
browser/components/newtab/docs/v2-system-addon/preferences.md
dom/docs/ipc/jsactors.rst
toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js
toolkit/modules/ActorManagerParent.jsm
toolkit/modules/ActorManagerParent.sys.mjs
toolkit/modules/Console.jsm
toolkit/modules/Console.sys.mjs
toolkit/modules/ContentDOMReference.jsm
toolkit/modules/ContentDOMReference.sys.mjs
toolkit/modules/DeferredTask.jsm
toolkit/modules/DeferredTask.sys.mjs
toolkit/modules/Deprecated.jsm
toolkit/modules/Deprecated.sys.mjs
toolkit/modules/E10SUtils.jsm
toolkit/modules/E10SUtils.sys.mjs
toolkit/modules/EventEmitter.jsm
toolkit/modules/EventEmitter.sys.mjs
toolkit/modules/Preferences.jsm
toolkit/modules/Preferences.sys.mjs
toolkit/modules/PrivateBrowsingUtils.jsm
toolkit/modules/PrivateBrowsingUtils.sys.mjs
toolkit/modules/Timer.jsm
toolkit/modules/Timer.sys.mjs
toolkit/modules/WebChannel.jsm
toolkit/modules/WebChannel.sys.mjs
toolkit/modules/moz.build
--- a/browser/base/content/test/performance/browser_startup.js
+++ b/browser/base/content/test/performance/browser_startup.js
@@ -26,17 +26,17 @@ const startupPhases = {
   // Consider loading your code after first paint instead,
   // eg. from BrowserGlue.jsm' _onFirstWindowLoaded method).
   "before profile selection": {
     allowlist: {
       modules: new Set([
         "resource:///modules/BrowserGlue.jsm",
         "resource:///modules/StartupRecorder.jsm",
         "resource://gre/modules/AppConstants.sys.mjs",
-        "resource://gre/modules/ActorManagerParent.jsm",
+        "resource://gre/modules/ActorManagerParent.sys.mjs",
         "resource://gre/modules/CustomElementsListener.jsm",
         "resource://gre/modules/MainProcessSingleton.jsm",
         "resource://gre/modules/XPCOMUtils.sys.mjs",
       ]),
     },
   },
 
   // For the following phases of startup we have only a list of files that
@@ -58,17 +58,17 @@ const startupPhases = {
       modules: new Set([
         "resource:///modules/AboutNewTab.jsm",
         "resource:///modules/BrowserUsageTelemetry.jsm",
         "resource:///modules/ContentCrashHandlers.jsm",
         "resource:///modules/ShellService.jsm",
         "resource://gre/modules/NewTabUtils.sys.mjs",
         "resource://gre/modules/PageThumbs.jsm",
         "resource://gre/modules/PlacesUtils.sys.mjs",
-        "resource://gre/modules/Preferences.jsm",
+        "resource://gre/modules/Preferences.sys.mjs",
         "resource://gre/modules/SearchService.sys.mjs",
         "resource://gre/modules/Sqlite.sys.mjs",
       ]),
       services: new Set(["@mozilla.org/browser/search-service;1"]),
     },
   },
 
   // We are at this phase once we are ready to handle user events.
--- a/browser/base/content/test/performance/browser_startup_content.js
+++ b/browser/base/content/test/performance/browser_startup_content.js
@@ -20,17 +20,17 @@ const kDumpAllStacks = false;
 
 const known_scripts = {
   modules: new Set([
     "chrome://mochikit/content/ShutdownLeaksCollector.jsm",
 
     // General utilities
     "resource://gre/modules/AppConstants.sys.mjs",
     "resource://gre/modules/DeferredTask.jsm",
-    "resource://gre/modules/Timer.jsm",
+    "resource://gre/modules/Timer.sys.mjs",
     "resource://gre/modules/XPCOMUtils.sys.mjs",
 
     // Logging related
     "resource://gre/modules/Log.sys.mjs",
 
     // Browser front-end
     "resource:///actors/AboutReaderChild.sys.mjs",
     "resource:///actors/BrowserTabChild.sys.mjs",
--- a/browser/components/newtab/docs/v2-system-addon/preferences.md
+++ b/browser/components/newtab/docs/v2-system-addon/preferences.md
@@ -69,17 +69,17 @@ prefs.set("foo", true)
 
 // This will call aCallback when browser.newtabpage.activity-stream.foo is changed
 prefs.observe("foo", aCallback);
 
 // This will stop listening to browser.newtabpage.activity-stream.foo
 prefs.ignore("foo", aCallback);
 ```
 
-See [toolkit/modules/Preferences.jsm](https://searchfox.mozilla.org/mozilla-central/source/toolkit/modules/Preferences.jsm)
+See :searchfox:`toolkit/modules/Preferences.sys.mjs <source/toolkit/modules/Preferences.sys.mjs>`
 for more information about what methods are available.
 
 ## Discovery Stream Preferences
 
 Preferences specific to the Discovery Stream are nested under the sub-branch `browser.newtabpage.activity-stream.discoverystream` (with the exception of `browser.newtabpage.blocked`).
 
 #### `browser.newtabpage.activity-stream.discoverystream.flight.blocks`
 
--- a/dom/docs/ipc/jsactors.rst
+++ b/dom/docs/ipc/jsactors.rst
@@ -266,17 +266,17 @@ How to port from message manager and fra
 
 .. _fission.message-manager-actors:
 
 Message Manager Actors
 ~~~~~~~~~~~~~~~~~~~~~~
 
 While the JSWindowActor mechanism was being designed and developed, large sections of our framescripts were converted to an "actor style" pattern to make eventual porting to JSWindowActors easier. These Actors use the Message Manager under the hood, but made it much easier to shrink our framescripts, and also allowed us to gain significant memory savings by having the actors be lazily instantiated.
 
-You can find the list of Message Manager Actors (or "Legacy Actors") in `BrowserGlue.jsm <https://searchfox.org/mozilla-central/source/browser/components/BrowserGlue.jsm>`_ and `ActorManagerParent.jsm <https://searchfox.org/mozilla-central/source/toolkit/modules/ActorManagerParent.jsm>`_, in the ``LEGACY_ACTORS`` lists.
+You can find the list of Message Manager Actors (or "Legacy Actors") in :searchfox:`BrowserGlue.jsm <browser/components/BrowserGlue.jsm>`_ and :searchfox:`ActorManagerParent.sys.mjs <toolkit/modules/ActorManagerParent.sys.mjs>`_, in the ``LEGACY_ACTORS`` lists.
 
 .. note::
   The split in Message Manager Actors defined between ``BrowserGlue`` and ``ActorManagerParent`` is mainly to keep Firefox Desktop specific Actors separate from Actors that can (in theory) be instantiated for non-Desktop browsers (like Fennec and GeckoView-based browsers). Firefox Desktop-specific Actors should be registered in ``BrowserGlue``. Shared "toolkit" Actors should go into ``ActorManagerParent``.
 
 "Porting" these Actors often means doing what is necessary in order to move their registration entries from ``LEGACY_ACTORS`` to the ``JSWINDOWACTORS`` list.
 
 Figuring out the lifetime of a new Actor pair
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- a/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js
+++ b/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js
@@ -27,17 +27,17 @@ const MAC = AppConstants.platform == "ma
 
 const backgroundtaskPhases = {
   AfterRunBackgroundTaskNamed: {
     allowlist: {
       modules: [
         "resource://gre/modules/AppConstants.jsm",
         "resource://gre/modules/AsyncShutdown.jsm",
         "resource://gre/modules/BackgroundTasksManager.jsm",
-        "resource://gre/modules/Console.jsm",
+        "resource://gre/modules/Console.sys.mjs",
         "resource://gre/modules/EnterprisePolicies.sys.mjs",
         "resource://gre/modules/EnterprisePoliciesParent.sys.mjs",
         "resource://gre/modules/PromiseUtils.sys.mjs",
         "resource://gre/modules/XPCOMUtils.sys.mjs",
         "resource://gre/modules/nsAsyncShutdown.jsm",
       ],
       // Human-readable contract IDs are many-to-one mapped to CIDs, so this
       // list is a little misleading.  For example, all of
rename from toolkit/modules/ActorManagerParent.jsm
rename to toolkit/modules/ActorManagerParent.sys.mjs
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.sys.mjs
@@ -1,27 +1,21 @@
 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
 /* 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/. */
-"use strict";
 
 /**
  * This module handles JavaScript-implemented JSWindowActors, registered through DOM IPC
  * infrastructure, and are fission-compatible.
  */
 
-var EXPORTED_SYMBOLS = ["ActorManagerParent"];
+import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
 
-const { XPCOMUtils } = ChromeUtils.importESModule(
-  "resource://gre/modules/XPCOMUtils.sys.mjs"
-);
-const { AppConstants } = ChromeUtils.importESModule(
-  "resource://gre/modules/AppConstants.sys.mjs"
-);
+import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
 
 /**
  * Fission-compatible JSProcess implementations.
  * Each actor options object takes the form of a ProcessActorOptions dictionary.
  * Detailed documentation of these options is in dom/docs/ipc/jsactors.rst,
  * available at https://firefox-source-docs.mozilla.org/dom/ipc/jsactors.html
  */
 let JSPROCESSACTORS = {
@@ -546,17 +540,17 @@ if (AppConstants.platform != "android") 
       },
     },
 
     includeChrome: true,
     allFrames: true,
   };
 }
 
-var ActorManagerParent = {
+export var ActorManagerParent = {
   _addActors(actors, kind) {
     let register, unregister;
     switch (kind) {
       case "JSProcessActor":
         register = ChromeUtils.registerProcessActor;
         unregister = ChromeUtils.unregisterProcessActor;
         break;
       case "JSWindowActor":
rename from toolkit/modules/Console.jsm
rename to toolkit/modules/Console.sys.mjs
--- a/toolkit/modules/Console.jsm
+++ b/toolkit/modules/Console.sys.mjs
@@ -1,32 +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/. */
 
-"use strict";
-
 /**
  * Define a 'console' API to roughly match the implementation provided by
  * Firebug.
  * This module helps cases where code is shared between the web and Firefox.
  * See also Browser.jsm for an implementation of other web constants to help
  * sharing code between the web and firefox;
  *
  * The API is only be a rough approximation for 3 reasons:
  * - The Firebug console API is implemented in many places with differences in
  *   the implementations, so there isn't a single reference to adhere to
  * - The Firebug console is a rich display compared with dump(), so there will
  *   be many things that we can't replicate
  * - The primary use of this API is debugging and error logging so the perfect
  *   implementation isn't always required (or even well defined)
  */
 
-var EXPORTED_SYMBOLS = ["console", "ConsoleAPI"];
-
 var gTimerRegistry = new Map();
 
 /**
  * String utility to ensure that strings are a specified length. Strings
  * that are too long are truncated to the max length and the last char is
  * set to "_". Strings that are too short are padded with spaces.
  *
  * @param {string} aStr
@@ -605,17 +601,17 @@ function sendConsoleAPIMessage(aConsole,
  *                            written to stdout
  *        - innerID {string}: An ID representing the source of the message.
  *                            Normally the inner ID of a DOM window.
  *        - consoleID {string} : String identified for the console, this will
  *                            be passed through the console notifications
  * @return {object}
  *        A console API instance object
  */
-function ConsoleAPI(aConsoleOptions = {}) {
+export function ConsoleAPI(aConsoleOptions = {}) {
   // Normalize console options to set default values
   // in order to avoid runtime checks on each console method call.
   this.dump = aConsoleOptions.dump || dump;
   this.prefix = aConsoleOptions.prefix || "";
   this.maxLogLevel = aConsoleOptions.maxLogLevel;
   this.innerID = aConsoleOptions.innerID || null;
   this.consoleID = aConsoleOptions.consoleID || "";
 
@@ -751,9 +747,9 @@ ConsoleAPI.prototype = {
     this._maxLogLevel = this._maxExplicitLogLevel = aValue;
   },
 
   shouldLog(aLevel) {
     return shouldLog(aLevel, this.maxLogLevel);
   },
 };
 
-var console = new ConsoleAPI();
+export var console = new ConsoleAPI();
rename from toolkit/modules/ContentDOMReference.jsm
rename to toolkit/modules/ContentDOMReference.sys.mjs
--- a/toolkit/modules/ContentDOMReference.jsm
+++ b/toolkit/modules/ContentDOMReference.sys.mjs
@@ -9,21 +9,17 @@
  * passed between processes. The identifer, if received by the same content process
  * that issued it, can then be converted back into the DOM element (presuming the
  * element hasn't had all of its other references dropped).
  *
  * The hope is that this module can eliminate the need for passing CPOW references
  * between processes during runtime.
  */
 
-var EXPORTED_SYMBOLS = ["ContentDOMReference"];
-
-const { XPCOMUtils } = ChromeUtils.importESModule(
-  "resource://gre/modules/XPCOMUtils.sys.mjs"
-);
+import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
 
 const lazy = {};
 
 XPCOMUtils.defineLazyServiceGetter(
   lazy,
   "finalizationService",
   "@mozilla.org/toolkit/finalizationwitness;1",
   "nsIFinalizationWitnessService"
@@ -50,17 +46,17 @@ const finalizerRoots = new WeakMap();
  *   IDToElement:
  *     A Map of IDs to WeakReference's to the elements they refer to.
  *
  *   elementToID:
  *     A WeakMap from a DOM element to an ID that refers to it.
  */
 var gRegistry = new WeakMap();
 
-var ContentDOMReference = {
+export var ContentDOMReference = {
   _init() {
     Services.obs.addObserver(this, FINALIZATION_TOPIC);
   },
 
   observe(subject, topic, data) {
     if (topic !== FINALIZATION_TOPIC) {
       throw new Error("Unexpected observer topic");
     }
rename from toolkit/modules/DeferredTask.jsm
rename to toolkit/modules/DeferredTask.sys.mjs
--- a/toolkit/modules/DeferredTask.jsm
+++ b/toolkit/modules/DeferredTask.sys.mjs
@@ -1,18 +1,14 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* 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/. */
 
-"use strict";
-
-var EXPORTED_SYMBOLS = ["DeferredTask"];
-
 const lazy = {};
 
 /**
  * Sets up a function or an asynchronous task whose execution can be triggered
  * after a defined delay.  Multiple attempts to run the task before the delay
  * has passed are coalesced.  The task cannot be re-entered while running, but
  * can be executed again after a previous run finished.
  *
@@ -109,17 +105,17 @@ const Timer = Components.Constructor(
  *        inactivity is guaranteed to pass between multiple executions of the
  *        task, except on finalization, when the task may restart immediately
  *        after the previous execution finished.
  * @param aIdleTimeoutMs
  *        The maximum time to wait for an idle slot on the main thread after
  *        aDelayMs have elapsed. If omitted, waits indefinitely for an idle
  *        callback.
  */
-var DeferredTask = function(aTaskFn, aDelayMs, aIdleTimeoutMs) {
+export var DeferredTask = function(aTaskFn, aDelayMs, aIdleTimeoutMs) {
   this._taskFn = aTaskFn;
   this._delayMs = aDelayMs;
   this._timeoutMs = aIdleTimeoutMs;
   this._caller = new Error().stack.split("\n", 2)[1];
   let markerString = `delay: ${aDelayMs}ms`;
   if (aIdleTimeoutMs) {
     markerString += `, idle timeout: ${aIdleTimeoutMs}`;
   }
rename from toolkit/modules/Deprecated.jsm
rename to toolkit/modules/Deprecated.sys.mjs
--- a/toolkit/modules/Deprecated.jsm
+++ b/toolkit/modules/Deprecated.sys.mjs
@@ -1,16 +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/. */
 
-"use strict";
-
-var EXPORTED_SYMBOLS = ["Deprecated"];
-
 const PREF_DEPRECATION_WARNINGS = "devtools.errorconsole.deprecation_warnings";
 
 // A flag that indicates whether deprecation warnings should be logged.
 var logWarnings = Services.prefs.getBoolPref(PREF_DEPRECATION_WARNINGS);
 
 Services.prefs.addObserver(PREF_DEPRECATION_WARNINGS, function(
   aSubject,
   aTopic,
@@ -38,17 +34,17 @@ function stringifyCallstack(aStack) {
     if (frame.filename || frame.lineNumber || frame.name) {
       msg += frame.filename + " " + frame.lineNumber + " " + frame.name + "\n";
     }
     frame = frame.caller;
   }
   return msg;
 }
 
-var Deprecated = {
+export var Deprecated = {
   /**
    * Log a deprecation warning.
    *
    * @param string aText
    *        Deprecation warning text.
    * @param string aUrl
    *        A URL pointing to documentation describing deprecation
    *        and the way to address it.
rename from toolkit/modules/E10SUtils.jsm
rename to toolkit/modules/E10SUtils.sys.mjs
--- a/toolkit/modules/E10SUtils.jsm
+++ b/toolkit/modules/E10SUtils.sys.mjs
@@ -1,19 +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/. */
 
-"use strict";
-
-var EXPORTED_SYMBOLS = ["E10SUtils"];
-
-const { XPCOMUtils } = ChromeUtils.importESModule(
-  "resource://gre/modules/XPCOMUtils.sys.mjs"
-);
+import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
 
 const lazy = {};
 
 XPCOMUtils.defineLazyPreferenceGetter(
   lazy,
   "useSeparateFileUriProcess",
   "browser.tabs.remote.separateFileUriProcess",
   false
@@ -264,17 +258,17 @@ function validatedWebRemoteType(
 }
 
 // remoteTypes allowed to host system-principal remote workers.
 const SYSTEM_WORKERS_REMOTE_TYPES_ALLOWED = [
   NOT_REMOTE,
   PRIVILEGEDABOUT_REMOTE_TYPE,
 ];
 
-var E10SUtils = {
+export var E10SUtils = {
   DEFAULT_REMOTE_TYPE,
   NOT_REMOTE,
   WEB_REMOTE_TYPE,
   WEB_REMOTE_COOP_COEP_TYPE_PREFIX,
   FILE_REMOTE_TYPE,
   EXTENSION_REMOTE_TYPE,
   PRIVILEGEDABOUT_REMOTE_TYPE,
   PRIVILEGEDMOZILLA_REMOTE_TYPE,
rename from toolkit/modules/EventEmitter.jsm
rename to toolkit/modules/EventEmitter.sys.mjs
--- a/toolkit/modules/EventEmitter.jsm
+++ b/toolkit/modules/EventEmitter.sys.mjs
@@ -1,25 +1,21 @@
 /* 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/. */
 
-"use strict";
-
 const lazy = {};
 
 ChromeUtils.defineModuleGetter(
   lazy,
   "console",
   "resource://gre/modules/Console.jsm"
 );
 
-var EXPORTED_SYMBOLS = ["EventEmitter"];
-
-function EventEmitter() {}
+export function EventEmitter() {}
 
 let loggingEnabled = Services.prefs.getBoolPref("toolkit.dump.emit");
 Services.prefs.addObserver("toolkit.dump.emit", {
   observe: () => {
     loggingEnabled = Services.prefs.getBoolPref("toolkit.dump.emit");
   },
 });
 
rename from toolkit/modules/Preferences.jsm
rename to toolkit/modules/Preferences.sys.mjs
--- a/toolkit/modules/Preferences.jsm
+++ b/toolkit/modules/Preferences.sys.mjs
@@ -1,22 +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/. */
 
-var EXPORTED_SYMBOLS = ["Preferences"];
-
 // The minimum and maximum integers that can be set as preferences.
 // The range of valid values is narrower than the range of valid JS values
 // because the native preferences code treats integers as NSPR PRInt32s,
 // which are 32-bit signed integers on all platforms.
 const MAX_INT = 0x7fffffff; // Math.pow(2, 31) - 1
 const MIN_INT = -0x80000000;
 
-function Preferences(args) {
+export function Preferences(args) {
   this._cachedPrefBranch = null;
   if (isObject(args)) {
     if (args.branch) {
       this._branchStr = args.branch;
     }
     if (args.defaultBranch) {
       this._defaultBranch = args.defaultBranch;
     }
rename from toolkit/modules/PrivateBrowsingUtils.jsm
rename to toolkit/modules/PrivateBrowsingUtils.sys.mjs
--- a/toolkit/modules/PrivateBrowsingUtils.jsm
+++ b/toolkit/modules/PrivateBrowsingUtils.sys.mjs
@@ -1,21 +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/. */
 
-var EXPORTED_SYMBOLS = ["PrivateBrowsingUtils"];
-
 const kAutoStartPref = "browser.privatebrowsing.autostart";
 
 // This will be set to true when the PB mode is autostarted from the command
 // line for the current session.
 var gTemporaryAutoStartMode = false;
 
-var PrivateBrowsingUtils = {
+export var PrivateBrowsingUtils = {
   get enabled() {
     return Services.policies.isAllowed("privatebrowsing");
   },
 
   // Rather than passing content windows to this function, please use
   // isBrowserPrivate since it works with e10s.
   isWindowPrivate: function pbu_isWindowPrivate(aWindow) {
     if (!aWindow.isChromeWindow) {
rename from toolkit/modules/Timer.jsm
rename to toolkit/modules/Timer.sys.mjs
--- a/toolkit/modules/Timer.jsm
+++ b/toolkit/modules/Timer.sys.mjs
@@ -1,29 +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/. */
 
-"use strict";
-
 /**
  * JS module implementation of setTimeout and clearTimeout.
  */
 
-var EXPORTED_SYMBOLS = [
-  "setTimeout",
-  "setTimeoutWithTarget",
-  "clearTimeout",
-  "setInterval",
-  "setIntervalWithTarget",
-  "clearInterval",
-  "requestIdleCallback",
-  "cancelIdleCallback",
-];
-
 // This gives us >=2^30 unique timer IDs, enough for 1 per ms for 12.4 days.
 var gNextId = 1; // setTimeout and setInterval must return a positive integer
 
 var gTimerTable = new Map(); // int -> nsITimer or idleCallback
 
 // Don't generate this for every timer.
 var setTimeout_timerCallbackQI = ChromeUtils.generateQI([
   "nsITimerCallback",
@@ -73,54 +60,64 @@ function _setTimeoutOrIsInterval(
     aMilliseconds,
     aIsInterval ? timer.TYPE_REPEATING_SLACK : timer.TYPE_ONE_SHOT
   );
 
   gTimerTable.set(id, timer);
   return id;
 }
 
-function setTimeout(aCallback, aMilliseconds, ...aArgs) {
+export function setTimeout(aCallback, aMilliseconds, ...aArgs) {
   return _setTimeoutOrIsInterval(aCallback, aMilliseconds, false, null, aArgs);
 }
 
-function setTimeoutWithTarget(aCallback, aMilliseconds, aTarget, ...aArgs) {
+export function setTimeoutWithTarget(
+  aCallback,
+  aMilliseconds,
+  aTarget,
+  ...aArgs
+) {
   return _setTimeoutOrIsInterval(
     aCallback,
     aMilliseconds,
     false,
     aTarget,
     aArgs
   );
 }
 
-function setInterval(aCallback, aMilliseconds, ...aArgs) {
+export function setInterval(aCallback, aMilliseconds, ...aArgs) {
   return _setTimeoutOrIsInterval(aCallback, aMilliseconds, true, null, aArgs);
 }
 
-function setIntervalWithTarget(aCallback, aMilliseconds, aTarget, ...aArgs) {
+export function setIntervalWithTarget(
+  aCallback,
+  aMilliseconds,
+  aTarget,
+  ...aArgs
+) {
   return _setTimeoutOrIsInterval(
     aCallback,
     aMilliseconds,
     true,
     aTarget,
     aArgs
   );
 }
 
 function clear(aId) {
   if (gTimerTable.has(aId)) {
     gTimerTable.get(aId).cancel();
     gTimerTable.delete(aId);
   }
 }
-var clearInterval = clear;
-var clearTimeout = clear;
+export var clearInterval = clear;
+export var clearTimeout = clear;
 
-function requestIdleCallback(aCallback, aOptions) {
+export function requestIdleCallback(aCallback, aOptions) {
   if (typeof aCallback !== "function") {
     throw new Error("callback is not a function in requestIdleCallback");
   }
   let id = gNextId++;
 
   let callback = (...aArgs) => {
     if (gTimerTable.has(id)) {
       gTimerTable.delete(id);
@@ -128,13 +125,13 @@ function requestIdleCallback(aCallback, 
     }
   };
 
   ChromeUtils.idleDispatch(callback, aOptions);
   gTimerTable.set(id, callback);
   return id;
 }
 
-function cancelIdleCallback(aId) {
+export function cancelIdleCallback(aId) {
   if (gTimerTable.has(aId)) {
     gTimerTable.delete(aId);
   }
 }
rename from toolkit/modules/WebChannel.jsm
rename to toolkit/modules/WebChannel.sys.mjs
--- a/toolkit/modules/WebChannel.jsm
+++ b/toolkit/modules/WebChannel.sys.mjs
@@ -2,27 +2,25 @@
  * 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/. */
 
 /**
  * WebChannel is an abstraction that uses the Message Manager and Custom Events
  * to create a two-way communication channel between chrome and content code.
  */
 
-var EXPORTED_SYMBOLS = ["WebChannel", "WebChannelBroker"];
-
 const ERRNO_UNKNOWN_ERROR = 999;
 const ERROR_UNKNOWN = "UNKNOWN_ERROR";
 
 /**
  * WebChannelBroker is a global object that helps manage WebChannel objects.
  * This object handles channel registration, origin validation and message multiplexing.
  */
 
-var WebChannelBroker = Object.create({
+export var WebChannelBroker = Object.create({
   /**
    * Register a new channel that callbacks messages
    * based on proper origin and channel name
    *
    * @param channel {WebChannel}
    */
   registerChannel(channel) {
     if (!this._channelMap.has(channel)) {
@@ -81,17 +79,17 @@ var WebChannelBroker = Object.create({
  * @param originOrPermission {nsIURI/string}
  *        If an nsIURI, incoming events will be accepted from any origin matching
  *        that URI's origin.
  *        If a string, it names a permission, and incoming events will be accepted
  *        from any https:// origin that has been granted that permission by the
  *        permission manager.
  * @constructor
  */
-var WebChannel = function(id, originOrPermission) {
+export var WebChannel = function(id, originOrPermission) {
   if (!id || !originOrPermission) {
     throw new Error("WebChannel id and originOrPermission are required.");
   }
 
   this.id = id;
   // originOrPermission can be either an nsIURI or a string representing a
   // permission name.
   if (typeof originOrPermission == "string") {
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -49,26 +49,26 @@ with Files("AsyncPrefs.sys.mjs"):
     BUG_COMPONENT = ("Core", "Security: Process Sandboxing")
 
 with Files("AsanReporter.sys.mjs"):
     BUG_COMPONENT = ("Firefox Build System", "General")
 
 with Files("Color.sys.mjs"):
     BUG_COMPONENT = ("Toolkit", "Find Toolbar")
 
-with Files("Console.jsm"):
+with Files("Console.sys.mjs"):
     BUG_COMPONENT = ("DevTools", "Console")
 
 with Files("DateTimePicker*.jsm"):
     BUG_COMPONENT = ("Core", "Layout: Form Controls")
 
-with Files("DeferredTask.jsm"):
+with Files("DeferredTask.sys.mjs"):
     BUG_COMPONENT = ("Toolkit", "Async Tooling")
 
-with Files("E10SUtils.jsm"):
+with Files("E10SUtils.sys.mjs"):
     BUG_COMPONENT = ("Core", "Security: Process Sandboxing")
 
 with Files("nsIE10SUtils.idl"):
     BUG_COMPONENT = ("Core", "Security: Process Sandboxing")
 
 with Files("Finder*.jsm"):
     BUG_COMPONENT = ("Toolkit", "Find Toolbar")
 
@@ -100,17 +100,17 @@ with Files("ObjectUtils.jsm"):
     BUG_COMPONENT = ("Toolkit", "Telemetry")
 
 with Files("PermissionsUtils.sys.mjs"):
     BUG_COMPONENT = ("Toolkit", "Add-ons Manager")
 
 with Files("PopupNotifications.sys.mjs"):
     BUG_COMPONENT = ("Toolkit", "Notifications and Alerts")
 
-with Files("PrivateBrowsingUtils.jsm"):
+with Files("PrivateBrowsingUtils.sys.mjs"):
     BUG_COMPONENT = ("Firefox", "Private Browsing")
 
 with Files("Promise*.jsm"):
     BUG_COMPONENT = ("Toolkit", "Async Tooling")
 
 with Files("ResponsivenessMonitor.sys.mjs"):
     BUG_COMPONENT = ("Firefox", "Migration")
 
@@ -144,33 +144,33 @@ TESTING_JS_MODULES += [
 
 SPHINX_TREES["toolkit_modules"] = "docs"
 
 with Files("docs/**"):
     SCHEDULES.exclusive = ["docs"]
 
 EXTRA_JS_MODULES += [
     "AboutPagesUtils.sys.mjs",
-    "ActorManagerParent.jsm",
+    "ActorManagerParent.sys.mjs",
     "AppMenuNotifications.sys.mjs",
     "AsyncPrefs.sys.mjs",
     "BinarySearch.sys.mjs",
     "BrowserTelemetryUtils.sys.mjs",
     "BrowserUtils.sys.mjs",
     "CanonicalJSON.jsm",
     "CertUtils.sys.mjs",
     "Color.sys.mjs",
-    "Console.jsm",
-    "ContentDOMReference.jsm",
+    "Console.sys.mjs",
+    "ContentDOMReference.sys.mjs",
     "CreditCard.sys.mjs",
     "DateTimePickerPanel.sys.mjs",
-    "DeferredTask.jsm",
-    "Deprecated.jsm",
-    "E10SUtils.jsm",
-    "EventEmitter.jsm",
+    "DeferredTask.sys.mjs",
+    "Deprecated.sys.mjs",
+    "E10SUtils.sys.mjs",
+    "EventEmitter.sys.mjs",
     "FileUtils.sys.mjs",
     "FindBarContent.sys.mjs",
     "Finder.sys.mjs",
     "FinderHighlighter.sys.mjs",
     "FinderIterator.sys.mjs",
     "FinderParent.sys.mjs",
     "FirstStartup.sys.mjs",
     "FormLikeFactory.sys.mjs",
@@ -189,35 +189,35 @@ EXTRA_JS_MODULES += [
     "Log.sys.mjs",
     "NewTabUtils.sys.mjs",
     "NLP.sys.mjs",
     "ObjectUtils.jsm",
     "OsEnvironment.sys.mjs",
     "OSKeyStore.sys.mjs",
     "PermissionsUtils.sys.mjs",
     "PopupNotifications.sys.mjs",
-    "Preferences.jsm",
-    "PrivateBrowsingUtils.jsm",
+    "Preferences.sys.mjs",
+    "PrivateBrowsingUtils.sys.mjs",
     "ProcessType.sys.mjs",
     "ProfileAge.sys.mjs",
     "PromiseUtils.sys.mjs",
     "Region.sys.mjs",
     "RemotePageAccessManager.sys.mjs",
     "ResetProfile.sys.mjs",
     "ResponsivenessMonitor.sys.mjs",
     "SelectionUtils.sys.mjs",
     "ServiceRequest.sys.mjs",
     "Services.jsm",
     "ShortcutUtils.sys.mjs",
     "Sqlite.sys.mjs",
     "SubDialog.sys.mjs",
-    "Timer.jsm",
+    "Timer.sys.mjs",
     "Troubleshoot.sys.mjs",
     "UpdateUtils.sys.mjs",
-    "WebChannel.jsm",
+    "WebChannel.sys.mjs",
 ]
 
 if CONFIG["MOZ_ASAN_REPORTER"]:
     EXTRA_JS_MODULES += [
         "AsanReporter.sys.mjs",
     ]
 
 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":