Bug 1816477 - Port bug 1814931: convert services/sync to ES modules. r=darktrojan
Differential Revision: https://phabricator.services.mozilla.com/D169654 --HG-- rename : mail/services/sync/accounts.js => mail/services/sync/modules/engines/accounts.sys.mjs rename : mail/services/sync/addressBooks.js => mail/services/sync/modules/engines/addressBooks.sys.mjs rename : mail/services/sync/calendars.js => mail/services/sync/modules/engines/calendars.sys.mjs rename : mail/services/sync/identities.js => mail/services/sync/modules/engines/identities.sys.mjs
This commit is contained in:
Родитель
226b0c5557
Коммит
95169d2fa4
|
@ -18,16 +18,10 @@ ChromeUtils.defineModuleGetter(
|
|||
"EnsureFxAccountsWebChannel",
|
||||
"resource://gre/modules/FxAccountsWebChannel.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"UIState",
|
||||
"resource://services-sync/UIState.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Weave",
|
||||
"resource://services-sync/main.js"
|
||||
);
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
UIState: "resource://services-sync/UIState.sys.mjs",
|
||||
Weave: "resource://services-sync/main.sys.mjs",
|
||||
});
|
||||
|
||||
var gSync = {
|
||||
handleEvent(event) {
|
||||
|
@ -153,8 +147,8 @@ var gSync = {
|
|||
).getFxAccountsSingleton();
|
||||
|
||||
if (disconnectAccount) {
|
||||
const { SyncDisconnect } = ChromeUtils.import(
|
||||
"resource://services-sync/SyncDisconnect.jsm"
|
||||
const { SyncDisconnect } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/SyncDisconnect.sys.mjs"
|
||||
);
|
||||
await fxAccounts.telemetry.recordDisconnection(null, "ui");
|
||||
await SyncDisconnect.disconnect(false);
|
||||
|
|
|
@ -750,7 +750,7 @@ MailGlue.prototype = {
|
|||
["identities", "IdentitiesEngine"],
|
||||
]) {
|
||||
let ns = ChromeUtils.import(
|
||||
`resource://services-sync/engines/${moduleName}.js`
|
||||
`resource://services-sync/engines/${moduleName}.sys.mjs`
|
||||
);
|
||||
await Weave.Service.engineManager.register(ns[engineName]);
|
||||
Weave.Service.engineManager
|
||||
|
|
|
@ -10,7 +10,9 @@ const { AppConstants } = ChromeUtils.importESModule(
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { UIState } = ChromeUtils.import("resource://services-sync/UIState.jsm");
|
||||
const { UIState } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/UIState.sys.mjs"
|
||||
);
|
||||
|
||||
class AccountHubStart extends HTMLElement {
|
||||
#accounts = [
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
/* import-globals-from preferences.js */
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
UIState: "resource://services-sync/UIState.jsm",
|
||||
Weave: "resource://services-sync/main.js",
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
UIState: "resource://services-sync/UIState.sys.mjs",
|
||||
Weave: "resource://services-sync/main.sys.mjs",
|
||||
});
|
||||
|
||||
var { FxAccounts, getFxAccountsSingleton } = ChromeUtils.import(
|
||||
|
|
|
@ -2,24 +2,20 @@
|
|||
* 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 = ["AccountsEngine", "AccountRecord"];
|
||||
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
|
||||
import {
|
||||
Store,
|
||||
SyncEngine,
|
||||
Tracker,
|
||||
} from "resource://services-sync/engines.sys.mjs";
|
||||
import { Utils } from "resource://services-sync/util.sys.mjs";
|
||||
|
||||
const { CryptoUtils } = ChromeUtils.import(
|
||||
"resource://services-crypto/utils.js"
|
||||
);
|
||||
const { CryptoWrapper } = ChromeUtils.import(
|
||||
"resource://services-sync/record.js"
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { Store, SyncEngine, Tracker } = ChromeUtils.import(
|
||||
"resource://services-sync/engines.js"
|
||||
);
|
||||
const { Utils } = ChromeUtils.import("resource://services-sync/util.js");
|
||||
|
||||
const SYNCED_SMTP_PROPERTIES = {
|
||||
authMethod: "authMethod",
|
||||
|
@ -57,9 +53,10 @@ const SYNCED_SERVER_PROPERTIES = {
|
|||
* The record contains the following fields:
|
||||
*
|
||||
*/
|
||||
function AccountRecord(collection, id) {
|
||||
export function AccountRecord(collection, id) {
|
||||
CryptoWrapper.call(this, collection, id);
|
||||
}
|
||||
|
||||
AccountRecord.prototype = {
|
||||
__proto__: CryptoWrapper.prototype,
|
||||
_logName: "Record.Account",
|
||||
|
@ -72,9 +69,10 @@ Utils.deferGetSet(AccountRecord, "cleartext", [
|
|||
"isDefault",
|
||||
]);
|
||||
|
||||
function AccountsEngine(service) {
|
||||
export function AccountsEngine(service) {
|
||||
SyncEngine.call(this, "Accounts", service);
|
||||
}
|
||||
|
||||
AccountsEngine.prototype = {
|
||||
__proto__: SyncEngine.prototype,
|
||||
_storeObj: AccountStore,
|
|
@ -2,24 +2,20 @@
|
|||
* 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 = ["AddressBooksEngine", "AddressBookRecord"];
|
||||
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
|
||||
import {
|
||||
Store,
|
||||
SyncEngine,
|
||||
Tracker,
|
||||
} from "resource://services-sync/engines.sys.mjs";
|
||||
import { Utils } from "resource://services-sync/util.sys.mjs";
|
||||
|
||||
const { CryptoUtils } = ChromeUtils.import(
|
||||
"resource://services-crypto/utils.js"
|
||||
);
|
||||
const { CryptoWrapper } = ChromeUtils.import(
|
||||
"resource://services-sync/record.js"
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { Store, SyncEngine, Tracker } = ChromeUtils.import(
|
||||
"resource://services-sync/engines.js"
|
||||
);
|
||||
const { Utils } = ChromeUtils.import("resource://services-sync/util.js");
|
||||
|
||||
const SYNCED_COMMON_PROPERTIES = {
|
||||
autocomplete: "enable_autocomplete",
|
||||
|
@ -54,18 +50,20 @@ const SYNCED_LDAP_PROPERTIES = {
|
|||
* The record contains the following fields:
|
||||
*
|
||||
*/
|
||||
function AddressBookRecord(collection, id) {
|
||||
export function AddressBookRecord(collection, id) {
|
||||
CryptoWrapper.call(this, collection, id);
|
||||
}
|
||||
|
||||
AddressBookRecord.prototype = {
|
||||
__proto__: CryptoWrapper.prototype,
|
||||
_logName: "Record.AddressBook",
|
||||
};
|
||||
Utils.deferGetSet(AddressBookRecord, "cleartext", ["name", "type", "prefs"]);
|
||||
|
||||
function AddressBooksEngine(service) {
|
||||
export function AddressBooksEngine(service) {
|
||||
SyncEngine.call(this, "AddressBooks", service);
|
||||
}
|
||||
|
||||
AddressBooksEngine.prototype = {
|
||||
__proto__: SyncEngine.prototype,
|
||||
_storeObj: AddressBookStore,
|
|
@ -2,22 +2,18 @@
|
|||
* 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 = ["CalendarsEngine", "CalendarRecord"];
|
||||
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
|
||||
import {
|
||||
Store,
|
||||
SyncEngine,
|
||||
Tracker,
|
||||
} from "resource://services-sync/engines.sys.mjs";
|
||||
import { Utils } from "resource://services-sync/util.sys.mjs";
|
||||
|
||||
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
const { CryptoUtils } = ChromeUtils.import(
|
||||
"resource://services-crypto/utils.js"
|
||||
);
|
||||
const { CryptoWrapper } = ChromeUtils.import(
|
||||
"resource://services-sync/record.js"
|
||||
);
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { Store, SyncEngine, Tracker } = ChromeUtils.import(
|
||||
"resource://services-sync/engines.js"
|
||||
);
|
||||
const { Utils } = ChromeUtils.import("resource://services-sync/util.js");
|
||||
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
const SYNCED_PROPERTIES = {
|
||||
cacheEnabled: "cache.enabled",
|
||||
|
@ -57,9 +53,10 @@ function shouldSyncCalendar(calendar) {
|
|||
* The record contains the following fields:
|
||||
*
|
||||
*/
|
||||
function CalendarRecord(collection, id) {
|
||||
export function CalendarRecord(collection, id) {
|
||||
CryptoWrapper.call(this, collection, id);
|
||||
}
|
||||
|
||||
CalendarRecord.prototype = {
|
||||
__proto__: CryptoWrapper.prototype,
|
||||
_logName: "Record.Calendar",
|
||||
|
@ -71,9 +68,10 @@ Utils.deferGetSet(CalendarRecord, "cleartext", [
|
|||
"prefs",
|
||||
]);
|
||||
|
||||
function CalendarsEngine(service) {
|
||||
export function CalendarsEngine(service) {
|
||||
SyncEngine.call(this, "Calendars", service);
|
||||
}
|
||||
|
||||
CalendarsEngine.prototype = {
|
||||
__proto__: SyncEngine.prototype,
|
||||
_storeObj: CalendarStore,
|
|
@ -2,24 +2,20 @@
|
|||
* 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 = ["IdentitiesEngine", "IdentityRecord"];
|
||||
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
|
||||
import {
|
||||
Store,
|
||||
SyncEngine,
|
||||
Tracker,
|
||||
} from "resource://services-sync/engines.sys.mjs";
|
||||
import { Utils } from "resource://services-sync/util.sys.mjs";
|
||||
|
||||
const { CryptoUtils } = ChromeUtils.import(
|
||||
"resource://services-crypto/utils.js"
|
||||
);
|
||||
const { CryptoWrapper } = ChromeUtils.import(
|
||||
"resource://services-sync/record.js"
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
|
||||
"resource://services-sync/constants.js"
|
||||
);
|
||||
const { Store, SyncEngine, Tracker } = ChromeUtils.import(
|
||||
"resource://services-sync/engines.js"
|
||||
);
|
||||
const { Utils } = ChromeUtils.import("resource://services-sync/util.js");
|
||||
|
||||
const SYNCED_IDENTITY_PROPERTIES = {
|
||||
attachSignature: "attach_signature",
|
||||
|
@ -56,18 +52,20 @@ const SYNCED_IDENTITY_PROPERTIES = {
|
|||
* The record contains the following fields:
|
||||
*
|
||||
*/
|
||||
function IdentityRecord(collection, id) {
|
||||
export function IdentityRecord(collection, id) {
|
||||
CryptoWrapper.call(this, collection, id);
|
||||
}
|
||||
|
||||
IdentityRecord.prototype = {
|
||||
__proto__: CryptoWrapper.prototype,
|
||||
_logName: "Record.Identity",
|
||||
};
|
||||
Utils.deferGetSet(IdentityRecord, "cleartext", ["accounts", "prefs", "smtpID"]);
|
||||
|
||||
function IdentitiesEngine(service) {
|
||||
export function IdentitiesEngine(service) {
|
||||
SyncEngine.call(this, "Identities", service);
|
||||
}
|
||||
|
||||
IdentitiesEngine.prototype = {
|
||||
__proto__: SyncEngine.prototype,
|
||||
_storeObj: IdentityStore,
|
|
@ -3,10 +3,10 @@
|
|||
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXTRA_JS_MODULES["services-sync"].engines += [
|
||||
"accounts.js",
|
||||
"addressBooks.js",
|
||||
"calendars.js",
|
||||
"identities.js",
|
||||
"modules/engines/accounts.sys.mjs",
|
||||
"modules/engines/addressBooks.sys.mjs",
|
||||
"modules/engines/calendars.sys.mjs",
|
||||
"modules/engines/identities.sys.mjs",
|
||||
]
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += [
|
||||
|
|
|
@ -7,10 +7,12 @@ do_get_profile();
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { AccountsEngine, AccountRecord } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/accounts.js"
|
||||
const { AccountsEngine, AccountRecord } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/accounts.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
|
|
@ -7,10 +7,12 @@ do_get_profile();
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { AccountsEngine } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/accounts.js"
|
||||
const { AccountsEngine } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/accounts.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
|
|
@ -7,10 +7,12 @@ do_get_profile();
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { AddressBooksEngine, AddressBookRecord } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/addressBooks.js"
|
||||
const { AddressBooksEngine, AddressBookRecord } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/addressBooks.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
|
|
@ -7,10 +7,12 @@ do_get_profile();
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { AddressBooksEngine } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/addressBooks.js"
|
||||
const { AddressBooksEngine } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/addressBooks.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
do_get_profile();
|
||||
|
||||
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
const { CalendarsEngine, CalendarRecord } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/calendars.js"
|
||||
const { CalendarsEngine, CalendarRecord } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/calendars.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
|
||||
let engine, store, tracker;
|
||||
let calDAVCalendar, icsCalendar, fileICSCalendar, storageCalendar;
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
do_get_profile();
|
||||
|
||||
const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
const { CalendarsEngine } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/calendars.js"
|
||||
const { CalendarsEngine } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/calendars.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
|
||||
let engine, store, tracker;
|
||||
|
||||
|
|
|
@ -7,10 +7,12 @@ do_get_profile();
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { IdentitiesEngine, IdentityRecord } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/identities.js"
|
||||
const { IdentitiesEngine, IdentityRecord } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/identities.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
|
|
@ -7,10 +7,12 @@ do_get_profile();
|
|||
const { MailServices } = ChromeUtils.import(
|
||||
"resource:///modules/MailServices.jsm"
|
||||
);
|
||||
const { IdentitiesEngine } = ChromeUtils.import(
|
||||
"resource://services-sync/engines/identities.js"
|
||||
const { IdentitiesEngine } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/engines/identities.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.importESModule(
|
||||
"resource://services-sync/service.sys.mjs"
|
||||
);
|
||||
const { Service } = ChromeUtils.import("resource://services-sync/service.js");
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
);
|
||||
|
|
|
@ -11,14 +11,14 @@ var { MailServices } = ChromeUtils.import(
|
|||
);
|
||||
|
||||
add_task(function test_services() {
|
||||
function check_service(service, interface) {
|
||||
function check_service(service, serviceInterface) {
|
||||
Assert.ok(
|
||||
service in MailServices,
|
||||
`${service} should be a member of MailServices`
|
||||
);
|
||||
Assert.ok(
|
||||
MailServices[service] instanceof interface,
|
||||
`MailServices.${service} should implement Ci.${interface.name}`
|
||||
MailServices[service] instanceof serviceInterface,
|
||||
`MailServices.${service} should implement Ci.${serviceInterface.name}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче