From d0b9714f92358ffbb582c62d90560ae46701b521 Mon Sep 17 00:00:00 2001 From: Abhishek Tiwari Date: Wed, 15 Mar 2023 18:44:02 +0000 Subject: [PATCH] Bug 1821624 - Convert toolkit/components/messaging-system to ES modules r=Standard8,fxview-reviewers,omc-reviewers,aminomancer,sclements Differential Revision: https://phabricator.services.mozilla.com/D172406 --- browser/actors/AboutPrivateBrowsingParent.sys.mjs | 7 ++----- browser/components/BrowserGlue.sys.mjs | 6 ++---- .../tests/browser/browser_cfr_message.js | 4 ++-- .../actors/AboutMessagePreviewParent.sys.mjs | 6 ++++-- .../newtab/aboutwelcome/AboutWelcomeChild.jsm | 4 ++-- .../newtab/aboutwelcome/AboutWelcomeParent.jsm | 8 ++++---- browser/components/newtab/lib/ASRouter.jsm | 6 +++--- .../components/newtab/lib/ASRouterDefaultConfig.jsm | 4 ++-- browser/components/newtab/lib/ASRouterTargeting.jsm | 2 +- .../newtab/lib/ASRouterTriggerListeners.jsm | 4 ++-- browser/components/newtab/lib/ToolbarPanelHub.jsm | 4 ++-- browser/components/newtab/lib/TopSitesFeed.jsm | 4 ++-- .../browser_aboutwelcome_upgrade_multistage_mr.js | 4 ++-- .../test/browser/browser_asrouter_targeting.js | 2 +- .../test/browser/browser_multistage_spotlight.js | 4 ++-- toolkit/components/messaging-system/jar.mn | 2 +- .../lib/{Logger.jsm => Logger.sys.mjs} | 9 ++------- ...ageActions.jsm => SpecialMessageActions.sys.mjs} | 8 ++------ .../test/browser/head.js | 9 ++++----- .../targeting/{Targeting.jsm => Targeting.sys.mjs} | 13 +++---------- .../targeting/test/unit/test_targeting.js | 4 ++-- toolkit/components/nimbus/lib/ExperimentManager.jsm | 4 ++-- .../nimbus/lib/RemoteSettingsExperimentLoader.jsm | 6 +++--- toolkit/components/normandy/lib/RecipeRunner.jsm | 4 ++-- 24 files changed, 54 insertions(+), 74 deletions(-) rename toolkit/components/messaging-system/lib/{Logger.jsm => Logger.sys.mjs} (71%) rename toolkit/components/messaging-system/lib/{SpecialMessageActions.jsm => SpecialMessageActions.sys.mjs} (98%) rename toolkit/components/messaging-system/targeting/{Targeting.jsm => Targeting.sys.mjs} (95%) diff --git a/browser/actors/AboutPrivateBrowsingParent.sys.mjs b/browser/actors/AboutPrivateBrowsingParent.sys.mjs index 79bfc2e94ca7..9e8b1cb1f81d 100644 --- a/browser/actors/AboutPrivateBrowsingParent.sys.mjs +++ b/browser/actors/AboutPrivateBrowsingParent.sys.mjs @@ -25,12 +25,9 @@ XPCOMUtils.defineLazyPreferenceGetter( ); ChromeUtils.defineESModuleGetters(lazy, { - UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs", -}); - -XPCOMUtils.defineLazyModuleGetters(lazy, { SpecialMessageActions: - "resource://messaging-system/lib/SpecialMessageActions.jsm", + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", + UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs", }); // We only show the private search banner once per browser session. diff --git a/browser/components/BrowserGlue.sys.mjs b/browser/components/BrowserGlue.sys.mjs index 6a9c9ae153af..7c9b35ebfa95 100644 --- a/browser/components/BrowserGlue.sys.mjs +++ b/browser/components/BrowserGlue.sys.mjs @@ -56,6 +56,8 @@ ChromeUtils.defineESModuleGetters(lazy, { SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs", SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs", ShortcutUtils: "resource://gre/modules/ShortcutUtils.sys.mjs", + SpecialMessageActions: + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", TRRRacer: "resource:///modules/TRRPerformance.sys.mjs", TelemetryUtils: "resource://gre/modules/TelemetryUtils.sys.mjs", UIState: "resource://services-sync/UIState.sys.mjs", @@ -101,10 +103,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { Sanitizer: "resource:///modules/Sanitizer.jsm", SaveToPocket: "chrome://pocket/content/SaveToPocket.jsm", ShellService: "resource:///modules/ShellService.jsm", - - SpecialMessageActions: - "resource://messaging-system/lib/SpecialMessageActions.jsm", - TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm", TabUnloader: "resource:///modules/TabUnloader.jsm", }); diff --git a/browser/components/firefoxview/tests/browser/browser_cfr_message.js b/browser/components/firefoxview/tests/browser/browser_cfr_message.js index ee9df2f10579..337f74c4b159 100644 --- a/browser/components/firefoxview/tests/browser/browser_cfr_message.js +++ b/browser/components/firefoxview/tests/browser/browser_cfr_message.js @@ -5,8 +5,8 @@ const { ASRouterTriggerListeners } = ChromeUtils.import( "resource://activity-stream/lib/ASRouterTriggerListeners.jsm" ); -const { SpecialMessageActions } = ChromeUtils.import( - "resource://messaging-system/lib/SpecialMessageActions.jsm" +const { SpecialMessageActions } = ChromeUtils.importESModule( + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs" ); add_task(async function cfr_firefoxview_should_show() { diff --git a/browser/components/messagepreview/actors/AboutMessagePreviewParent.sys.mjs b/browser/components/messagepreview/actors/AboutMessagePreviewParent.sys.mjs index 077bfe46bf0c..d03d293ad6ea 100644 --- a/browser/components/messagepreview/actors/AboutMessagePreviewParent.sys.mjs +++ b/browser/components/messagepreview/actors/AboutMessagePreviewParent.sys.mjs @@ -8,11 +8,13 @@ import { JsonSchema } from "resource://gre/modules/JsonSchema.sys.mjs"; const lazy = {}; +ChromeUtils.defineESModuleGetters(lazy, { + SpecialMessageActions: + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", +}); XPCOMUtils.defineLazyModuleGetters(lazy, { InfoBar: "resource://activity-stream/lib/InfoBar.jsm", Spotlight: "resource://activity-stream/lib/Spotlight.jsm", - SpecialMessageActions: - "resource://messaging-system/lib/SpecialMessageActions.jsm", }); function dispatchCFRAction({ type, data }, browser) { diff --git a/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm b/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm index 0a87d68117d0..82f05d8a1636 100644 --- a/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm +++ b/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm @@ -20,8 +20,8 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { }); XPCOMUtils.defineLazyGetter(lazy, "log", () => { - const { Logger } = ChromeUtils.import( - "resource://messaging-system/lib/Logger.jsm" + const { Logger } = ChromeUtils.importESModule( + "resource://messaging-system/lib/Logger.sys.mjs" ); return new Logger("AboutWelcomeChild"); }); diff --git a/browser/components/newtab/aboutwelcome/AboutWelcomeParent.jsm b/browser/components/newtab/aboutwelcome/AboutWelcomeParent.jsm index d29378cac720..5ee38c53c3e8 100644 --- a/browser/components/newtab/aboutwelcome/AboutWelcomeParent.jsm +++ b/browser/components/newtab/aboutwelcome/AboutWelcomeParent.jsm @@ -16,12 +16,12 @@ ChromeUtils.defineESModuleGetters(lazy, { BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs", BuiltInThemes: "resource:///modules/BuiltInThemes.sys.mjs", FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs", + SpecialMessageActions: + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", }); XPCOMUtils.defineLazyModuleGetters(lazy, { AddonManager: "resource://gre/modules/AddonManager.jsm", - SpecialMessageActions: - "resource://messaging-system/lib/SpecialMessageActions.jsm", AboutWelcomeTelemetry: "resource://activity-stream/aboutwelcome/lib/AboutWelcomeTelemetry.jsm", AboutWelcomeDefaults: @@ -32,8 +32,8 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { }); XPCOMUtils.defineLazyGetter(lazy, "log", () => { - const { Logger } = ChromeUtils.import( - "resource://messaging-system/lib/Logger.jsm" + const { Logger } = ChromeUtils.importESModule( + "resource://messaging-system/lib/Logger.sys.mjs" ); return new Logger("AboutWelcomeParent"); }); diff --git a/browser/components/newtab/lib/ASRouter.jsm b/browser/components/newtab/lib/ASRouter.jsm index a284199f748e..f04eda26cc67 100644 --- a/browser/components/newtab/lib/ASRouter.jsm +++ b/browser/components/newtab/lib/ASRouter.jsm @@ -15,6 +15,9 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { Downloader: "resource://services-settings/Attachments.sys.mjs", MacAttribution: "resource:///modules/MacAttribution.sys.mjs", + SpecialMessageActions: + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", + TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", }); XPCOMUtils.defineLazyModuleGetters(lazy, { @@ -38,9 +41,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm", setTimeout: "resource://gre/modules/Timer.jsm", NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm", - SpecialMessageActions: - "resource://messaging-system/lib/SpecialMessageActions.jsm", - TargetingContext: "resource://messaging-system/targeting/Targeting.jsm", Utils: "resource://services-settings/Utils.jsm", }); XPCOMUtils.defineLazyServiceGetters(lazy, { diff --git a/browser/components/newtab/lib/ASRouterDefaultConfig.jsm b/browser/components/newtab/lib/ASRouterDefaultConfig.jsm index 6caff6f4a225..84ccad5200f7 100644 --- a/browser/components/newtab/lib/ASRouterDefaultConfig.jsm +++ b/browser/components/newtab/lib/ASRouterDefaultConfig.jsm @@ -16,8 +16,8 @@ const { TelemetryFeed } = ChromeUtils.import( const { ASRouterParentProcessMessageHandler } = ChromeUtils.import( "resource://activity-stream/lib/ASRouterParentProcessMessageHandler.jsm" ); -const { SpecialMessageActions } = ChromeUtils.import( - "resource://messaging-system/lib/SpecialMessageActions.jsm" +const { SpecialMessageActions } = ChromeUtils.importESModule( + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs" ); const { ASRouterPreferences } = ChromeUtils.import( "resource://activity-stream/lib/ASRouterPreferences.jsm" diff --git a/browser/components/newtab/lib/ASRouterTargeting.jsm b/browser/components/newtab/lib/ASRouterTargeting.jsm index 01bfbcb5cb4c..1ece6e332adb 100644 --- a/browser/components/newtab/lib/ASRouterTargeting.jsm +++ b/browser/components/newtab/lib/ASRouterTargeting.jsm @@ -26,6 +26,7 @@ ChromeUtils.defineESModuleGetters(lazy, { BuiltInThemes: "resource:///modules/BuiltInThemes.sys.mjs", ProfileAge: "resource://gre/modules/ProfileAge.sys.mjs", Region: "resource://gre/modules/Region.sys.mjs", + TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs", TelemetrySession: "resource://gre/modules/TelemetrySession.sys.mjs", }); @@ -34,7 +35,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { ASRouterPreferences: "resource://activity-stream/lib/ASRouterPreferences.jsm", AddonManager: "resource://gre/modules/AddonManager.jsm", ClientEnvironment: "resource://normandy/lib/ClientEnvironment.jsm", - TargetingContext: "resource://messaging-system/targeting/Targeting.jsm", HomePage: "resource:///modules/HomePage.jsm", AboutNewTab: "resource:///modules/AboutNewTab.jsm", BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm", diff --git a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm index 48e19f6379df..a185c6c5c8df 100644 --- a/browser/components/newtab/lib/ASRouterTriggerListeners.jsm +++ b/browser/components/newtab/lib/ASRouterTriggerListeners.jsm @@ -22,8 +22,8 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { }); XPCOMUtils.defineLazyGetter(lazy, "log", () => { - const { Logger } = ChromeUtils.import( - "resource://messaging-system/lib/Logger.jsm" + const { Logger } = ChromeUtils.importESModule( + "resource://messaging-system/lib/Logger.sys.mjs" ); return new Logger("ASRouterTriggerListeners"); }); diff --git a/browser/components/newtab/lib/ToolbarPanelHub.jsm b/browser/components/newtab/lib/ToolbarPanelHub.jsm index 4f7ec047b5a6..817459305337 100644 --- a/browser/components/newtab/lib/ToolbarPanelHub.jsm +++ b/browser/components/newtab/lib/ToolbarPanelHub.jsm @@ -11,12 +11,12 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { Preferences: "resource://gre/modules/Preferences.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", + SpecialMessageActions: + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", }); XPCOMUtils.defineLazyModuleGetters(lazy, { EveryWindow: "resource:///modules/EveryWindow.jsm", - SpecialMessageActions: - "resource://messaging-system/lib/SpecialMessageActions.jsm", RemoteL10n: "resource://activity-stream/lib/RemoteL10n.jsm", }); ChromeUtils.defineModuleGetter( diff --git a/browser/components/newtab/lib/TopSitesFeed.jsm b/browser/components/newtab/lib/TopSitesFeed.jsm index b11b57072f3c..3fb1f5fb980d 100644 --- a/browser/components/newtab/lib/TopSitesFeed.jsm +++ b/browser/components/newtab/lib/TopSitesFeed.jsm @@ -67,8 +67,8 @@ ChromeUtils.defineModuleGetter( ); XPCOMUtils.defineLazyGetter(lazy, "log", () => { - const { Logger } = ChromeUtils.import( - "resource://messaging-system/lib/Logger.jsm" + const { Logger } = ChromeUtils.importESModule( + "resource://messaging-system/lib/Logger.sys.mjs" ); return new Logger("TopSitesFeed"); }); diff --git a/browser/components/newtab/test/browser/browser_aboutwelcome_upgrade_multistage_mr.js b/browser/components/newtab/test/browser/browser_aboutwelcome_upgrade_multistage_mr.js index 3749b612d469..b3850fc15117 100644 --- a/browser/components/newtab/test/browser/browser_aboutwelcome_upgrade_multistage_mr.js +++ b/browser/components/newtab/test/browser/browser_aboutwelcome_upgrade_multistage_mr.js @@ -3,8 +3,8 @@ const { OnboardingMessageProvider } = ChromeUtils.import( "resource://activity-stream/lib/OnboardingMessageProvider.jsm" ); -const { SpecialMessageActions } = ChromeUtils.import( - "resource://messaging-system/lib/SpecialMessageActions.jsm" +const { SpecialMessageActions } = ChromeUtils.importESModule( + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs" ); const { assertFirefoxViewTabSelected, diff --git a/browser/components/newtab/test/browser/browser_asrouter_targeting.js b/browser/components/newtab/test/browser/browser_asrouter_targeting.js index b00241d5988d..a41c0f932d4e 100644 --- a/browser/components/newtab/test/browser/browser_asrouter_targeting.js +++ b/browser/components/newtab/test/browser/browser_asrouter_targeting.js @@ -11,7 +11,6 @@ XPCOMUtils.defineLazyModuleGetters(this, { NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm", QueryCache: "resource://activity-stream/lib/ASRouterTargeting.jsm", ShellService: "resource:///modules/ShellService.jsm", - TargetingContext: "resource://messaging-system/targeting/Targeting.jsm", }); ChromeUtils.defineESModuleGetters(this, { AppConstants: "resource://gre/modules/AppConstants.sys.mjs", @@ -22,6 +21,7 @@ ChromeUtils.defineESModuleGetters(this, { PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs", ProfileAge: "resource://gre/modules/ProfileAge.sys.mjs", Region: "resource://gre/modules/Region.sys.mjs", + TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs", TelemetrySession: "resource://gre/modules/TelemetrySession.sys.mjs", }); diff --git a/browser/components/newtab/test/browser/browser_multistage_spotlight.js b/browser/components/newtab/test/browser/browser_multistage_spotlight.js index f72639b39b16..ba945a40b7f6 100644 --- a/browser/components/newtab/test/browser/browser_multistage_spotlight.js +++ b/browser/components/newtab/test/browser/browser_multistage_spotlight.js @@ -12,8 +12,8 @@ const { PanelTestProvider } = ChromeUtils.import( const { BrowserWindowTracker } = ChromeUtils.import( "resource:///modules/BrowserWindowTracker.jsm" ); -const { SpecialMessageActions } = ChromeUtils.import( - "resource://messaging-system/lib/SpecialMessageActions.jsm" +const { SpecialMessageActions } = ChromeUtils.importESModule( + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs" ); async function waitForClick(selector, win) { diff --git a/toolkit/components/messaging-system/jar.mn b/toolkit/components/messaging-system/jar.mn index 6bd8e180afaa..9cdae9029088 100644 --- a/toolkit/components/messaging-system/jar.mn +++ b/toolkit/components/messaging-system/jar.mn @@ -5,4 +5,4 @@ toolkit.jar: % resource messaging-system %res/messaging-system/ res/messaging-system/lib/ (./lib/*) - res/messaging-system/targeting/Targeting.jsm (./targeting/Targeting.jsm) + res/messaging-system/targeting/Targeting.sys.mjs (./targeting/Targeting.sys.mjs) diff --git a/toolkit/components/messaging-system/lib/Logger.jsm b/toolkit/components/messaging-system/lib/Logger.sys.mjs similarity index 71% rename from toolkit/components/messaging-system/lib/Logger.jsm rename to toolkit/components/messaging-system/lib/Logger.sys.mjs index 475439966ecf..507d3eef6c84 100644 --- a/toolkit/components/messaging-system/lib/Logger.jsm +++ b/toolkit/components/messaging-system/lib/Logger.sys.mjs @@ -1,17 +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"; -const EXPORTED_SYMBOLS = ["Logger"]; - -const { ConsoleAPI } = ChromeUtils.importESModule( - "resource://gre/modules/Console.sys.mjs" -); +import { ConsoleAPI } from "resource://gre/modules/Console.sys.mjs"; const LOGGING_PREF = "messaging-system.log"; -class Logger extends ConsoleAPI { +export class Logger extends ConsoleAPI { constructor(name) { let consoleOptions = { prefix: name, diff --git a/toolkit/components/messaging-system/lib/SpecialMessageActions.jsm b/toolkit/components/messaging-system/lib/SpecialMessageActions.sys.mjs similarity index 98% rename from toolkit/components/messaging-system/lib/SpecialMessageActions.jsm rename to toolkit/components/messaging-system/lib/SpecialMessageActions.sys.mjs index d862704c4c72..602b3c32b622 100644 --- a/toolkit/components/messaging-system/lib/SpecialMessageActions.jsm +++ b/toolkit/components/messaging-system/lib/SpecialMessageActions.sys.mjs @@ -1,13 +1,9 @@ /* 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 EXPORTED_SYMBOLS = ["SpecialMessageActions"]; +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); const DOH_DOORHANGER_DECISION_PREF = "doh-rollout.doorhanger-decision"; const NETWORK_TRR_MODE_PREF = "network.trr.mode"; @@ -25,7 +21,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { ColorwayClosetOpener: "resource:///modules/ColorwayClosetOpener.jsm", }); -const SpecialMessageActions = { +export const SpecialMessageActions = { // This is overridden by ASRouter.init blockMessageById() { throw new Error("ASRouter not intialized yet"); diff --git a/toolkit/components/messaging-system/schemas/SpecialMessageActionSchemas/test/browser/head.js b/toolkit/components/messaging-system/schemas/SpecialMessageActionSchemas/test/browser/head.js index 9755a36178ba..b9ee38dd6132 100644 --- a/toolkit/components/messaging-system/schemas/SpecialMessageActionSchemas/test/browser/head.js +++ b/toolkit/components/messaging-system/schemas/SpecialMessageActionSchemas/test/browser/head.js @@ -8,11 +8,10 @@ const { JsonSchema } = ChromeUtils.importESModule( "resource://gre/modules/JsonSchema.sys.mjs" ); -ChromeUtils.defineModuleGetter( - this, - "SpecialMessageActions", - "resource://messaging-system/lib/SpecialMessageActions.jsm" -); +ChromeUtils.defineESModuleGetters(this, { + SpecialMessageActions: + "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", +}); XPCOMUtils.defineLazyGetter(this, "fetchSMASchema", async () => { const response = await fetch( diff --git a/toolkit/components/messaging-system/targeting/Targeting.jsm b/toolkit/components/messaging-system/targeting/Targeting.sys.mjs similarity index 95% rename from toolkit/components/messaging-system/targeting/Targeting.jsm rename to toolkit/components/messaging-system/targeting/Targeting.sys.mjs index 6ed951b24fdb..d2f98cf0c9f9 100644 --- a/toolkit/components/messaging-system/targeting/Targeting.jsm +++ b/toolkit/components/messaging-system/targeting/Targeting.sys.mjs @@ -2,14 +2,9 @@ * 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"; +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; +import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { @@ -27,8 +22,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { "resource://gre/modules/components-utils/ClientEnvironment.jsm", }); -var EXPORTED_SYMBOLS = ["TargetingContext"]; - const TARGETING_EVENT_CATEGORY = "messaging_experiments"; const TARGETING_EVENT_METHOD = "targeting"; const DEFAULT_TIMEOUT = 5000; @@ -72,7 +65,7 @@ const TargetingEnvironment = { }, }; -class TargetingContext { +export class TargetingContext { #telemetrySource = null; constructor(customContext, options = { source: null }) { diff --git a/toolkit/components/messaging-system/targeting/test/unit/test_targeting.js b/toolkit/components/messaging-system/targeting/test/unit/test_targeting.js index 5e8c9b013035..853510fba0bf 100644 --- a/toolkit/components/messaging-system/targeting/test/unit/test_targeting.js +++ b/toolkit/components/messaging-system/targeting/test/unit/test_targeting.js @@ -1,8 +1,8 @@ const { ClientEnvironment } = ChromeUtils.import( "resource://normandy/lib/ClientEnvironment.jsm" ); -const { TargetingContext } = ChromeUtils.import( - "resource://messaging-system/targeting/Targeting.jsm" +const { TargetingContext } = ChromeUtils.importESModule( + "resource://messaging-system/targeting/Targeting.sys.mjs" ); const { TelemetryTestUtils } = ChromeUtils.importESModule( "resource://testing-common/TelemetryTestUtils.sys.mjs" diff --git a/toolkit/components/nimbus/lib/ExperimentManager.jsm b/toolkit/components/nimbus/lib/ExperimentManager.jsm index 0fc9aed77a02..e80a1d4a10a6 100644 --- a/toolkit/components/nimbus/lib/ExperimentManager.jsm +++ b/toolkit/components/nimbus/lib/ExperimentManager.jsm @@ -28,8 +28,8 @@ XPCOMUtils.defineLazyModuleGetters(lazy, { }); XPCOMUtils.defineLazyGetter(lazy, "log", () => { - const { Logger } = ChromeUtils.import( - "resource://messaging-system/lib/Logger.jsm" + const { Logger } = ChromeUtils.importESModule( + "resource://messaging-system/lib/Logger.sys.mjs" ); return new Logger("ExperimentManager"); }); diff --git a/toolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.jsm b/toolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.jsm index 6d25069f5029..44b977ff227a 100644 --- a/toolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.jsm +++ b/toolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.jsm @@ -19,19 +19,19 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { JsonSchema: "resource://gre/modules/JsonSchema.sys.mjs", RemoteSettings: "resource://services-settings/remote-settings.sys.mjs", + TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", }); XPCOMUtils.defineLazyModuleGetters(lazy, { ASRouterTargeting: "resource://activity-stream/lib/ASRouterTargeting.jsm", - TargetingContext: "resource://messaging-system/targeting/Targeting.jsm", ExperimentManager: "resource://nimbus/lib/ExperimentManager.jsm", CleanupManager: "resource://normandy/lib/CleanupManager.jsm", NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm", }); XPCOMUtils.defineLazyGetter(lazy, "log", () => { - const { Logger } = ChromeUtils.import( - "resource://messaging-system/lib/Logger.jsm" + const { Logger } = ChromeUtils.importESModule( + "resource://messaging-system/lib/Logger.sys.mjs" ); return new Logger("RSLoader"); }); diff --git a/toolkit/components/normandy/lib/RecipeRunner.jsm b/toolkit/components/normandy/lib/RecipeRunner.jsm index eb44b8d1c37b..37acb5681d80 100644 --- a/toolkit/components/normandy/lib/RecipeRunner.jsm +++ b/toolkit/components/normandy/lib/RecipeRunner.jsm @@ -24,19 +24,19 @@ XPCOMUtils.defineLazyServiceGetter( ); ChromeUtils.defineESModuleGetters(lazy, { + LegacyHeartbeat: "resource://normandy/lib/LegacyHeartbeat.sys.mjs", RemoteSettings: "resource://services-settings/remote-settings.sys.mjs", RemoteSettingsClient: "resource://services-settings/RemoteSettingsClient.sys.mjs", + TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", clearTimeout: "resource://gre/modules/Timer.sys.mjs", setTimeout: "resource://gre/modules/Timer.sys.mjs", - LegacyHeartbeat: "resource://normandy/lib/LegacyHeartbeat.sys.mjs", }); XPCOMUtils.defineLazyModuleGetters(lazy, { Storage: "resource://normandy/lib/Storage.jsm", FilterExpressions: "resource://gre/modules/components-utils/FilterExpressions.jsm", - TargetingContext: "resource://messaging-system/targeting/Targeting.jsm", Normandy: "resource://normandy/Normandy.jsm", NormandyApi: "resource://normandy/lib/NormandyApi.jsm", ClientEnvironment: "resource://normandy/lib/ClientEnvironment.jsm",