Bug 1816416 - Convert services/sync/modules/constants.js to ESM. r=Standard8,credential-management-reviewers,sync-reviewers,dimi,skhamis

Differential Revision: https://phabricator.services.mozilla.com/D175842
This commit is contained in:
Mathew Hodson
2023-04-19 21:19:53 +00:00
parent 9c7817338f
commit 07d4f22260
30 changed files with 214 additions and 218 deletions

View File

@@ -12,8 +12,8 @@
const { Service } = ChromeUtils.importESModule(
"resource://services-sync/service.sys.mjs"
);
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.importESModule(
"resource://services-sync/constants.sys.mjs"
);
const {

View File

@@ -16,9 +16,7 @@ const {
PREF_ACCOUNT_ROOT,
} = ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
const { DEVICE_TYPE_DESKTOP } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { DEVICE_TYPE_DESKTOP } from "resource://services-sync/constants.sys.mjs";
const lazy = {};

View File

@@ -5,11 +5,14 @@
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { Log } from "resource://gre/modules/Log.sys.mjs";
import { Weave } from "resource://services-sync/main.sys.mjs";
import { Preferences } from "resource://gre/modules/Preferences.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
CLIENT_NOT_CONFIGURED: "resource://services-sync/constants.sys.mjs",
Preferences: "resource://gre/modules/Preferences.sys.mjs",
Weave: "resource://services-sync/main.sys.mjs",
});
// The Sync XPCOM service
XPCOMUtils.defineLazyGetter(lazy, "weaveXPCService", function() {
return Cc["@mozilla.org/weave/service;1"].getService(
@@ -67,8 +70,8 @@ let SyncedTabsInternal = {
return {
id: client.id,
type: "client",
name: Weave.Service.clientsEngine.getClientName(client.id),
clientType: Weave.Service.clientsEngine.getClientType(client.id),
name: lazy.Weave.Service.clientsEngine.getClientName(client.id),
clientType: lazy.Weave.Service.clientsEngine.getClientType(client.id),
lastModified: client.lastModified * 1000, // sec to ms
tabs: [],
};
@@ -115,17 +118,17 @@ let SyncedTabsInternal = {
}
// A boolean that controls whether we should show the icon from the remote tab.
const showRemoteIcons = Preferences.get(
const showRemoteIcons = lazy.Preferences.get(
"services.sync.syncedTabs.showRemoteIcons",
true
);
let engine = Weave.Service.engineManager.get("tabs");
let engine = lazy.Weave.Service.engineManager.get("tabs");
let ntabs = 0;
let clientTabList = await engine.getAllClients();
for (let client of clientTabList) {
if (!Weave.Service.clientsEngine.remoteClientExists(client.id)) {
if (!lazy.Weave.Service.clientsEngine.remoteClientExists(client.id)) {
continue;
}
let clientRepr = await this._makeClient(client);
@@ -158,7 +161,7 @@ let SyncedTabsInternal = {
async syncTabs(force) {
if (!force) {
// Don't bother refetching tabs if we already did so recently
let lastFetch = Preferences.get("services.sync.lastTabFetch", 0);
let lastFetch = lazy.Preferences.get("services.sync.lastTabFetch", 0);
let now = Math.floor(Date.now() / 1000);
if (now - lastFetch < TABS_FRESH_ENOUGH_INTERVAL_SECONDS) {
lazy.log.info("_refetchTabs was done recently, do not doing it again");
@@ -168,24 +171,24 @@ let SyncedTabsInternal = {
// If Sync isn't configured don't try and sync, else we will get reports
// of a login failure.
if (Weave.Status.checkSetup() === Weave.CLIENT_NOT_CONFIGURED) {
if (lazy.Weave.Status.checkSetup() === lazy.CLIENT_NOT_CONFIGURED) {
lazy.log.info(
"Sync client is not configured, so not attempting a tab sync"
);
return false;
}
// If the primary pass is locked, we should not try to sync
if (Weave.Utils.mpLocked()) {
if (lazy.Weave.Utils.mpLocked()) {
lazy.log.info(
"Can't sync tabs due to the primary password being locked",
Weave.Status.login
lazy.Weave.Status.login
);
return false;
}
// Ask Sync to just do the tabs engine if it can.
try {
lazy.log.info("Doing a tab sync.");
await Weave.Service.sync({ why: "tabs", engines: ["tabs"] });
await lazy.Weave.Service.sync({ why: "tabs", engines: ["tabs"] });
return true;
} catch (ex) {
lazy.log.error("Sync failed", ex);
@@ -203,7 +206,7 @@ let SyncedTabsInternal = {
// The tabs engine just finished syncing
// Set our lastTabFetch pref here so it tracks both explicit sync calls
// and normally scheduled ones.
Preferences.set(
lazy.Preferences.set(
"services.sync.lastTabFetch",
Math.floor(Date.now() / 1000)
);
@@ -211,7 +214,7 @@ let SyncedTabsInternal = {
break;
case "weave:service:start-over":
// start-over needs to notify so consumers find no tabs.
Preferences.reset("services.sync.lastTabFetch");
lazy.Preferences.reset("services.sync.lastTabFetch");
Services.obs.notifyObservers(null, TOPIC_TABS_CHANGED);
break;
case "nsPref:changed":
@@ -229,12 +232,12 @@ let SyncedTabsInternal = {
return true;
}
let engine = Weave.Service.engineManager.get("tabs");
let engine = lazy.Weave.Service.engineManager.get("tabs");
return engine && engine.enabled;
},
get hasSyncedThisSession() {
let engine = Weave.Service.engineManager.get("tabs");
let engine = lazy.Weave.Service.engineManager.get("tabs");
return engine && engine.hasSyncedThisSession;
},
};

View File

@@ -14,6 +14,7 @@
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
LOGIN_FAILED_LOGIN_REJECTED: "resource://services-sync/constants.sys.mjs",
Weave: "resource://services-sync/main.sys.mjs",
});
@@ -219,7 +220,7 @@ const UIStateInternal = {
// LOGIN_FAILED_LOGIN_REJECTED explicitly means "you must log back in".
// All other login failures are assumed to be transient and should go
// away by themselves, so aren't reflected here.
return lazy.Weave.Status.login == lazy.Weave.LOGIN_FAILED_LOGIN_REJECTED;
return lazy.Weave.Status.login == lazy.LOGIN_FAILED_LOGIN_REJECTED;
},
set fxAccounts(mockFxAccounts) {

View File

@@ -1,136 +0,0 @@
/* 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/. */
// Process each item in the "constants hash" to add to "global" and give a name
var EXPORTED_SYMBOLS = [];
for (let [key, val] of Object.entries({
// Don't manually modify this line, as it is automatically replaced on merge day
// by the gecko_migration.py script.
WEAVE_VERSION: "1.116.0",
// Sync Server API version that the client supports.
SYNC_API_VERSION: "1.5",
// Version of the data format this client supports. The data format describes
// how records are packaged; this is separate from the Server API version and
// the per-engine cleartext formats.
STORAGE_VERSION: 5,
PREFS_BRANCH: "services.sync.",
// Put in [] because those aren't allowed in a collection name.
DEFAULT_KEYBUNDLE_NAME: "[default]",
// Key dimensions.
SYNC_KEY_ENCODED_LENGTH: 26,
SYNC_KEY_DECODED_LENGTH: 16,
NO_SYNC_NODE_INTERVAL: 10 * 60 * 1000, // 10 minutes
MAX_ERROR_COUNT_BEFORE_BACKOFF: 3,
// Backoff intervals
MINIMUM_BACKOFF_INTERVAL: 15 * 60 * 1000, // 15 minutes
MAXIMUM_BACKOFF_INTERVAL: 8 * 60 * 60 * 1000, // 8 hours
// HMAC event handling timeout.
// 10 minutes: a compromise between the multi-desktop sync interval
// and the mobile sync interval.
HMAC_EVENT_INTERVAL: 600000,
// How long to wait between sync attempts if the Master Password is locked.
MASTER_PASSWORD_LOCKED_RETRY_INTERVAL: 15 * 60 * 1000, // 15 minutes
// 50 is hardcoded here because of URL length restrictions.
// (GUIDs can be up to 64 chars long.)
// Individual engines can set different values for their limit if their
// identifiers are shorter.
DEFAULT_GUID_FETCH_BATCH_SIZE: 50,
// Default batch size for download batching
// (how many records are fetched at a time from the server when batching is used).
DEFAULT_DOWNLOAD_BATCH_SIZE: 1000,
// score thresholds for early syncs
SINGLE_USER_THRESHOLD: 1000,
MULTI_DEVICE_THRESHOLD: 300,
// Other score increment constants
SCORE_INCREMENT_SMALL: 1,
SCORE_INCREMENT_MEDIUM: 10,
// Instant sync score increment
SCORE_INCREMENT_XLARGE: 300 + 1, //MULTI_DEVICE_THRESHOLD + 1
// Delay before incrementing global score
SCORE_UPDATE_DELAY: 100,
// Delay for the back observer debouncer. This is chosen to be longer than any
// observed spurious idle/back events and short enough to pre-empt user activity.
IDLE_OBSERVER_BACK_DELAY: 100,
// Duplicate URI_LENGTH_MAX from Places (from nsNavHistory.h), used to discard
// tabs with huge uris during tab sync.
URI_LENGTH_MAX: 65536,
MAX_HISTORY_UPLOAD: 5000,
MAX_HISTORY_DOWNLOAD: 5000,
// Top-level statuses:
STATUS_OK: "success.status_ok",
SYNC_FAILED: "error.sync.failed",
LOGIN_FAILED: "error.login.failed",
SYNC_FAILED_PARTIAL: "error.sync.failed_partial",
CLIENT_NOT_CONFIGURED: "service.client_not_configured",
STATUS_DISABLED: "service.disabled",
MASTER_PASSWORD_LOCKED: "service.master_password_locked",
// success states
LOGIN_SUCCEEDED: "success.login",
SYNC_SUCCEEDED: "success.sync",
ENGINE_SUCCEEDED: "success.engine",
// login failure status codes:
LOGIN_FAILED_NO_USERNAME: "error.login.reason.no_username",
LOGIN_FAILED_NO_PASSPHRASE: "error.login.reason.no_recoverykey",
LOGIN_FAILED_NETWORK_ERROR: "error.login.reason.network",
LOGIN_FAILED_SERVER_ERROR: "error.login.reason.server",
LOGIN_FAILED_INVALID_PASSPHRASE: "error.login.reason.recoverykey",
LOGIN_FAILED_LOGIN_REJECTED: "error.login.reason.account",
// sync failure status codes
METARECORD_DOWNLOAD_FAIL: "error.sync.reason.metarecord_download_fail",
VERSION_OUT_OF_DATE: "error.sync.reason.version_out_of_date",
CREDENTIALS_CHANGED: "error.sync.reason.credentials_changed",
ABORT_SYNC_COMMAND: "aborting sync, process commands said so",
NO_SYNC_NODE_FOUND: "error.sync.reason.no_node_found",
OVER_QUOTA: "error.sync.reason.over_quota",
SERVER_MAINTENANCE: "error.sync.reason.serverMaintenance",
RESPONSE_OVER_QUOTA: "14",
// engine failure status codes
ENGINE_UPLOAD_FAIL: "error.engine.reason.record_upload_fail",
ENGINE_DOWNLOAD_FAIL: "error.engine.reason.record_download_fail",
ENGINE_UNKNOWN_FAIL: "error.engine.reason.unknown_fail",
ENGINE_APPLY_FAIL: "error.engine.reason.apply_fail",
// an upload failure where the batch was interrupted with a 412
ENGINE_BATCH_INTERRUPTED: "error.engine.reason.batch_interrupted",
// Ways that a sync can be disabled (messages only to be printed in debug log)
kSyncMasterPasswordLocked: "User elected to leave Primary Password locked",
kSyncWeaveDisabled: "Weave is disabled",
kSyncNetworkOffline: "Network is offline",
kSyncBackoffNotMet: "Trying to sync before the server said it's okay",
kFirstSyncChoiceNotMade: "User has not selected an action for first sync",
kSyncNotConfigured: "Sync is not configured",
kFirefoxShuttingDown: "Firefox is about to shut down",
DEVICE_TYPE_DESKTOP: "desktop",
DEVICE_TYPE_MOBILE: "mobile",
SQLITE_MAX_VARIABLE_NUMBER: 999,
})) {
this[key] = val;
this.EXPORTED_SYMBOLS.push(key);
}

View File

@@ -0,0 +1,133 @@
/* 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/. */
// Don't manually modify this line, as it is automatically replaced on merge day
// by the gecko_migration.py script.
export const WEAVE_VERSION = "1.116.0";
// Sync Server API version that the client supports.
export const SYNC_API_VERSION = "1.5";
// Version of the data format this client supports. The data format describes
// how records are packaged; this is separate from the Server API version and
// the per-engine cleartext formats.
export const STORAGE_VERSION = 5;
export const PREFS_BRANCH = "services.sync.";
// Put in [] because those aren't allowed in a collection name.
export const DEFAULT_KEYBUNDLE_NAME = "[default]";
// Key dimensions.
export const SYNC_KEY_ENCODED_LENGTH = 26;
export const SYNC_KEY_DECODED_LENGTH = 16;
export const NO_SYNC_NODE_INTERVAL = 10 * 60 * 1000; // 10 minutes
export const MAX_ERROR_COUNT_BEFORE_BACKOFF = 3;
// Backoff intervals
export const MINIMUM_BACKOFF_INTERVAL = 15 * 60 * 1000; // 15 minutes
export const MAXIMUM_BACKOFF_INTERVAL = 8 * 60 * 60 * 1000; // 8 hours
// HMAC event handling timeout.
// 10 minutes = a compromise between the multi-desktop sync interval
// and the mobile sync interval.
export const HMAC_EVENT_INTERVAL = 600000;
// How long to wait between sync attempts if the Master Password is locked.
export const MASTER_PASSWORD_LOCKED_RETRY_INTERVAL = 15 * 60 * 1000; // 15 minutes
// 50 is hardcoded here because of URL length restrictions.
// (GUIDs can be up to 64 chars long.)
// Individual engines can set different values for their limit if their
// identifiers are shorter.
export const DEFAULT_GUID_FETCH_BATCH_SIZE = 50;
// Default batch size for download batching
// (how many records are fetched at a time from the server when batching is used).
export const DEFAULT_DOWNLOAD_BATCH_SIZE = 1000;
// score thresholds for early syncs
export const SINGLE_USER_THRESHOLD = 1000;
export const MULTI_DEVICE_THRESHOLD = 300;
// Other score increment constants
export const SCORE_INCREMENT_SMALL = 1;
export const SCORE_INCREMENT_MEDIUM = 10;
// Instant sync score increment
export const SCORE_INCREMENT_XLARGE = 300 + 1; //MULTI_DEVICE_THRESHOLD + 1
// Delay before incrementing global score
export const SCORE_UPDATE_DELAY = 100;
// Delay for the back observer debouncer. This is chosen to be longer than any
// observed spurious idle/back events and short enough to pre-empt user activity.
export const IDLE_OBSERVER_BACK_DELAY = 100;
// Duplicate URI_LENGTH_MAX from Places (from nsNavHistory.h), used to discard
// tabs with huge uris during tab sync.
export const URI_LENGTH_MAX = 65536;
export const MAX_HISTORY_UPLOAD = 5000;
export const MAX_HISTORY_DOWNLOAD = 5000;
// Top-level statuses
export const STATUS_OK = "success.status_ok";
export const SYNC_FAILED = "error.sync.failed";
export const LOGIN_FAILED = "error.login.failed";
export const SYNC_FAILED_PARTIAL = "error.sync.failed_partial";
export const CLIENT_NOT_CONFIGURED = "service.client_not_configured";
export const STATUS_DISABLED = "service.disabled";
export const MASTER_PASSWORD_LOCKED = "service.master_password_locked";
// success states
export const LOGIN_SUCCEEDED = "success.login";
export const SYNC_SUCCEEDED = "success.sync";
export const ENGINE_SUCCEEDED = "success.engine";
// login failure status codes
export const LOGIN_FAILED_NO_USERNAME = "error.login.reason.no_username";
export const LOGIN_FAILED_NO_PASSPHRASE = "error.login.reason.no_recoverykey";
export const LOGIN_FAILED_NETWORK_ERROR = "error.login.reason.network";
export const LOGIN_FAILED_SERVER_ERROR = "error.login.reason.server";
export const LOGIN_FAILED_INVALID_PASSPHRASE = "error.login.reason.recoverykey";
export const LOGIN_FAILED_LOGIN_REJECTED = "error.login.reason.account";
// sync failure status codes
export const METARECORD_DOWNLOAD_FAIL =
"error.sync.reason.metarecord_download_fail";
export const VERSION_OUT_OF_DATE = "error.sync.reason.version_out_of_date";
export const CREDENTIALS_CHANGED = "error.sync.reason.credentials_changed";
export const ABORT_SYNC_COMMAND = "aborting sync, process commands said so";
export const NO_SYNC_NODE_FOUND = "error.sync.reason.no_node_found";
export const OVER_QUOTA = "error.sync.reason.over_quota";
export const SERVER_MAINTENANCE = "error.sync.reason.serverMaintenance";
export const RESPONSE_OVER_QUOTA = "14";
// engine failure status codes
export const ENGINE_UPLOAD_FAIL = "error.engine.reason.record_upload_fail";
export const ENGINE_DOWNLOAD_FAIL = "error.engine.reason.record_download_fail";
export const ENGINE_UNKNOWN_FAIL = "error.engine.reason.unknown_fail";
export const ENGINE_APPLY_FAIL = "error.engine.reason.apply_fail";
// an upload failure where the batch was interrupted with a 412
export const ENGINE_BATCH_INTERRUPTED = "error.engine.reason.batch_interrupted";
// Ways that a sync can be disabled (messages only to be printed in debug log)
export const kSyncMasterPasswordLocked =
"User elected to leave Primary Password locked";
export const kSyncWeaveDisabled = "Weave is disabled";
export const kSyncNetworkOffline = "Network is offline";
export const kSyncBackoffNotMet =
"Trying to sync before the server said it's okay";
export const kFirstSyncChoiceNotMade =
"User has not selected an action for first sync";
export const kSyncNotConfigured = "Sync is not configured";
export const kFirefoxShuttingDown = "Firefox is about to shut down";
export const DEVICE_TYPE_DESKTOP = "desktop";
export const DEVICE_TYPE_MOBILE = "mobile";
export const SQLITE_MAX_VARIABLE_NUMBER = 999;

View File

@@ -10,14 +10,15 @@ import { Log } from "resource://gre/modules/Log.sys.mjs";
import { Async } from "resource://services-common/async.sys.mjs";
import { Observers } from "resource://services-common/observers.sys.mjs";
const {
import {
DEFAULT_DOWNLOAD_BATCH_SIZE,
DEFAULT_GUID_FETCH_BATCH_SIZE,
ENGINE_BATCH_INTERRUPTED,
ENGINE_DOWNLOAD_FAIL,
ENGINE_UPLOAD_FAIL,
VERSION_OUT_OF_DATE,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import {
Collection,
CryptoWrapper,

View File

@@ -47,9 +47,7 @@ import {
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { SCORE_INCREMENT_XLARGE } from "resource://services-sync/constants.sys.mjs";
import { CollectionValidator } from "resource://services-sync/collection_validator.sys.mjs";
const lazy = {};

View File

@@ -6,9 +6,7 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { Async } from "resource://services-common/async.sys.mjs";
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { SCORE_INCREMENT_XLARGE } from "resource://services-sync/constants.sys.mjs";
import {
Changeset,
Store,

View File

@@ -22,12 +22,13 @@
import { Async } from "resource://services-common/async.sys.mjs";
const {
import {
DEVICE_TYPE_DESKTOP,
DEVICE_TYPE_MOBILE,
SINGLE_USER_THRESHOLD,
SYNC_API_VERSION,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import {
Store,
SyncEngine,

View File

@@ -14,7 +14,9 @@ import { SyncEngine, Tracker } from "resource://services-sync/engines.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
MULTI_DEVICE_THRESHOLD: "resource://services-sync/constants.sys.mjs",
Observers: "resource://services-common/observers.sys.mjs",
SCORE_INCREMENT_MEDIUM: "resource://services-sync/constants.sys.mjs",
Svc: "resource://services-sync/util.sys.mjs",
});
@@ -22,8 +24,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
extensionStorageSync: "resource://gre/modules/ExtensionStorageSync.jsm",
extensionStorageSyncKinto:
"resource://gre/modules/ExtensionStorageSyncKinto.jsm",
SCORE_INCREMENT_MEDIUM: "resource://services-sync/constants.js",
MULTI_DEVICE_THRESHOLD: "resource://services-sync/constants.js",
});
XPCOMUtils.defineLazyServiceGetter(

View File

@@ -11,9 +11,7 @@ import {
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
const { SCORE_INCREMENT_MEDIUM } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { SCORE_INCREMENT_MEDIUM } from "resource://services-sync/constants.sys.mjs";
import {
CollectionProblemData,
CollectionValidator,

View File

@@ -8,12 +8,13 @@ const THIRTY_DAYS_IN_MS = 2592000000; // 30 days in milliseconds
import { Async } from "resource://services-common/async.sys.mjs";
import { CommonUtils } from "resource://services-common/utils.sys.mjs";
const {
import {
MAX_HISTORY_DOWNLOAD,
MAX_HISTORY_UPLOAD,
SCORE_INCREMENT_SMALL,
SCORE_INCREMENT_XLARGE,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import {
Store,
SyncEngine,

View File

@@ -7,9 +7,7 @@ import {
CryptoWrapper,
} from "resource://services-sync/record.sys.mjs";
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { SCORE_INCREMENT_XLARGE } from "resource://services-sync/constants.sys.mjs";
import { CollectionValidator } from "resource://services-sync/collection_validator.sys.mjs";
import {
Store,

View File

@@ -35,10 +35,7 @@ import {
} from "resource://services-sync/engines.sys.mjs";
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { SCORE_INCREMENT_XLARGE } from "resource://services-sync/constants.sys.mjs";
import { CommonUtils } from "resource://services-common/utils.sys.mjs";
const lazy = {};

View File

@@ -10,9 +10,11 @@ import { SyncEngine, Tracker } from "resource://services-sync/engines.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
import { Log } from "resource://gre/modules/Log.sys.mjs";
const { SCORE_INCREMENT_SMALL, STATUS_OK, URI_LENGTH_MAX } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import {
SCORE_INCREMENT_SMALL,
STATUS_OK,
URI_LENGTH_MAX,
} from "resource://services-sync/constants.sys.mjs";
import { CommonUtils } from "resource://services-common/utils.sys.mjs";
import { Async } from "resource://services-common/async.sys.mjs";

View File

@@ -2,23 +2,22 @@
* 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/. */
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
export { lazy as Weave };
export const Weave = ChromeUtils.import(
"resource://services-sync/constants.js"
);
const lazy = {};
// We want these to be lazily loaded, which helps performance and also tests
// to not have these loaded before they are ready.
// eslint-disable-next-line mozilla/lazy-getter-object-name
ChromeUtils.defineESModuleGetters(Weave, {
// eslint-disable-next-line mozilla/valid-lazy
ChromeUtils.defineESModuleGetters(lazy, {
Service: "resource://services-sync/service.sys.mjs",
Status: "resource://services-sync/status.sys.mjs",
Svc: "resource://services-sync/util.sys.mjs",
Utils: "resource://services-sync/util.sys.mjs",
});
XPCOMUtils.defineLazyGetter(Weave, "Crypto", function() {
// eslint-disable-next-line mozilla/valid-lazy
ChromeUtils.defineLazyGetter(lazy, "Crypto", () => {
let { WeaveCrypto } = ChromeUtils.importESModule(
"resource://services-crypto/WeaveCrypto.sys.mjs"
);

View File

@@ -6,7 +6,7 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { Log } from "resource://gre/modules/Log.sys.mjs";
const {
import {
CREDENTIALS_CHANGED,
ENGINE_APPLY_FAIL,
ENGINE_UNKNOWN_FAIL,
@@ -33,7 +33,8 @@ const {
SYNC_SUCCEEDED,
kSyncBackoffNotMet,
kSyncMasterPasswordLocked,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
const { logManager } = ChromeUtils.import(

View File

@@ -7,10 +7,10 @@ const KEYS_WBO = "keys";
import { Log } from "resource://gre/modules/Log.sys.mjs";
const {
import {
DEFAULT_DOWNLOAD_BATCH_SIZE,
DEFAULT_KEYBUNDLE_NAME,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import { BulkKeyBundle } from "resource://services-sync/keys.sys.mjs";
import { Weave } from "resource://services-sync/main.sys.mjs";
import { Resource } from "resource://services-sync/resource.sys.mjs";

View File

@@ -12,7 +12,7 @@ import { Log } from "resource://gre/modules/Log.sys.mjs";
import { Async } from "resource://services-common/async.sys.mjs";
import { CommonUtils } from "resource://services-common/utils.sys.mjs";
const {
import {
CLIENT_NOT_CONFIGURED,
CREDENTIALS_CHANGED,
HMAC_EVENT_INTERVAL,
@@ -39,7 +39,8 @@ const {
kSyncNetworkOffline,
kSyncNotConfigured,
kSyncWeaveDisabled,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import { EngineManager } from "resource://services-sync/engines.sys.mjs";
import { ClientEngine } from "resource://services-sync/engines/clients.sys.mjs";
import { Weave } from "resource://services-sync/main.sys.mjs";

View File

@@ -8,7 +8,7 @@
import { Log } from "resource://gre/modules/Log.sys.mjs";
const {
import {
ABORT_SYNC_COMMAND,
LOGIN_FAILED_NETWORK_ERROR,
NO_SYNC_NODE_FOUND,
@@ -17,7 +17,8 @@ const {
SYNC_SUCCEEDED,
WEAVE_VERSION,
kSyncNetworkOffline,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
import { Async } from "resource://services-common/async.sys.mjs";

View File

@@ -2,7 +2,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 {
import {
CLIENT_NOT_CONFIGURED,
ENGINE_SUCCEEDED,
LOGIN_FAILED,
@@ -13,7 +13,8 @@ const {
SYNC_FAILED,
SYNC_FAILED_PARTIAL,
SYNC_SUCCEEDED,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import { Log } from "resource://gre/modules/Log.sys.mjs";
import { SyncAuthManager } from "resource://services-sync/sync_auth.sys.mjs";

View File

@@ -10,14 +10,14 @@ import { TokenServerClient } from "resource://services-common/tokenserverclient.
import { CryptoUtils } from "resource://services-crypto/utils.sys.mjs";
import { Svc, Utils } from "resource://services-sync/util.sys.mjs";
const {
import {
LOGIN_FAILED_LOGIN_REJECTED,
LOGIN_FAILED_NETWORK_ERROR,
LOGIN_FAILED_NO_USERNAME,
LOGIN_SUCCEEDED,
MASTER_PASSWORD_LOCKED,
STATUS_OK,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
const lazy = {};

View File

@@ -42,7 +42,7 @@ XPCOMUtils.defineLazyGetter(lazy, "fxAccounts", () => {
).getFxAccountsSingleton();
});
let constants = ChromeUtils.import("resource://services-sync/constants.js");
import * as constants from "resource://services-sync/constants.sys.mjs";
XPCOMUtils.defineLazyGetter(
lazy,

View File

@@ -7,14 +7,15 @@ import { Observers } from "resource://services-common/observers.sys.mjs";
import { CommonUtils } from "resource://services-common/utils.sys.mjs";
import { CryptoUtils } from "resource://services-crypto/utils.sys.mjs";
const {
import {
DEVICE_TYPE_DESKTOP,
MAXIMUM_BACKOFF_INTERVAL,
PREFS_BRANCH,
SYNC_KEY_DECODED_LENGTH,
SYNC_KEY_ENCODED_LENGTH,
WEAVE_VERSION,
} = ChromeUtils.import("resource://services-sync/constants.js");
} from "resource://services-sync/constants.sys.mjs";
import { Preferences } from "resource://gre/modules/Preferences.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

View File

@@ -20,7 +20,7 @@ EXTRA_JS_MODULES["services-sync"] += [
"modules/addonutils.sys.mjs",
"modules/bridged_engine.sys.mjs",
"modules/collection_validator.sys.mjs",
"modules/constants.js",
"modules/constants.sys.mjs",
"modules/doctor.sys.mjs",
"modules/engines.sys.mjs",
"modules/keys.sys.mjs",

View File

@@ -82,7 +82,7 @@ var {
kSyncNetworkOffline,
kSyncNotConfigured,
kSyncWeaveDisabled,
} = ChromeUtils.import("resource://services-sync/constants.js");
} = ChromeUtils.importESModule("resource://services-sync/constants.sys.mjs");
var { BulkKeyBundle, SyncKeyBundle } = ChromeUtils.importESModule(
"resource://services-sync/keys.sys.mjs"
);

View File

@@ -67,14 +67,15 @@ ChromeUtils.defineESModuleGetters(lazy, {
Preference: "resource://tps/modules/prefs.sys.mjs",
Separator: "resource://tps/modules/bookmarks.sys.mjs",
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
STATUS_OK: "resource://services-sync/constants.sys.mjs",
Svc: "resource://services-sync/util.sys.mjs",
SyncTelemetry: "resource://services-sync/telemetry.sys.mjs",
WEAVE_VERSION: "resource://services-sync/constants.sys.mjs",
Weave: "resource://services-sync/main.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
extensionStorageSync: "resource://gre/modules/ExtensionStorageSync.jsm",
WEAVE_VERSION: "resource://services-sync/constants.js",
});
XPCOMUtils.defineLazyGetter(lazy, "fileProtocolHandler", () => {
@@ -1374,7 +1375,7 @@ var TPS = {
await this.waitForSetupComplete();
lazy.Logger.AssertEqual(
lazy.Weave.Status.service,
lazy.Weave.STATUS_OK,
lazy.STATUS_OK,
"Weave status OK"
);
await this.waitForTracking();

View File

@@ -392,9 +392,9 @@ merge-automation:
version-bump: "major"
new-suffix: 'a1'
replacements:
- - "services/sync/modules/constants.js"
- 'WEAVE_VERSION: "1.{current_weave_version}.0"'
- 'WEAVE_VERSION: "1.{next_weave_version}.0"'
- - "services/sync/modules/constants.sys.mjs"
- 'WEAVE_VERSION = "1.{current_weave_version}.0"'
- 'WEAVE_VERSION = "1.{next_weave_version}.0"'
merge-old-head: false
end-tag: 'FIREFOX_NIGHTLY_{major_version}_END'
to-repo: 'https://hg.mozilla.org/mozilla-central'

View File

@@ -11,9 +11,7 @@ import {
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
import { Utils } from "resource://services-sync/util.sys.mjs";
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
import { SCORE_INCREMENT_XLARGE } from "resource://services-sync/constants.sys.mjs";
const lazy = {};