diff --git a/.eslintignore b/.eslintignore index 15ed4091741b..9fa022ae27c1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -183,7 +183,7 @@ services/common/kinto-http-client.js services/common/kinto-offline-client.js # Webpack-bundled library -services/fxaccounts/FxAccountsPairingChannel.js +services/fxaccounts/FxAccountsPairingChannel.sys.mjs # Servo is imported. servo/ diff --git a/browser/base/content/test/performance/browser_startup.js b/browser/base/content/test/performance/browser_startup.js index 9f643dc7ccf1..478dd353e109 100644 --- a/browser/base/content/test/performance/browser_startup.js +++ b/browser/base/content/test/performance/browser_startup.js @@ -83,8 +83,8 @@ const startupPhases = { "resource://gre/modules/BookmarkHTMLUtils.sys.mjs", "resource://gre/modules/Bookmarks.sys.mjs", "resource://gre/modules/ContextualIdentityService.sys.mjs", - "resource://gre/modules/FxAccounts.jsm", - "resource://gre/modules/FxAccountsStorage.jsm", + "resource://gre/modules/FxAccounts.sys.mjs", + "resource://gre/modules/FxAccountsStorage.sys.mjs", "resource://gre/modules/PlacesBackups.sys.mjs", "resource://gre/modules/PlacesExpiration.sys.mjs", "resource://gre/modules/PlacesSyncUtils.sys.mjs", diff --git a/services/fxaccounts/Credentials.jsm b/services/fxaccounts/Credentials.sys.mjs similarity index 95% rename from services/fxaccounts/Credentials.jsm rename to services/fxaccounts/Credentials.sys.mjs index 302caea1a665..155dab3a3070 100644 --- a/services/fxaccounts/Credentials.jsm +++ b/services/fxaccounts/Credentials.sys.mjs @@ -9,13 +9,8 @@ * See https://github.com/mozilla/fxa-auth-server/wiki/onepw-protocol */ -"use strict"; +import { Log } from "resource://gre/modules/Log.sys.mjs"; -var EXPORTED_SYMBOLS = ["Credentials"]; - -const { Log } = ChromeUtils.importESModule( - "resource://gre/modules/Log.sys.mjs" -); const { CryptoUtils } = ChromeUtils.import( "resource://services-crypto/utils.js" ); @@ -45,7 +40,7 @@ var log = Log.repository.getLogger("Identity.FxAccounts"); log.level = LOG_LEVEL; log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter())); -var Credentials = Object.freeze({ +export var Credentials = Object.freeze({ /** * Make constants accessible to tests */ diff --git a/services/fxaccounts/FxAccounts.jsm b/services/fxaccounts/FxAccounts.sys.mjs similarity index 99% rename from services/fxaccounts/FxAccounts.jsm rename to services/fxaccounts/FxAccounts.sys.mjs index cf4c1c6c6e78..7d17069f4239 100644 --- a/services/fxaccounts/FxAccounts.jsm +++ b/services/fxaccounts/FxAccounts.sys.mjs @@ -1,20 +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/. */ -"use strict"; -const { PromiseUtils } = ChromeUtils.importESModule( - "resource://gre/modules/PromiseUtils.sys.mjs" -); +import { PromiseUtils } from "resource://gre/modules/PromiseUtils.sys.mjs"; + const { CryptoUtils } = ChromeUtils.import( "resource://services-crypto/utils.js" ); -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); -const { clearTimeout, setTimeout } = ChromeUtils.importESModule( - "resource://gre/modules/Timer.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; +import { clearTimeout, setTimeout } from "resource://gre/modules/Timer.sys.mjs"; + const { FxAccountsStorageManager } = ChromeUtils.import( "resource://gre/modules/FxAccountsStorage.jsm" ); @@ -129,7 +124,7 @@ XPCOMUtils.defineLazyPreferenceGetter( // } // If the state has changed between the function being called and the promise // being resolved, the .resolve() call will actually be rejected. -function AccountState(storageManager) { +export function AccountState(storageManager) { this.storageManager = storageManager; this.inFlightTokenRequests = new Map(); this.promiseInitialized = this.storageManager @@ -375,7 +370,7 @@ function copyObjectProperties(from, to, thisObj, keys) { * (although |./mach doc| is broken on windows (bug 1232403) and on Linux for * markh (some obscure npm issue he gave up on) - so later...) */ -class FxAccounts { +export class FxAccounts { constructor(mocks = null) { this._internal = new FxAccountsInternal(); if (mocks) { @@ -1645,7 +1640,8 @@ FxAccountsInternal.prototype = { }; let fxAccountsSingleton = null; -function getFxAccountsSingleton() { + +export function getFxAccountsSingleton() { if (fxAccountsSingleton) { return fxAccountsSingleton; } @@ -1660,4 +1656,3 @@ function getFxAccountsSingleton() { } // `AccountState` is exported for tests. -var EXPORTED_SYMBOLS = ["getFxAccountsSingleton", "FxAccounts", "AccountState"]; diff --git a/services/fxaccounts/FxAccountsClient.jsm b/services/fxaccounts/FxAccountsClient.sys.mjs similarity index 99% rename from services/fxaccounts/FxAccountsClient.jsm rename to services/fxaccounts/FxAccountsClient.sys.mjs index c81a0cf404ac..8d2a5d50eae6 100644 --- a/services/fxaccounts/FxAccountsClient.jsm +++ b/services/fxaccounts/FxAccountsClient.sys.mjs @@ -2,8 +2,6 @@ * 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 = ["FxAccountsClient"]; - const { CommonUtils } = ChromeUtils.import( "resource://services-common/utils.js" ); @@ -36,7 +34,9 @@ const SIGNUP = "/account/create"; // Devices older than this many days will not appear in the devices list const DEVICES_FILTER_DAYS = 21; -var FxAccountsClient = function(host = Services.prefs.getCharPref(HOST_PREF)) { +export var FxAccountsClient = function( + host = Services.prefs.getCharPref(HOST_PREF) +) { this.host = host; // The FxA auth server expects requests to certain endpoints to be authorized diff --git a/services/fxaccounts/FxAccountsCommands.js b/services/fxaccounts/FxAccountsCommands.sys.mjs similarity index 98% rename from services/fxaccounts/FxAccountsCommands.js rename to services/fxaccounts/FxAccountsCommands.sys.mjs index bd58438db852..0f745f6ee537 100644 --- a/services/fxaccounts/FxAccountsCommands.js +++ b/services/fxaccounts/FxAccountsCommands.sys.mjs @@ -2,8 +2,6 @@ * 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 EXPORTED_SYMBOLS = ["SendTab", "FxAccountsCommands"]; - const { COMMAND_SENDTAB, COMMAND_SENDTAB_TAIL, @@ -16,9 +14,8 @@ ChromeUtils.defineModuleGetter( "PushCrypto", "resource://gre/modules/PushCrypto.jsm" ); -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; + const { Observers } = ChromeUtils.import( "resource://services-common/observers.js" ); @@ -39,7 +36,7 @@ XPCOMUtils.defineLazyPreferenceGetter( } ); -class FxAccountsCommands { +export class FxAccountsCommands { constructor(fxAccountsInternal) { this._fxai = fxAccountsInternal; this.sendTab = new SendTab(this, fxAccountsInternal); @@ -248,7 +245,7 @@ class FxAccountsCommands { * the push keys to deliver the tabs using same mechanism we use for web-push. * However, clients use the send-tab keys for end-to-end encryption. */ -class SendTab { +export class SendTab { constructor(commands, fxAccountsInternal) { this._commands = commands; this._fxai = fxAccountsInternal; diff --git a/services/fxaccounts/FxAccountsConfig.jsm b/services/fxaccounts/FxAccountsConfig.sys.mjs similarity index 98% rename from services/fxaccounts/FxAccountsConfig.jsm rename to services/fxaccounts/FxAccountsConfig.sys.mjs index ea485c56d321..8f5d053f0aa3 100644 --- a/services/fxaccounts/FxAccountsConfig.jsm +++ b/services/fxaccounts/FxAccountsConfig.sys.mjs @@ -1,8 +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"; -var EXPORTED_SYMBOLS = ["FxAccountsConfig"]; const { RESTRequest } = ChromeUtils.import( "resource://services-common/rest.js" @@ -10,9 +8,7 @@ const { RESTRequest } = ChromeUtils.import( const { log } = ChromeUtils.import( "resource://gre/modules/FxAccountsCommon.js" ); -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; const lazy = {}; @@ -57,7 +53,7 @@ const CONFIG_PREFS = [ ]; const SYNC_PARAM = "sync"; -var FxAccountsConfig = { +export var FxAccountsConfig = { async promiseEmailURI(email, entrypoint, extraParams = {}) { return this._buildURL("", { extraParams: { entrypoint, email, service: SYNC_PARAM, ...extraParams }, diff --git a/services/fxaccounts/FxAccountsDevice.jsm b/services/fxaccounts/FxAccountsDevice.sys.mjs similarity index 99% rename from services/fxaccounts/FxAccountsDevice.jsm rename to services/fxaccounts/FxAccountsDevice.sys.mjs index e2d945e3399b..ba5ebd0025f4 100644 --- a/services/fxaccounts/FxAccountsDevice.jsm +++ b/services/fxaccounts/FxAccountsDevice.sys.mjs @@ -1,11 +1,8 @@ /* 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 { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; const { log, @@ -57,7 +54,7 @@ function sanitizeDeviceName(name) { } // Everything to do with FxA devices. -class FxAccountsDevice { +export class FxAccountsDevice { constructor(fxai) { this._fxai = fxai; this._deviceListCache = null; @@ -653,5 +650,3 @@ FxAccountsDevice.prototype.QueryInterface = ChromeUtils.generateQI([ function urlsafeBase64Encode(buffer) { return ChromeUtils.base64URLEncode(new Uint8Array(buffer), { pad: false }); } - -var EXPORTED_SYMBOLS = ["FxAccountsDevice"]; diff --git a/services/fxaccounts/FxAccountsKeys.jsm b/services/fxaccounts/FxAccountsKeys.sys.mjs similarity index 99% rename from services/fxaccounts/FxAccountsKeys.jsm rename to services/fxaccounts/FxAccountsKeys.sys.mjs index e4cf5339ed30..97f86ab76994 100644 --- a/services/fxaccounts/FxAccountsKeys.jsm +++ b/services/fxaccounts/FxAccountsKeys.sys.mjs @@ -1,11 +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 { PromiseUtils } = ChromeUtils.importESModule( - "resource://gre/modules/PromiseUtils.sys.mjs" -); +import { PromiseUtils } from "resource://gre/modules/PromiseUtils.sys.mjs"; + const { CommonUtils } = ChromeUtils.import( "resource://services-common/utils.js" ); @@ -56,7 +54,7 @@ const DEPRECATED_KEY_SCOPES = [DEPRECATED_SCOPE_ECOSYSTEM_TELEMETRY]; * possible. We intend to remove support for Firefox ever directly handling `kB` * at some point in the future. */ -class FxAccountsKeys { +export class FxAccountsKeys { constructor(fxAccountsInternal) { this._fxai = fxAccountsInternal; } @@ -749,5 +747,3 @@ class FxAccountsKeys { return CryptoUtils.digestBytes(bytes, hasher); } } - -var EXPORTED_SYMBOLS = ["FxAccountsKeys"]; diff --git a/services/fxaccounts/FxAccountsPairing.jsm b/services/fxaccounts/FxAccountsPairing.sys.mjs similarity index 98% rename from services/fxaccounts/FxAccountsPairing.jsm rename to services/fxaccounts/FxAccountsPairing.sys.mjs index 371e792f4980..2f0d487b00ee 100644 --- a/services/fxaccounts/FxAccountsPairing.jsm +++ b/services/fxaccounts/FxAccountsPairing.sys.mjs @@ -2,8 +2,6 @@ // 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 { log, PREF_REMOTE_PAIRING_URI, @@ -17,9 +15,8 @@ const { getFxAccountsSingleton, FxAccounts } = ChromeUtils.import( "resource://gre/modules/FxAccounts.jsm" ); const fxAccounts = getFxAccountsSingleton(); -const { setTimeout, clearTimeout } = ChromeUtils.importESModule( - "resource://gre/modules/Timer.sys.mjs" -); +import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs"; + ChromeUtils.import("resource://services-common/utils.js"); const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { @@ -173,7 +170,8 @@ class Errored extends State { } const flows = new Map(); -class FxAccountsPairingFlow { + +export class FxAccountsPairingFlow { static get(channelId) { return flows.get(channelId); } @@ -518,5 +516,3 @@ class FxAccountsPairingFlow { ); } } - -const EXPORTED_SYMBOLS = ["FxAccountsPairingFlow"]; diff --git a/services/fxaccounts/FxAccountsPairingChannel.js b/services/fxaccounts/FxAccountsPairingChannel.sys.mjs similarity index 99% rename from services/fxaccounts/FxAccountsPairingChannel.js rename to services/fxaccounts/FxAccountsPairingChannel.sys.mjs index 0e9597d6fb18..cb6d3fdb91a4 100644 --- a/services/fxaccounts/FxAccountsPairingChannel.js +++ b/services/fxaccounts/FxAccountsPairingChannel.sys.mjs @@ -22,15 +22,14 @@ // from Firefox browser code, hence the presence of these privileged browser APIs. // If you're trying to use this from ordinary web content you're in for a bad time. -const {setTimeout} = ChromeUtils.importESModule("resource://gre/modules/Timer.sys.mjs"); +import { setTimeout } from "resource://gre/modules/Timer.sys.mjs"; + // We cannot use WebSocket from chrome code without a window, // see https://bugzilla.mozilla.org/show_bug.cgi?id=784686 const browser = Services.appShell.createWindowlessBrowser(true); const {WebSocket} = browser.document.ownerGlobal; -const EXPORTED_SYMBOLS = ["FxAccountsPairingChannel"]; - -var FxAccountsPairingChannel = +export var FxAccountsPairingChannel = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -704,7 +703,7 @@ async function verifyHmac(keyBytes, signature, message) { hash: { name: 'SHA-256' }, name: 'HMAC', }, false, ['verify']); - if (! await crypto.subtle.verify({ name: 'HMAC' }, key, signature, message)) { + if (! (await crypto.subtle.verify({ name: 'HMAC' }, key, signature, message))) { // Yes, we really do throw 'decrypt_error' when failing to verify a HMAC, // and a 'bad_record_mac' error when failing to decrypt. throw new TLSError(ALERT_DESCRIPTION.DECRYPT_ERROR); diff --git a/services/fxaccounts/FxAccountsProfile.jsm b/services/fxaccounts/FxAccountsProfile.sys.mjs similarity index 98% rename from services/fxaccounts/FxAccountsProfile.jsm rename to services/fxaccounts/FxAccountsProfile.sys.mjs index 49594d992c6e..3b860ad3f4f1 100644 --- a/services/fxaccounts/FxAccountsProfile.jsm +++ b/services/fxaccounts/FxAccountsProfile.sys.mjs @@ -2,8 +2,6 @@ * 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"; - /** * Firefox Accounts Profile helper. * @@ -12,8 +10,6 @@ * the user's profile in open browser tabs, and cacheing/invalidating profile data. */ -var EXPORTED_SYMBOLS = ["FxAccountsProfile"]; - const { ON_PROFILE_CHANGE_NOTIFICATION, log } = ChromeUtils.import( "resource://gre/modules/FxAccountsCommon.js" ); @@ -30,7 +26,7 @@ ChromeUtils.defineModuleGetter( "resource://gre/modules/FxAccountsProfileClient.jsm" ); -var FxAccountsProfile = function(options = {}) { +export var FxAccountsProfile = function(options = {}) { this._currentFetchPromise = null; this._cachedAt = 0; // when we saved the cached version. this._isNotifying = false; // are we sending a notification? diff --git a/services/fxaccounts/FxAccountsProfileClient.jsm b/services/fxaccounts/FxAccountsProfileClient.sys.mjs similarity index 97% rename from services/fxaccounts/FxAccountsProfileClient.jsm rename to services/fxaccounts/FxAccountsProfileClient.sys.mjs index c554699ef58b..0ba2c71e7857 100644 --- a/services/fxaccounts/FxAccountsProfileClient.jsm +++ b/services/fxaccounts/FxAccountsProfileClient.sys.mjs @@ -7,11 +7,6 @@ */ "use strict;"; -var EXPORTED_SYMBOLS = [ - "FxAccountsProfileClient", - "FxAccountsProfileClientError", -]; - const { ERRNO_NETWORK, ERRNO_PARSE, @@ -44,7 +39,7 @@ const { RESTRequest } = ChromeUtils.import( * The bearer token to access the profile server * @constructor */ -var FxAccountsProfileClient = function(options) { +export var FxAccountsProfileClient = function(options) { if (!options || !options.serverURL) { throw new Error("Missing 'serverURL' configuration option"); } @@ -244,7 +239,7 @@ FxAccountsProfileClient.prototype = { * Error message * @constructor */ -var FxAccountsProfileClientError = function(details) { +export var FxAccountsProfileClientError = function(details) { details = details || {}; this.name = "FxAccountsProfileClientError"; diff --git a/services/fxaccounts/FxAccountsPush.jsm b/services/fxaccounts/FxAccountsPush.sys.mjs similarity index 99% rename from services/fxaccounts/FxAccountsPush.jsm rename to services/fxaccounts/FxAccountsPush.sys.mjs index 32160135cca1..05b56e61aa3f 100644 --- a/services/fxaccounts/FxAccountsPush.jsm +++ b/services/fxaccounts/FxAccountsPush.sys.mjs @@ -26,7 +26,7 @@ const { * Object, custom options that used for testing * @constructor */ -function FxAccountsPushService(options = {}) { +export function FxAccountsPushService(options = {}) { this.log = log; if (options.log) { @@ -312,5 +312,3 @@ FxAccountsPushService.prototype = { }); }, }; - -var EXPORTED_SYMBOLS = ["FxAccountsPushService"]; diff --git a/services/fxaccounts/FxAccountsStorage.jsm b/services/fxaccounts/FxAccountsStorage.sys.mjs similarity index 98% rename from services/fxaccounts/FxAccountsStorage.jsm rename to services/fxaccounts/FxAccountsStorage.sys.mjs index 7b1afba4f6c9..a3222275f1b2 100644 --- a/services/fxaccounts/FxAccountsStorage.jsm +++ b/services/fxaccounts/FxAccountsStorage.sys.mjs @@ -1,14 +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"; - -var EXPORTED_SYMBOLS = [ - "FxAccountsStorageManagerCanStoreField", - "FxAccountsStorageManager", - // Exported for tests. - "LoginManagerStorage", -]; const { DATA_FORMAT_VERSION, @@ -22,7 +14,7 @@ const { // A helper function so code can check what fields are able to be stored by // the storage manager without having a reference to a manager instance. -function FxAccountsStorageManagerCanStoreField(fieldName) { +export function FxAccountsStorageManagerCanStoreField(fieldName) { return ( FXA_PWDMGR_PLAINTEXT_FIELDS.has(fieldName) || FXA_PWDMGR_SECURE_FIELDS.has(fieldName) @@ -30,7 +22,7 @@ function FxAccountsStorageManagerCanStoreField(fieldName) { } // The storage manager object. -var FxAccountsStorageManager = function(options = {}) { +export var FxAccountsStorageManager = function(options = {}) { this.options = { filename: options.filename || DEFAULT_STORAGE_FILENAME, baseDir: options.baseDir || Services.dirsvc.get("ProfD", Ci.nsIFile).path, @@ -475,6 +467,7 @@ JSONStorage.prototype = { }; function StorageLockedError() {} + /** * LoginManagerStorage constructor that creates instances that set/get * data stored securely in the nsILoginManager. @@ -482,7 +475,7 @@ function StorageLockedError() {} * @return instance */ -function LoginManagerStorage() {} +export function LoginManagerStorage() {} LoginManagerStorage.prototype = { STORAGE_LOCKED: StorageLockedError, diff --git a/services/fxaccounts/FxAccountsTelemetry.jsm b/services/fxaccounts/FxAccountsTelemetry.sys.mjs similarity index 97% rename from services/fxaccounts/FxAccountsTelemetry.jsm rename to services/fxaccounts/FxAccountsTelemetry.sys.mjs index 1d8cb6fc6f21..b2b9f6ca3682 100644 --- a/services/fxaccounts/FxAccountsTelemetry.jsm +++ b/services/fxaccounts/FxAccountsTelemetry.sys.mjs @@ -2,16 +2,12 @@ * 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"; - // FxA Telemetry support. For hysterical raisins, the actual implementation // is inside "sync". We should move the core implementation somewhere that's // sanely shared (eg, services-common?), but let's wait and see where we end up // first... -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; const lazy = {}; @@ -34,7 +30,7 @@ XPCOMUtils.defineLazyPreferenceGetter( "" ); -class FxAccountsTelemetry { +export class FxAccountsTelemetry { constructor(fxai) { this._fxai = fxai; Services.telemetry.setEventRecordingEnabled("fxa", true); @@ -176,5 +172,3 @@ class FxAccountsTelemetry { } } } - -var EXPORTED_SYMBOLS = ["FxAccountsTelemetry"]; diff --git a/services/fxaccounts/FxAccountsWebChannel.jsm b/services/fxaccounts/FxAccountsWebChannel.sys.mjs similarity index 98% rename from services/fxaccounts/FxAccountsWebChannel.jsm rename to services/fxaccounts/FxAccountsWebChannel.sys.mjs index 50c85c953683..6e9faadc493f 100644 --- a/services/fxaccounts/FxAccountsWebChannel.jsm +++ b/services/fxaccounts/FxAccountsWebChannel.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"; /** * Firefox Accounts Web Channel. @@ -10,16 +9,8 @@ * about account state changes. */ -var EXPORTED_SYMBOLS = [ - "EnsureFxAccountsWebChannel", - // These are exported for tests. - "FxAccountsWebChannel", - "FxAccountsWebChannelHelpers", -]; +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); const { COMMAND_PROFILE_CHANGE, COMMAND_LOGIN, @@ -141,7 +132,7 @@ function getErrorDetails(error) { * Helpers functions. Should only be passed in for testing. * @constructor */ -function FxAccountsWebChannel(options) { +export function FxAccountsWebChannel(options) { if (!options) { throw new Error("Missing configuration options"); } @@ -406,7 +397,7 @@ FxAccountsWebChannel.prototype = { }, }; -function FxAccountsWebChannelHelpers(options) { +export function FxAccountsWebChannelHelpers(options) { options = options || {}; this._fxAccounts = options.fxAccounts || lazy.fxAccounts; @@ -743,12 +734,13 @@ FxAccountsWebChannelHelpers.prototype = { }; var singleton; + // The entry-point for this module, which ensures only one of our channels is // ever created - we require this because the WebChannel is global in scope // (eg, it uses the observer service to tell interested parties of interesting // things) and allowing multiple channels would cause such notifications to be // sent multiple times. -var EnsureFxAccountsWebChannel = () => { +export var EnsureFxAccountsWebChannel = () => { let contentUri = Services.urlFormatter.formatURLPref( "identity.fxaccounts.remote.root" ); diff --git a/services/fxaccounts/components.conf b/services/fxaccounts/components.conf index 74fb0bcf3eb1..992c88d0cbf8 100644 --- a/services/fxaccounts/components.conf +++ b/services/fxaccounts/components.conf @@ -8,7 +8,7 @@ Classes = [ { 'cid': '{1b7db999-2ecd-4abf-bb95-a726896798ca}', 'contract_ids': ['@mozilla.org/fxaccounts/push;1'], - 'jsm': 'resource://gre/modules/FxAccountsPush.jsm', + 'esModule': 'resource://gre/modules/FxAccountsPush.sys.mjs', 'constructor': 'FxAccountsPushService', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, 'categories': {'push': 'chrome://fxa-device-update'}, diff --git a/services/fxaccounts/moz.build b/services/fxaccounts/moz.build index 57cfb77e9bde..a99a5b0d591e 100644 --- a/services/fxaccounts/moz.build +++ b/services/fxaccounts/moz.build @@ -14,22 +14,22 @@ BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"] EXTRA_JS_MODULES += [ - "Credentials.jsm", - "FxAccounts.jsm", - "FxAccountsClient.jsm", - "FxAccountsCommands.js", + "Credentials.sys.mjs", + "FxAccounts.sys.mjs", + "FxAccountsClient.sys.mjs", + "FxAccountsCommands.sys.mjs", "FxAccountsCommon.js", - "FxAccountsConfig.jsm", - "FxAccountsDevice.jsm", - "FxAccountsKeys.jsm", - "FxAccountsPairing.jsm", - "FxAccountsPairingChannel.js", - "FxAccountsProfile.jsm", - "FxAccountsProfileClient.jsm", - "FxAccountsPush.jsm", - "FxAccountsStorage.jsm", - "FxAccountsTelemetry.jsm", - "FxAccountsWebChannel.jsm", + "FxAccountsConfig.sys.mjs", + "FxAccountsDevice.sys.mjs", + "FxAccountsKeys.sys.mjs", + "FxAccountsPairing.sys.mjs", + "FxAccountsPairingChannel.sys.mjs", + "FxAccountsProfile.sys.mjs", + "FxAccountsProfileClient.sys.mjs", + "FxAccountsPush.sys.mjs", + "FxAccountsStorage.sys.mjs", + "FxAccountsTelemetry.sys.mjs", + "FxAccountsWebChannel.sys.mjs", ] XPCOM_MANIFESTS += [