diff --git a/.eslintrc.js b/.eslintrc.js index 56ad804b8379..15fce3c2dcaa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -236,7 +236,7 @@ module.exports = { "browser/components/enterprisepolicies/**", "browser/components/firefoxview/**", "browser/components/migration/**", - "browser/components/newtab/lib/ASRouterPreferences.jsm", + "browser/components/newtab/lib/ASRouterPreferences.sys.mjs", "browser/components/protocolhandler/WebProtocolHandlerRegistrar.sys.mjs", "browser/components/shell/ShellService.sys.mjs", "browser/components/syncedtabs/TabListComponent.sys.mjs", diff --git a/browser/components/asrouter/modules/ASRouter.jsm b/browser/components/asrouter/modules/ASRouter.jsm index 352f37744414..bb488c591115 100644 --- a/browser/components/asrouter/modules/ASRouter.jsm +++ b/browser/components/asrouter/modules/ASRouter.jsm @@ -13,6 +13,8 @@ const { AppConstants } = ChromeUtils.importESModule( const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { + ASRouterPreferences: + "resource:///modules/asrouter/ASRouterPreferences.sys.mjs", ASRouterTargeting: "resource:///modules/asrouter/ASRouterTargeting.sys.mjs", ASRouterTriggerListeners: "resource:///modules/asrouter/ASRouterTriggerListeners.sys.mjs", @@ -30,6 +32,8 @@ ChromeUtils.defineESModuleGetters(lazy, { SpecialMessageActions: "resource://messaging-system/lib/SpecialMessageActions.sys.mjs", TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", + TARGETING_PREFERENCES: + "resource:///modules/asrouter/ASRouterPreferences.sys.mjs", Utils: "resource://services-settings/Utils.sys.mjs", setTimeout: "resource://gre/modules/Timer.sys.mjs", Spotlight: "resource:///modules/asrouter/Spotlight.sys.mjs", @@ -38,11 +42,6 @@ ChromeUtils.defineESModuleGetters(lazy, { ToolbarPanelHub: "resource:///modules/asrouter/ToolbarPanelHub.sys.mjs", }); -XPCOMUtils.defineLazyModuleGetters(lazy, { - ASRouterPreferences: "resource:///modules/asrouter/ASRouterPreferences.jsm", - TARGETING_PREFERENCES: "resource:///modules/asrouter/ASRouterPreferences.jsm", -}); - XPCOMUtils.defineLazyServiceGetters(lazy, { BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"], }); diff --git a/browser/components/asrouter/modules/ASRouterDefaultConfig.sys.mjs b/browser/components/asrouter/modules/ASRouterDefaultConfig.sys.mjs index 6c4cbbcd6dc8..da66bc054bb0 100644 --- a/browser/components/asrouter/modules/ASRouterDefaultConfig.sys.mjs +++ b/browser/components/asrouter/modules/ASRouterDefaultConfig.sys.mjs @@ -20,9 +20,7 @@ const { SpecialMessageActions } = ChromeUtils.importESModule( "resource://messaging-system/lib/SpecialMessageActions.sys.mjs" ); -const { ASRouterPreferences } = ChromeUtils.import( - "resource:///modules/asrouter/ASRouterPreferences.jsm" -); +import { ASRouterPreferences } from "resource:///modules/asrouter/ASRouterPreferences.sys.mjs"; import { QueryCache } from "resource:///modules/asrouter/ASRouterTargeting.sys.mjs"; import { ActivityStreamStorage } from "resource://activity-stream/lib/ActivityStreamStorage.sys.mjs"; diff --git a/browser/components/asrouter/modules/ASRouterParentProcessMessageHandler.sys.mjs b/browser/components/asrouter/modules/ASRouterParentProcessMessageHandler.sys.mjs index c4a9f9d3a328..c2f5fcd884f6 100644 --- a/browser/components/asrouter/modules/ASRouterParentProcessMessageHandler.sys.mjs +++ b/browser/components/asrouter/modules/ASRouterParentProcessMessageHandler.sys.mjs @@ -3,10 +3,7 @@ * 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/. */ -const { ASRouterPreferences } = ChromeUtils.import( - "resource:///modules/asrouter/ASRouterPreferences.jsm" -); - +import { ASRouterPreferences } from "resource:///modules/asrouter/ASRouterPreferences.sys.mjs"; import { MESSAGE_TYPE_HASH as msg } from "resource:///modules/asrouter/ActorConstants.sys.mjs"; export class ASRouterParentProcessMessageHandler { diff --git a/browser/components/asrouter/modules/ASRouterPreferences.jsm b/browser/components/asrouter/modules/ASRouterPreferences.sys.mjs similarity index 95% rename from browser/components/asrouter/modules/ASRouterPreferences.jsm rename to browser/components/asrouter/modules/ASRouterPreferences.sys.mjs index 3731c607eadd..c7617d80c02c 100644 --- a/browser/components/asrouter/modules/ASRouterPreferences.jsm +++ b/browser/components/asrouter/modules/ASRouterPreferences.sys.mjs @@ -1,7 +1,6 @@ /* 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 PROVIDER_PREF_BRANCH = "browser.newtabpage.activity-stream.asrouter.providers."; @@ -33,9 +32,9 @@ const USER_PREFERENCES = { // Preferences that influence targeting attributes. When these change we need // to re-evaluate if the message targeting still matches -const TARGETING_PREFERENCES = [FXA_USERNAME_PREF]; +export const TARGETING_PREFERENCES = [FXA_USERNAME_PREF]; -const TEST_PROVIDERS = [ +export const TEST_PROVIDERS = [ { id: "panel_local_testing", type: "local", @@ -44,7 +43,7 @@ const TEST_PROVIDERS = [ }, ]; -class _ASRouterPreferences { +export class _ASRouterPreferences { constructor() { Object.assign(this, DEFAULT_STATE); this._callbacks = new Set(); @@ -239,11 +238,4 @@ class _ASRouterPreferences { } } -const ASRouterPreferences = new _ASRouterPreferences(); - -const EXPORTED_SYMBOLS = [ - "_ASRouterPreferences", - "ASRouterPreferences", - "TEST_PROVIDERS", - "TARGETING_PREFERENCES", -]; +export const ASRouterPreferences = new _ASRouterPreferences(); diff --git a/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs b/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs index 1034285841af..d2951e2a1602 100644 --- a/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs +++ b/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs @@ -38,6 +38,8 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { AddonManager: "resource://gre/modules/AddonManager.sys.mjs", AboutNewTab: "resource:///modules/AboutNewTab.sys.mjs", + ASRouterPreferences: + "resource:///modules/asrouter/ASRouterPreferences.sys.mjs", AttributionCode: "resource:///modules/AttributionCode.sys.mjs", BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs", ClientEnvironment: "resource://normandy/lib/ClientEnvironment.sys.mjs", @@ -52,10 +54,6 @@ ChromeUtils.defineESModuleGetters(lazy, { WindowsLaunchOnLogin: "resource://gre/modules/WindowsLaunchOnLogin.sys.mjs", }); -XPCOMUtils.defineLazyModuleGetters(lazy, { - ASRouterPreferences: "resource:///modules/asrouter/ASRouterPreferences.jsm", -}); - ChromeUtils.defineLazyGetter(lazy, "fxAccounts", () => { return ChromeUtils.importESModule( "resource://gre/modules/FxAccounts.sys.mjs" diff --git a/browser/components/asrouter/moz.build b/browser/components/asrouter/moz.build index 00b411b7e7e0..5365801a2640 100644 --- a/browser/components/asrouter/moz.build +++ b/browser/components/asrouter/moz.build @@ -20,7 +20,7 @@ EXTRA_JS_MODULES.asrouter += [ "modules/ASRouterDefaultConfig.sys.mjs", "modules/ASRouterNewTabHook.sys.mjs", "modules/ASRouterParentProcessMessageHandler.sys.mjs", - "modules/ASRouterPreferences.jsm", + "modules/ASRouterPreferences.sys.mjs", "modules/ASRouterTargeting.sys.mjs", "modules/ASRouterTriggerListeners.sys.mjs", "modules/CFRMessageProvider.sys.mjs", diff --git a/browser/components/asrouter/tests/unit/ASRouter.test.js b/browser/components/asrouter/tests/unit/ASRouter.test.js index f23047be4438..abdc6fb88324 100644 --- a/browser/components/asrouter/tests/unit/ASRouter.test.js +++ b/browser/components/asrouter/tests/unit/ASRouter.test.js @@ -11,7 +11,7 @@ import { import { ASRouterPreferences, TARGETING_PREFERENCES, -} from "modules/ASRouterPreferences.jsm"; +} from "modules/ASRouterPreferences.sys.mjs"; import { ASRouterTriggerListeners } from "modules/ASRouterTriggerListeners.sys.mjs"; import { CFRPageActions } from "modules/CFRPageActions.sys.mjs"; import { GlobalOverrider } from "test/unit/utils"; diff --git a/browser/components/asrouter/tests/unit/ASRouterPreferences.test.js b/browser/components/asrouter/tests/unit/ASRouterPreferences.test.js index e6a45c4d9acd..a3fe1fc5c94e 100644 --- a/browser/components/asrouter/tests/unit/ASRouterPreferences.test.js +++ b/browser/components/asrouter/tests/unit/ASRouterPreferences.test.js @@ -2,7 +2,7 @@ import { _ASRouterPreferences, ASRouterPreferences as ASRouterPreferencesSingleton, TEST_PROVIDERS, -} from "modules/ASRouterPreferences.jsm"; +} from "modules/ASRouterPreferences.sys.mjs"; const FAKE_PROVIDERS = [{ id: "foo" }, { id: "bar" }]; const PROVIDER_PREF_BRANCH = diff --git a/browser/components/asrouter/tests/unit/ASRouterTargeting.test.js b/browser/components/asrouter/tests/unit/ASRouterTargeting.test.js index db0afd4a68a7..610b488b47d4 100644 --- a/browser/components/asrouter/tests/unit/ASRouterTargeting.test.js +++ b/browser/components/asrouter/tests/unit/ASRouterTargeting.test.js @@ -5,7 +5,7 @@ import { QueryCache, } from "modules/ASRouterTargeting.sys.mjs"; import { OnboardingMessageProvider } from "modules/OnboardingMessageProvider.sys.mjs"; -import { ASRouterPreferences } from "modules/ASRouterPreferences.jsm"; +import { ASRouterPreferences } from "modules/ASRouterPreferences.sys.mjs"; import { GlobalOverrider } from "test/unit/utils"; // Note that tests for the ASRouterTargeting environment can be found in diff --git a/browser/components/asrouter/tests/unit/ASRouterTriggerListeners.test.js b/browser/components/asrouter/tests/unit/ASRouterTriggerListeners.test.js index dbf4a8edb419..aa455e23a293 100644 --- a/browser/components/asrouter/tests/unit/ASRouterTriggerListeners.test.js +++ b/browser/components/asrouter/tests/unit/ASRouterTriggerListeners.test.js @@ -1,5 +1,5 @@ import { ASRouterTriggerListeners } from "modules/ASRouterTriggerListeners.sys.mjs"; -import { ASRouterPreferences } from "modules/ASRouterPreferences.jsm"; +import { ASRouterPreferences } from "modules/ASRouterPreferences.sys.mjs"; import { GlobalOverrider } from "test/unit/utils"; describe("ASRouterTriggerListeners", () => {