Bug 1817183 - Migrate most of services/fxaccounts to ES modules. r=markh

Differential Revision: https://phabricator.services.mozilla.com/D170061
This commit is contained in:
Mark Banner 2023-02-17 16:34:42 +00:00
parent 48a366e1ec
commit 0a0248d5ae
19 changed files with 67 additions and 130 deletions

View File

@ -183,7 +183,7 @@ services/common/kinto-http-client.js
services/common/kinto-offline-client.js services/common/kinto-offline-client.js
# Webpack-bundled library # Webpack-bundled library
services/fxaccounts/FxAccountsPairingChannel.js services/fxaccounts/FxAccountsPairingChannel.sys.mjs
# Servo is imported. # Servo is imported.
servo/ servo/

View File

@ -83,8 +83,8 @@ const startupPhases = {
"resource://gre/modules/BookmarkHTMLUtils.sys.mjs", "resource://gre/modules/BookmarkHTMLUtils.sys.mjs",
"resource://gre/modules/Bookmarks.sys.mjs", "resource://gre/modules/Bookmarks.sys.mjs",
"resource://gre/modules/ContextualIdentityService.sys.mjs", "resource://gre/modules/ContextualIdentityService.sys.mjs",
"resource://gre/modules/FxAccounts.jsm", "resource://gre/modules/FxAccounts.sys.mjs",
"resource://gre/modules/FxAccountsStorage.jsm", "resource://gre/modules/FxAccountsStorage.sys.mjs",
"resource://gre/modules/PlacesBackups.sys.mjs", "resource://gre/modules/PlacesBackups.sys.mjs",
"resource://gre/modules/PlacesExpiration.sys.mjs", "resource://gre/modules/PlacesExpiration.sys.mjs",
"resource://gre/modules/PlacesSyncUtils.sys.mjs", "resource://gre/modules/PlacesSyncUtils.sys.mjs",

View File

@ -9,13 +9,8 @@
* See https://github.com/mozilla/fxa-auth-server/wiki/onepw-protocol * 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( const { CryptoUtils } = ChromeUtils.import(
"resource://services-crypto/utils.js" "resource://services-crypto/utils.js"
); );
@ -45,7 +40,7 @@ var log = Log.repository.getLogger("Identity.FxAccounts");
log.level = LOG_LEVEL; log.level = LOG_LEVEL;
log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter())); log.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
var Credentials = Object.freeze({ export var Credentials = Object.freeze({
/** /**
* Make constants accessible to tests * Make constants accessible to tests
*/ */

View File

@ -1,20 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { PromiseUtils } = ChromeUtils.importESModule( import { PromiseUtils } from "resource://gre/modules/PromiseUtils.sys.mjs";
"resource://gre/modules/PromiseUtils.sys.mjs"
);
const { CryptoUtils } = ChromeUtils.import( const { CryptoUtils } = ChromeUtils.import(
"resource://services-crypto/utils.js" "resource://services-crypto/utils.js"
); );
const { XPCOMUtils } = ChromeUtils.importESModule( import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
"resource://gre/modules/XPCOMUtils.sys.mjs" import { clearTimeout, setTimeout } from "resource://gre/modules/Timer.sys.mjs";
);
const { clearTimeout, setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs"
);
const { FxAccountsStorageManager } = ChromeUtils.import( const { FxAccountsStorageManager } = ChromeUtils.import(
"resource://gre/modules/FxAccountsStorage.jsm" "resource://gre/modules/FxAccountsStorage.jsm"
); );
@ -129,7 +124,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
// } // }
// If the state has changed between the function being called and the promise // If the state has changed between the function being called and the promise
// being resolved, the .resolve() call will actually be rejected. // being resolved, the .resolve() call will actually be rejected.
function AccountState(storageManager) { export function AccountState(storageManager) {
this.storageManager = storageManager; this.storageManager = storageManager;
this.inFlightTokenRequests = new Map(); this.inFlightTokenRequests = new Map();
this.promiseInitialized = this.storageManager 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 * (although |./mach doc| is broken on windows (bug 1232403) and on Linux for
* markh (some obscure npm issue he gave up on) - so later...) * markh (some obscure npm issue he gave up on) - so later...)
*/ */
class FxAccounts { export class FxAccounts {
constructor(mocks = null) { constructor(mocks = null) {
this._internal = new FxAccountsInternal(); this._internal = new FxAccountsInternal();
if (mocks) { if (mocks) {
@ -1645,7 +1640,8 @@ FxAccountsInternal.prototype = {
}; };
let fxAccountsSingleton = null; let fxAccountsSingleton = null;
function getFxAccountsSingleton() {
export function getFxAccountsSingleton() {
if (fxAccountsSingleton) { if (fxAccountsSingleton) {
return fxAccountsSingleton; return fxAccountsSingleton;
} }
@ -1660,4 +1656,3 @@ function getFxAccountsSingleton() {
} }
// `AccountState` is exported for tests. // `AccountState` is exported for tests.
var EXPORTED_SYMBOLS = ["getFxAccountsSingleton", "FxAccounts", "AccountState"];

View File

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["FxAccountsClient"];
const { CommonUtils } = ChromeUtils.import( const { CommonUtils } = ChromeUtils.import(
"resource://services-common/utils.js" "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 // Devices older than this many days will not appear in the devices list
const DEVICES_FILTER_DAYS = 21; 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; this.host = host;
// The FxA auth server expects requests to certain endpoints to be authorized // The FxA auth server expects requests to certain endpoints to be authorized

View File

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const EXPORTED_SYMBOLS = ["SendTab", "FxAccountsCommands"];
const { const {
COMMAND_SENDTAB, COMMAND_SENDTAB,
COMMAND_SENDTAB_TAIL, COMMAND_SENDTAB_TAIL,
@ -16,9 +14,8 @@ ChromeUtils.defineModuleGetter(
"PushCrypto", "PushCrypto",
"resource://gre/modules/PushCrypto.jsm" "resource://gre/modules/PushCrypto.jsm"
); );
const { XPCOMUtils } = ChromeUtils.importESModule( import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { Observers } = ChromeUtils.import( const { Observers } = ChromeUtils.import(
"resource://services-common/observers.js" "resource://services-common/observers.js"
); );
@ -39,7 +36,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
} }
); );
class FxAccountsCommands { export class FxAccountsCommands {
constructor(fxAccountsInternal) { constructor(fxAccountsInternal) {
this._fxai = fxAccountsInternal; this._fxai = fxAccountsInternal;
this.sendTab = new SendTab(this, 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. * 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. * However, clients use the send-tab keys for end-to-end encryption.
*/ */
class SendTab { export class SendTab {
constructor(commands, fxAccountsInternal) { constructor(commands, fxAccountsInternal) {
this._commands = commands; this._commands = commands;
this._fxai = fxAccountsInternal; this._fxai = fxAccountsInternal;

View File

@ -1,8 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["FxAccountsConfig"];
const { RESTRequest } = ChromeUtils.import( const { RESTRequest } = ChromeUtils.import(
"resource://services-common/rest.js" "resource://services-common/rest.js"
@ -10,9 +8,7 @@ const { RESTRequest } = ChromeUtils.import(
const { log } = ChromeUtils.import( const { log } = ChromeUtils.import(
"resource://gre/modules/FxAccountsCommon.js" "resource://gre/modules/FxAccountsCommon.js"
); );
const { XPCOMUtils } = ChromeUtils.importESModule( import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -57,7 +53,7 @@ const CONFIG_PREFS = [
]; ];
const SYNC_PARAM = "sync"; const SYNC_PARAM = "sync";
var FxAccountsConfig = { export var FxAccountsConfig = {
async promiseEmailURI(email, entrypoint, extraParams = {}) { async promiseEmailURI(email, entrypoint, extraParams = {}) {
return this._buildURL("", { return this._buildURL("", {
extraParams: { entrypoint, email, service: SYNC_PARAM, ...extraParams }, extraParams: { entrypoint, email, service: SYNC_PARAM, ...extraParams },

View File

@ -1,11 +1,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { XPCOMUtils } = ChromeUtils.importESModule( import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { const {
log, log,
@ -57,7 +54,7 @@ function sanitizeDeviceName(name) {
} }
// Everything to do with FxA devices. // Everything to do with FxA devices.
class FxAccountsDevice { export class FxAccountsDevice {
constructor(fxai) { constructor(fxai) {
this._fxai = fxai; this._fxai = fxai;
this._deviceListCache = null; this._deviceListCache = null;
@ -653,5 +650,3 @@ FxAccountsDevice.prototype.QueryInterface = ChromeUtils.generateQI([
function urlsafeBase64Encode(buffer) { function urlsafeBase64Encode(buffer) {
return ChromeUtils.base64URLEncode(new Uint8Array(buffer), { pad: false }); return ChromeUtils.base64URLEncode(new Uint8Array(buffer), { pad: false });
} }
var EXPORTED_SYMBOLS = ["FxAccountsDevice"];

View File

@ -1,11 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { PromiseUtils } = ChromeUtils.importESModule( import { PromiseUtils } from "resource://gre/modules/PromiseUtils.sys.mjs";
"resource://gre/modules/PromiseUtils.sys.mjs"
);
const { CommonUtils } = ChromeUtils.import( const { CommonUtils } = ChromeUtils.import(
"resource://services-common/utils.js" "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` * possible. We intend to remove support for Firefox ever directly handling `kB`
* at some point in the future. * at some point in the future.
*/ */
class FxAccountsKeys { export class FxAccountsKeys {
constructor(fxAccountsInternal) { constructor(fxAccountsInternal) {
this._fxai = fxAccountsInternal; this._fxai = fxAccountsInternal;
} }
@ -749,5 +747,3 @@ class FxAccountsKeys {
return CryptoUtils.digestBytes(bytes, hasher); return CryptoUtils.digestBytes(bytes, hasher);
} }
} }
var EXPORTED_SYMBOLS = ["FxAccountsKeys"];

View File

@ -2,8 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // 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/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
"use strict";
const { const {
log, log,
PREF_REMOTE_PAIRING_URI, PREF_REMOTE_PAIRING_URI,
@ -17,9 +15,8 @@ const { getFxAccountsSingleton, FxAccounts } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm" "resource://gre/modules/FxAccounts.jsm"
); );
const fxAccounts = getFxAccountsSingleton(); const fxAccounts = getFxAccountsSingleton();
const { setTimeout, clearTimeout } = ChromeUtils.importESModule( import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs";
"resource://gre/modules/Timer.sys.mjs"
);
ChromeUtils.import("resource://services-common/utils.js"); ChromeUtils.import("resource://services-common/utils.js");
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
@ -173,7 +170,8 @@ class Errored extends State {
} }
const flows = new Map(); const flows = new Map();
class FxAccountsPairingFlow {
export class FxAccountsPairingFlow {
static get(channelId) { static get(channelId) {
return flows.get(channelId); return flows.get(channelId);
} }
@ -518,5 +516,3 @@ class FxAccountsPairingFlow {
); );
} }
} }
const EXPORTED_SYMBOLS = ["FxAccountsPairingFlow"];

View File

@ -22,15 +22,14 @@
// from Firefox browser code, hence the presence of these privileged browser APIs. // 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. // 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, // We cannot use WebSocket from chrome code without a window,
// see https://bugzilla.mozilla.org/show_bug.cgi?id=784686 // see https://bugzilla.mozilla.org/show_bug.cgi?id=784686
const browser = Services.appShell.createWindowlessBrowser(true); const browser = Services.appShell.createWindowlessBrowser(true);
const {WebSocket} = browser.document.ownerGlobal; const {WebSocket} = browser.document.ownerGlobal;
const EXPORTED_SYMBOLS = ["FxAccountsPairingChannel"]; export var FxAccountsPairingChannel =
var FxAccountsPairingChannel =
/******/ (function(modules) { // webpackBootstrap /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache /******/ // The module cache
/******/ var installedModules = {}; /******/ var installedModules = {};
@ -704,7 +703,7 @@ async function verifyHmac(keyBytes, signature, message) {
hash: { name: 'SHA-256' }, hash: { name: 'SHA-256' },
name: 'HMAC', name: 'HMAC',
}, false, ['verify']); }, 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, // Yes, we really do throw 'decrypt_error' when failing to verify a HMAC,
// and a 'bad_record_mac' error when failing to decrypt. // and a 'bad_record_mac' error when failing to decrypt.
throw new TLSError(ALERT_DESCRIPTION.DECRYPT_ERROR); throw new TLSError(ALERT_DESCRIPTION.DECRYPT_ERROR);

View File

@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/** /**
* Firefox Accounts Profile helper. * Firefox Accounts Profile helper.
* *
@ -12,8 +10,6 @@
* the user's profile in open browser tabs, and cacheing/invalidating profile data. * 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( const { ON_PROFILE_CHANGE_NOTIFICATION, log } = ChromeUtils.import(
"resource://gre/modules/FxAccountsCommon.js" "resource://gre/modules/FxAccountsCommon.js"
); );
@ -30,7 +26,7 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/FxAccountsProfileClient.jsm" "resource://gre/modules/FxAccountsProfileClient.jsm"
); );
var FxAccountsProfile = function(options = {}) { export var FxAccountsProfile = function(options = {}) {
this._currentFetchPromise = null; this._currentFetchPromise = null;
this._cachedAt = 0; // when we saved the cached version. this._cachedAt = 0; // when we saved the cached version.
this._isNotifying = false; // are we sending a notification? this._isNotifying = false; // are we sending a notification?

View File

@ -7,11 +7,6 @@
*/ */
"use strict;"; "use strict;";
var EXPORTED_SYMBOLS = [
"FxAccountsProfileClient",
"FxAccountsProfileClientError",
];
const { const {
ERRNO_NETWORK, ERRNO_NETWORK,
ERRNO_PARSE, ERRNO_PARSE,
@ -44,7 +39,7 @@ const { RESTRequest } = ChromeUtils.import(
* The bearer token to access the profile server * The bearer token to access the profile server
* @constructor * @constructor
*/ */
var FxAccountsProfileClient = function(options) { export var FxAccountsProfileClient = function(options) {
if (!options || !options.serverURL) { if (!options || !options.serverURL) {
throw new Error("Missing 'serverURL' configuration option"); throw new Error("Missing 'serverURL' configuration option");
} }
@ -244,7 +239,7 @@ FxAccountsProfileClient.prototype = {
* Error message * Error message
* @constructor * @constructor
*/ */
var FxAccountsProfileClientError = function(details) { export var FxAccountsProfileClientError = function(details) {
details = details || {}; details = details || {};
this.name = "FxAccountsProfileClientError"; this.name = "FxAccountsProfileClientError";

View File

@ -26,7 +26,7 @@ const {
* Object, custom options that used for testing * Object, custom options that used for testing
* @constructor * @constructor
*/ */
function FxAccountsPushService(options = {}) { export function FxAccountsPushService(options = {}) {
this.log = log; this.log = log;
if (options.log) { if (options.log) {
@ -312,5 +312,3 @@ FxAccountsPushService.prototype = {
}); });
}, },
}; };
var EXPORTED_SYMBOLS = ["FxAccountsPushService"];

View File

@ -1,14 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = [
"FxAccountsStorageManagerCanStoreField",
"FxAccountsStorageManager",
// Exported for tests.
"LoginManagerStorage",
];
const { const {
DATA_FORMAT_VERSION, DATA_FORMAT_VERSION,
@ -22,7 +14,7 @@ const {
// A helper function so code can check what fields are able to be stored by // 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. // the storage manager without having a reference to a manager instance.
function FxAccountsStorageManagerCanStoreField(fieldName) { export function FxAccountsStorageManagerCanStoreField(fieldName) {
return ( return (
FXA_PWDMGR_PLAINTEXT_FIELDS.has(fieldName) || FXA_PWDMGR_PLAINTEXT_FIELDS.has(fieldName) ||
FXA_PWDMGR_SECURE_FIELDS.has(fieldName) FXA_PWDMGR_SECURE_FIELDS.has(fieldName)
@ -30,7 +22,7 @@ function FxAccountsStorageManagerCanStoreField(fieldName) {
} }
// The storage manager object. // The storage manager object.
var FxAccountsStorageManager = function(options = {}) { export var FxAccountsStorageManager = function(options = {}) {
this.options = { this.options = {
filename: options.filename || DEFAULT_STORAGE_FILENAME, filename: options.filename || DEFAULT_STORAGE_FILENAME,
baseDir: options.baseDir || Services.dirsvc.get("ProfD", Ci.nsIFile).path, baseDir: options.baseDir || Services.dirsvc.get("ProfD", Ci.nsIFile).path,
@ -475,6 +467,7 @@ JSONStorage.prototype = {
}; };
function StorageLockedError() {} function StorageLockedError() {}
/** /**
* LoginManagerStorage constructor that creates instances that set/get * LoginManagerStorage constructor that creates instances that set/get
* data stored securely in the nsILoginManager. * data stored securely in the nsILoginManager.
@ -482,7 +475,7 @@ function StorageLockedError() {}
* @return instance * @return instance
*/ */
function LoginManagerStorage() {} export function LoginManagerStorage() {}
LoginManagerStorage.prototype = { LoginManagerStorage.prototype = {
STORAGE_LOCKED: StorageLockedError, STORAGE_LOCKED: StorageLockedError,

View File

@ -2,16 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// FxA Telemetry support. For hysterical raisins, the actual implementation // FxA Telemetry support. For hysterical raisins, the actual implementation
// is inside "sync". We should move the core implementation somewhere that's // 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 // sanely shared (eg, services-common?), but let's wait and see where we end up
// first... // first...
const { XPCOMUtils } = ChromeUtils.importESModule( import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {}; const lazy = {};
@ -34,7 +30,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
"" ""
); );
class FxAccountsTelemetry { export class FxAccountsTelemetry {
constructor(fxai) { constructor(fxai) {
this._fxai = fxai; this._fxai = fxai;
Services.telemetry.setEventRecordingEnabled("fxa", true); Services.telemetry.setEventRecordingEnabled("fxa", true);
@ -176,5 +172,3 @@ class FxAccountsTelemetry {
} }
} }
} }
var EXPORTED_SYMBOLS = ["FxAccountsTelemetry"];

View File

@ -1,7 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/** /**
* Firefox Accounts Web Channel. * Firefox Accounts Web Channel.
@ -10,16 +9,8 @@
* about account state changes. * about account state changes.
*/ */
var EXPORTED_SYMBOLS = [ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
"EnsureFxAccountsWebChannel",
// These are exported for tests.
"FxAccountsWebChannel",
"FxAccountsWebChannelHelpers",
];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { const {
COMMAND_PROFILE_CHANGE, COMMAND_PROFILE_CHANGE,
COMMAND_LOGIN, COMMAND_LOGIN,
@ -141,7 +132,7 @@ function getErrorDetails(error) {
* Helpers functions. Should only be passed in for testing. * Helpers functions. Should only be passed in for testing.
* @constructor * @constructor
*/ */
function FxAccountsWebChannel(options) { export function FxAccountsWebChannel(options) {
if (!options) { if (!options) {
throw new Error("Missing configuration options"); throw new Error("Missing configuration options");
} }
@ -406,7 +397,7 @@ FxAccountsWebChannel.prototype = {
}, },
}; };
function FxAccountsWebChannelHelpers(options) { export function FxAccountsWebChannelHelpers(options) {
options = options || {}; options = options || {};
this._fxAccounts = options.fxAccounts || lazy.fxAccounts; this._fxAccounts = options.fxAccounts || lazy.fxAccounts;
@ -743,12 +734,13 @@ FxAccountsWebChannelHelpers.prototype = {
}; };
var singleton; var singleton;
// The entry-point for this module, which ensures only one of our channels is // 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 // ever created - we require this because the WebChannel is global in scope
// (eg, it uses the observer service to tell interested parties of interesting // (eg, it uses the observer service to tell interested parties of interesting
// things) and allowing multiple channels would cause such notifications to be // things) and allowing multiple channels would cause such notifications to be
// sent multiple times. // sent multiple times.
var EnsureFxAccountsWebChannel = () => { export var EnsureFxAccountsWebChannel = () => {
let contentUri = Services.urlFormatter.formatURLPref( let contentUri = Services.urlFormatter.formatURLPref(
"identity.fxaccounts.remote.root" "identity.fxaccounts.remote.root"
); );

View File

@ -8,7 +8,7 @@ Classes = [
{ {
'cid': '{1b7db999-2ecd-4abf-bb95-a726896798ca}', 'cid': '{1b7db999-2ecd-4abf-bb95-a726896798ca}',
'contract_ids': ['@mozilla.org/fxaccounts/push;1'], 'contract_ids': ['@mozilla.org/fxaccounts/push;1'],
'jsm': 'resource://gre/modules/FxAccountsPush.jsm', 'esModule': 'resource://gre/modules/FxAccountsPush.sys.mjs',
'constructor': 'FxAccountsPushService', 'constructor': 'FxAccountsPushService',
'processes': ProcessSelector.MAIN_PROCESS_ONLY, 'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'categories': {'push': 'chrome://fxa-device-update'}, 'categories': {'push': 'chrome://fxa-device-update'},

View File

@ -14,22 +14,22 @@ BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"] XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
EXTRA_JS_MODULES += [ EXTRA_JS_MODULES += [
"Credentials.jsm", "Credentials.sys.mjs",
"FxAccounts.jsm", "FxAccounts.sys.mjs",
"FxAccountsClient.jsm", "FxAccountsClient.sys.mjs",
"FxAccountsCommands.js", "FxAccountsCommands.sys.mjs",
"FxAccountsCommon.js", "FxAccountsCommon.js",
"FxAccountsConfig.jsm", "FxAccountsConfig.sys.mjs",
"FxAccountsDevice.jsm", "FxAccountsDevice.sys.mjs",
"FxAccountsKeys.jsm", "FxAccountsKeys.sys.mjs",
"FxAccountsPairing.jsm", "FxAccountsPairing.sys.mjs",
"FxAccountsPairingChannel.js", "FxAccountsPairingChannel.sys.mjs",
"FxAccountsProfile.jsm", "FxAccountsProfile.sys.mjs",
"FxAccountsProfileClient.jsm", "FxAccountsProfileClient.sys.mjs",
"FxAccountsPush.jsm", "FxAccountsPush.sys.mjs",
"FxAccountsStorage.jsm", "FxAccountsStorage.sys.mjs",
"FxAccountsTelemetry.jsm", "FxAccountsTelemetry.sys.mjs",
"FxAccountsWebChannel.jsm", "FxAccountsWebChannel.sys.mjs",
] ]
XPCOM_MANIFESTS += [ XPCOM_MANIFESTS += [