Bug 1745977 - Stop using the second argument to ChromeUtils.import in various files in services/. r=markh

Differential Revision: https://phabricator.services.mozilla.com/D133776
This commit is contained in:
Mark Banner 2021-12-15 10:05:35 +00:00
parent 315d8e83f5
commit 07f6cf42b9
16 changed files with 32 additions and 51 deletions

View File

@ -550,16 +550,6 @@ module.exports = {
"dom/push/test/xpcshell/head.js",
"dom/push/test/xpcshell/test_broadcast_success.js",
"dom/push/test/xpcshell/test_crypto.js",
"services/common/tests/unit/head_helpers.js",
"services/common/tests/unit/test_uptake_telemetry.js",
"services/fxaccounts/tests/xpcshell/test_accounts.js",
"services/fxaccounts/tests/xpcshell/test_accounts_device_registration.js",
"services/fxaccounts/tests/xpcshell/test_loginmgr_storage.js",
"services/fxaccounts/tests/xpcshell/test_oauth_token_storage.js",
"services/fxaccounts/tests/xpcshell/test_oauth_tokens.js",
"services/fxaccounts/tests/xpcshell/test_web_channel.js",
"services/sync/modules-testing/utils.js",
"services/sync/tests/unit/test_postqueue.js",
"toolkit/components/cloudstorage/tests/unit/test_cloudstorage.js",
"toolkit/components/crashes/tests/xpcshell/test_crash_manager.js",
"toolkit/components/crashes/tests/xpcshell/test_crash_service.js",

View File

@ -282,19 +282,15 @@ function checkUptakeTelemetry(snapshot1, snapshot2, expectedIncrements) {
}
async function withFakeChannel(channel, f) {
const module = ChromeUtils.import(
"resource://services-common/uptake-telemetry.js",
null
const { Policy } = ChromeUtils.import(
"resource://services-common/uptake-telemetry.js"
);
const oldPolicy = module.Policy;
module.Policy = {
...oldPolicy,
getChannel: () => channel,
};
let oldGetChannel = Policy.getChannel;
Policy.getChannel = () => channel;
try {
return await f();
} finally {
module.Policy = oldPolicy;
Policy.getChannel = oldGetChannel;
}
}

View File

@ -1,5 +1,3 @@
const { ClientID } = ChromeUtils.import("resource://gre/modules/ClientID.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
@ -10,20 +8,16 @@ const { UptakeTelemetry } = ChromeUtils.import(
const COMPONENT = "remotesettings";
async function withFakeClientID(uuid, f) {
const module = ChromeUtils.import(
"resource://services-common/uptake-telemetry.js",
null
const { Policy } = ChromeUtils.import(
"resource://services-common/uptake-telemetry.js"
);
const oldPolicy = module.Policy;
module.Policy = {
...oldPolicy,
_clientIDHash: null,
getClientID: () => Promise.resolve(uuid),
};
let oldGetClientID = Policy.getClientID;
Policy._clientIDHash = null;
Policy.getClientID = () => Promise.resolve(uuid);
try {
return await f();
} finally {
module.Policy = oldPolicy;
Policy.getClientID = oldGetClientID;
}
}

View File

@ -4,7 +4,7 @@
"use strict";
var EXPORTED_SYMBOLS = ["UptakeTelemetry"];
var EXPORTED_SYMBOLS = ["UptakeTelemetry", "Policy"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"

View File

@ -1622,4 +1622,5 @@ XPCOMUtils.defineLazyGetter(this, "fxAccounts", function() {
return a;
});
var EXPORTED_SYMBOLS = ["fxAccounts", "FxAccounts"];
// `AccountState` is exported for tests.
var EXPORTED_SYMBOLS = ["fxAccounts", "FxAccounts", "AccountState"];

View File

@ -6,6 +6,8 @@
var EXPORTED_SYMBOLS = [
"FxAccountsStorageManagerCanStoreField",
"FxAccountsStorageManager",
// Exported for tests.
"LoginManagerStorage",
];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

View File

@ -10,7 +10,12 @@
* about account state changes.
*/
var EXPORTED_SYMBOLS = ["EnsureFxAccountsWebChannel"];
var EXPORTED_SYMBOLS = [
"EnsureFxAccountsWebChannel",
// These are exported for tests.
"FxAccountsWebChannel",
"FxAccountsWebChannelHelpers",
];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"

View File

@ -29,8 +29,7 @@ const { PromiseUtils } = ChromeUtils.import(
// We grab some additional stuff via backstage passes.
var { AccountState } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm",
null
"resource://gre/modules/FxAccounts.jsm"
);
const ONE_HOUR_MS = 1000 * 60 * 60;

View File

@ -20,8 +20,7 @@ const {
ON_DEVICE_DISCONNECTED_NOTIFICATION,
} = ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
var { AccountState } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm",
null
"resource://gre/modules/FxAccounts.jsm"
);
initTestLogging("Trace");

View File

@ -18,8 +18,7 @@ const { FXA_PWDMGR_HOST, FXA_PWDMGR_REALM } = ChromeUtils.import(
// Use a backstage pass to get at our LoginManagerStorage object, so we can
// mock the prototype.
var { LoginManagerStorage } = ChromeUtils.import(
"resource://gre/modules/FxAccountsStorage.jsm",
null
"resource://gre/modules/FxAccountsStorage.jsm"
);
var isLoggedIn = true;
LoginManagerStorage.prototype.__defineGetter__("_isLoggedIn", () => isLoggedIn);

View File

@ -12,8 +12,7 @@ const { FxAccountsClient } = ChromeUtils.import(
// We grab some additional stuff via backstage passes.
var { AccountState } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm",
null
"resource://gre/modules/FxAccounts.jsm"
);
function promiseNotification(topic) {

View File

@ -10,8 +10,7 @@ const { FxAccountsClient } = ChromeUtils.import(
"resource://gre/modules/FxAccountsClient.jsm"
);
var { AccountState } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm",
null
"resource://gre/modules/FxAccounts.jsm"
);
function promiseNotification(topic) {

View File

@ -14,7 +14,7 @@ const { CryptoUtils } = ChromeUtils.import(
const {
FxAccountsWebChannel,
FxAccountsWebChannelHelpers,
} = ChromeUtils.import("resource://gre/modules/FxAccountsWebChannel.jsm", null);
} = ChromeUtils.import("resource://gre/modules/FxAccountsWebChannel.jsm");
const URL_STRING = "https://example.com";

View File

@ -51,8 +51,7 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// and grab non-exported stuff via a backstage pass.
const { AccountState } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm",
null
"resource://gre/modules/FxAccounts.jsm"
);
// A mock "storage manager" for FxAccounts that doesn't actually write anywhere.

View File

@ -9,6 +9,8 @@ var EXPORTED_SYMBOLS = [
"CryptoWrapper",
"CollectionKeyManager",
"Collection",
// Exported for tests.
"PostQueue",
];
const CRYPTO_COLLECTION = "crypto";

View File

@ -1,10 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let { PostQueue } = ChromeUtils.import(
"resource://services-sync/record.js",
null
);
let { PostQueue } = ChromeUtils.import("resource://services-sync/record.js");
function makeRecord(nbytes) {
return {