Bug 1801379 - Migrate Sinon.jsm to an ES module r=extension-reviewers,application-update-reviewers,pip-reviewers,credential-management-reviewers,fxview-reviewers,devtools-reviewers,Standard8,nchevobbe,sclements,dimi,mconley,bytesized,robwu

Migrated `testing/modules/Sinon.sys.mjs` to an ES module.

`testing` should now be 100% ESM 🎉

Differential Revision: https://phabricator.services.mozilla.com/D173643
This commit is contained in:
CanadaHonk 2023-03-29 07:34:10 +00:00
parent 8cd944215e
commit 91709586ba
112 changed files with 294 additions and 154 deletions

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const BASE = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
// eslint-disable-next-line @microsoft/sdl/no-insecure-url

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const BASE = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
// eslint-disable-next-line @microsoft/sdl/no-insecure-url

View File

@ -5,7 +5,9 @@
let contextMenu;
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const example_base =
// eslint-disable-next-line @microsoft/sdl/no-insecure-url

View File

@ -14,7 +14,9 @@
* correctly prevent default events, and follows the correct code path.
*/
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
var gTests = [
{

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const BASE = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
// eslint-disable-next-line @microsoft/sdl/no-insecure-url

View File

@ -6,11 +6,11 @@ ChromeUtils.defineESModuleGetters(this, {
"resource://testing-common/EnterprisePolicyTesting.sys.mjs",
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
ExtensionCommon: "resource://gre/modules/ExtensionCommon.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
async function promisePageActionPanelOpen(win = window, eventDict = {}) {

View File

@ -10,7 +10,9 @@
const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const {
MODE_DISABLED,

View File

@ -1,7 +1,9 @@
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
function promiseSyncReady() {
let service = Cc["@mozilla.org/weave/service;1"].getService(Ci.nsISupports)

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
add_task(async function() {
let tab1 = await addTab();

View File

@ -2,7 +2,9 @@
* 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 { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const TEST_ROOT = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",

View File

@ -7,7 +7,9 @@ const { MacAttribution } = ChromeUtils.importESModule(
const { AttributionIOUtils } = ChromeUtils.importESModule(
"resource:///modules/AttributionCode.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
async function assertCacheExistsAndIsEmpty() {
// We should have written to the cache, and be able to read back

View File

@ -102,7 +102,9 @@ async function setupStubs() {
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
// This depends on the caller to invoke it by name. We do try to
// prevent the most obvious incorrect invocation, namely

View File

@ -7,7 +7,9 @@ const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
add_task(async () => {
await setupStubs();

View File

@ -12,7 +12,9 @@ const { BuiltInThemes } = ChromeUtils.importESModule(
const { ColorwayClosetOpener } = ChromeUtils.import(
"resource:///modules/ColorwayClosetOpener.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const MOCK_COLLECTION_TEST_CARD_IMAGE_PATH = "mockCollectionPreview.avif";
const MOCK_THEME_NAME = "Mock Theme";

View File

@ -2,7 +2,9 @@
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
ChromeUtils.defineModuleGetter(
this,

View File

@ -9,11 +9,11 @@ const { AddonTestUtils } = ChromeUtils.import(
ChromeUtils.defineESModuleGetters(this, {
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
HomePage: "resource:///modules/HomePage.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
function promisePrefChanged(expectedValue) {

View File

@ -9,12 +9,12 @@ const { AddonTestUtils } = ChromeUtils.import(
ChromeUtils.defineESModuleGetters(this, {
PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs",
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
HomePage: "resource:///modules/HomePage.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
AddonTestUtils.init(this);

View File

@ -19,7 +19,9 @@ const { RemoteSettings } = ChromeUtils.importESModule(
"resource://services-settings/remote-settings.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const URLTYPE_SUGGEST_JSON = "application/x-suggestions+json";

View File

@ -12,7 +12,9 @@ const { SearchTestUtils } = ChromeUtils.importESModule(
const { NimbusFeatures } = ChromeUtils.import(
"resource://nimbus/ExperimentAPI.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
AddonTestUtils.init(this);
AddonTestUtils.overrideCertDB();

View File

@ -20,7 +20,9 @@ const { ASRouter } = ChromeUtils.import(
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { FeatureCalloutMessages } = ChromeUtils.import(
"resource://activity-stream/lib/FeatureCalloutMessages.jsm"
);

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { InternalTestingProfileMigrator } = ChromeUtils.importESModule(
"resource:///modules/InternalTestingProfileMigrator.sys.mjs"
);

View File

@ -3,7 +3,9 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { EdgeProfileMigrator } = ChromeUtils.importESModule(
"resource:///modules/EdgeProfileMigrator.sys.mjs"
);

View File

@ -19,7 +19,9 @@ const { FxAccounts } = ChromeUtils.importESModule(
);
// We import sinon here to make it available across all mochitest test files
// eslint-disable-next-line no-unused-vars
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
// Set the content pref to make it available across tests
const ABOUT_WELCOME_OVERRIDE_CONTENT_PREF = "browser.aboutwelcome.screens";
// Test differently for windows 7 as theme screens are removed.

View File

@ -7,7 +7,9 @@
const { AboutWelcomeDefaults } = ChromeUtils.import(
"resource://activity-stream/aboutwelcome/lib/AboutWelcomeDefaults.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { AttributionCode } = ChromeUtils.importESModule(
"resource:///modules/AttributionCode.sys.mjs"
);

View File

@ -10,7 +10,9 @@ const { AboutWelcomeTelemetry } = ChromeUtils.import(
const { AttributionCode } = ChromeUtils.importESModule(
"resource:///modules/AttributionCode.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const TELEMETRY_PREF = "browser.newtabpage.activity-stream.telemetry";
add_task(function test_enabled() {

View File

@ -4,7 +4,9 @@
const { OnboardingMessageProvider } = ChromeUtils.import(
"resource://activity-stream/lib/OnboardingMessageProvider.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
function getOnboardingScreenById(screens, screenId) {
return screens.find(screen => {

View File

@ -1,6 +1,8 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();

View File

@ -7,7 +7,9 @@
* Test to ensure that on "mousedown" in Toolbar we set Speculative Connection
*/
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
let spy = sandbox
.stub(PlacesUIUtils, "setupSpeculativeConnection")

View File

@ -4,7 +4,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
const TAG_NAME = "testTag";

View File

@ -8,7 +8,9 @@
const { PromptTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/PromptTestUtils.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { ForgetAboutSite } = ChromeUtils.importESModule(
"resource://gre/modules/ForgetAboutSite.sys.mjs"
);

View File

@ -1,7 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
const URL1 = "https://example.com/1/";

View File

@ -6,7 +6,9 @@ const { Interactions } = ChromeUtils.importESModule(
"resource:///modules/Interactions.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
XPCOMUtils.defineLazyPreferenceGetter(
this,

View File

@ -1,4 +1,6 @@
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
/* eslint-disable mozilla/use-chromeutils-generateqi */

View File

@ -9,7 +9,9 @@ ChromeUtils.defineModuleGetter(
"chrome://pocket/content/pktApi.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
// PocketEnabled/Disabled promises return true if it was already
// Enabled/Disabled, and false if it need to Enable/Disable.

View File

@ -9,4 +9,6 @@ XPCOMUtils.defineLazyScriptGetter(
"chrome://pocket/content/pktUI.js"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);

View File

@ -1,4 +1,6 @@
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const testGlobal = {
PKT_PANEL_OVERLAY: class {

View File

@ -11,7 +11,9 @@ const { FxAccountsPairingFlow } = ChromeUtils.importESModule(
);
// Use sinon for mocking.
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
let flowCounter = 0;

View File

@ -2,7 +2,9 @@
* 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 { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();

View File

@ -2,7 +2,9 @@
* 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 { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
add_task(async function test_experiment_messaging_system() {
const LOCALE = Services.locale.appLocaleAsBCP47;

View File

@ -10,7 +10,9 @@ const SCREENSHOTS_EVENTS = [
{ category: "screenshots", method: "failed", object: "screenshot_too_large" },
];
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, {
ScreenshotsUtils: "resource:///modules/ScreenshotsUtils.sys.mjs",
});

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, {
ScreenshotsUtils: "resource:///modules/ScreenshotsUtils.sys.mjs",

View File

@ -10,7 +10,9 @@ const { ExperimentFakes } = ChromeUtils.import(
const { SearchService } = ChromeUtils.importESModule(
"resource://gre/modules/SearchService.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
add_task(async function test_engines_reloaded_nimbus() {
let reloadSpy = sinon.spy(SearchService.prototype, "_maybeReloadEngines");

View File

@ -10,11 +10,11 @@ ChromeUtils.defineESModuleGetters(this, {
SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
const TESTS = [

View File

@ -10,11 +10,11 @@ ChromeUtils.defineESModuleGetters(this, {
SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
const TEST_PROVIDER_INFO = [

View File

@ -4,7 +4,9 @@
const { _LastSession } = ChromeUtils.importESModule(
"resource:///modules/sessionstore/SessionStore.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const state = {
windows: [

View File

@ -1,11 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
ChromeUtils.defineESModuleGetters(this, {
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm",
ExperimentFakes: "resource://testing-common/NimbusTestUtils.jsm",
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
const userChoiceStub = sinon

View File

@ -1,11 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
ChromeUtils.defineESModuleGetters(this, {
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm",
ExperimentFakes: "resource://testing-common/NimbusTestUtils.jsm",
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
XPCOMUtils.defineLazyServiceGetter(

View File

@ -1 +1,3 @@
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);

View File

@ -1,7 +1,9 @@
var { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");

View File

@ -5,10 +5,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
ChromeUtils.defineESModuleGetters(this, {
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
sinon: "resource://testing-common/Sinon.jsm",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
// Helpers for testing telemetry events.

View File

@ -2,5 +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/. */
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
var gProfD = do_get_profile().QueryInterface(Ci.nsIFile);

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
var gTestTab;
var gContentAPI;

View File

@ -5,7 +5,9 @@
// the original search string to the docshell and not a search url.
add_task(async function test() {
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
await SpecialPowers.pushPrefEnv({

View File

@ -19,6 +19,7 @@ ChromeUtils.defineESModuleGetters(this, {
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.sys.mjs",
UrlbarUtils: "resource:///modules/UrlbarUtils.sys.mjs",
UrlbarView: "resource:///modules/UrlbarView.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
@ -26,7 +27,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm",
ExperimentFakes: "resource://testing-common/NimbusTestUtils.jsm",
ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
XPCOMUtils.defineLazyGetter(this, "PlacesFrecencyRecalculator", () => {

View File

@ -30,12 +30,9 @@ XPCOMUtils.defineLazyGetter(this, "MerinoTestUtils", () => {
return module;
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.jsm",
});
ChromeUtils.defineESModuleGetters(lazy, {
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
async function addTopSites(url) {

View File

@ -22,13 +22,13 @@ ChromeUtils.defineESModuleGetters(lazy, {
"resource:///modules/UrlbarProviderQuickSuggest.sys.mjs",
UrlbarUtils: "resource:///modules/UrlbarUtils.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
ExperimentAPI: "resource://nimbus/ExperimentAPI.jsm",
ExperimentFakes: "resource://testing-common/NimbusTestUtils.jsm",
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
let gTestScope;

View File

@ -10,10 +10,7 @@
ChromeUtils.defineESModuleGetters(this, {
EnterprisePolicyTesting:
"resource://testing-common/EnterprisePolicyTesting.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
sinon: "resource://testing-common/Sinon.jsm",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
// We use this pref in enterprise preference policy tests. We specifically use a

View File

@ -11,10 +11,7 @@ ChromeUtils.defineESModuleGetters(this, {
CONTEXTUAL_SERVICES_PING_TYPES:
"resource:///modules/PartnerLinkAttribution.sys.mjs",
UrlbarView: "resource:///modules/UrlbarView.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
sinon: "resource://testing-common/Sinon.jsm",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
const { TELEMETRY_SCALARS } = UrlbarProviderQuickSuggest;

View File

@ -29,12 +29,12 @@ ChromeUtils.defineESModuleGetters(this, {
UrlbarResult: "resource:///modules/UrlbarResult.sys.mjs",
UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.sys.mjs",
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
AddonTestUtils: "resource://testing-common/AddonTestUtils.jsm",
HttpServer: "resource://testing-common/httpd.js",
sinon: "resource://testing-common/Sinon.jsm",
});
XPCOMUtils.defineLazyGetter(this, "QuickSuggestTestUtils", () => {

View File

@ -5,8 +5,8 @@
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.jsm",
ChromeUtils.defineESModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.sys.mjs",
});
let sandbox;

View File

@ -9,8 +9,8 @@
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.jsm",
ChromeUtils.defineESModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.sys.mjs",
});
// The possible limit-related properties in result groups.

View File

@ -8,8 +8,8 @@
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.jsm",
ChromeUtils.defineESModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.sys.mjs",
});
const SUGGEST_PREF = "browser.urlbar.suggest.searches";

View File

@ -7,8 +7,8 @@
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.jsm",
ChromeUtils.defineESModuleGetters(lazy, {
sinon: "resource://testing-common/Sinon.sys.mjs",
});
const MAX_RESULTS = 10;

View File

@ -25,7 +25,9 @@ var { FileTestUtils } = ChromeUtils.importESModule(
var { MockDocument } = ChromeUtils.importESModule(
"resource://testing-common/MockDocument.sys.mjs"
);
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
var { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);

View File

@ -10,11 +10,11 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
ChromeUtils.defineESModuleGetters(this, {
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
HomePage: "resource:///modules/HomePage.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
const HOMEPAGE_IGNORELIST = "homepage-urls";

View File

@ -11,11 +11,11 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
ChromeUtils.defineESModuleGetters(this, {
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
HomePage: "resource:///modules/HomePage.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
const HOMEPAGE_IGNORELIST = "homepage-urls";

View File

@ -11,7 +11,9 @@ const {
"resource:///modules/PartnerLinkAttribution.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const FAKE_PING = { tile_id: 1, position: 1 };

View File

@ -17,7 +17,9 @@ const { UpdateUtils } = ChromeUtils.importESModule(
"resource://gre/modules/UpdateUtils.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const FAKE_PING = { event: "fake_event", value: "fake_value", locale: "en-US" };
const FAKE_ENDPOINT = "https://www.test.com";

View File

@ -1,7 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { AddonTestUtils } = ChromeUtils.import(
"resource://testing-common/AddonTestUtils.jsm"

View File

@ -1,6 +1,8 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const {
setDefaultPreferencesIfNeeded,
PREFERENCE_TYPES,

View File

@ -8,7 +8,9 @@ const { getAddonAndLocalAPIsMocker } = ChromeUtils.importESModule(
const { LangPackMatcher } = ChromeUtils.importESModule(
"resource://gre/modules/LangPackMatcher.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
const mockAddonAndLocaleAPIs = getAddonAndLocalAPIsMocker(this, sandbox);

View File

@ -4,7 +4,9 @@
const { Async } = ChromeUtils.importESModule(
"resource://services-common/async.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
function makeArray(length) {
// Start at 1 so that we can just divide by yieldEvery to get the expected

View File

@ -9,7 +9,9 @@
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { SCOPE_OLD_SYNC, LEGACY_SCOPE_WEBEXT_SYNC } = ChromeUtils.import(
"resource://gre/modules/FxAccountsCommon.js"
);

View File

@ -22,7 +22,9 @@ var { CommonUtils } = ChromeUtils.importESModule(
var { PlacesTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/PlacesTestUtils.sys.mjs"
);
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
var {
SerializableSet,
Svc,

View File

@ -119,7 +119,7 @@ The [`Sinon`](https://sinonjs.org/) mocking framework is available. You can impo
using something like:
```js
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule("resource://testing-common/Sinon.sys.mjs");
```
More details on how to do mocking are available on the Sinon website.

View File

@ -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/. */
"use strict";
var EXPORTED_SYMBOLS = ["sinon"];
// ================================================
// Load mocking/stubbing library sinon
// docs: http://sinonjs.org/releases/v7.2.7/
const {
import {
clearInterval,
clearTimeout,
setInterval,
setIntervalWithTarget,
setTimeout,
setTimeoutWithTarget,
} = ChromeUtils.importESModule("resource://gre/modules/Timer.sys.mjs");
// eslint-disable-next-line no-unused-vars
} from "resource://gre/modules/Timer.sys.mjs";
const obj = {
global: {
clearInterval,
@ -28,10 +24,17 @@ const obj = {
setTimeoutWithTarget,
Date,
},
clearInterval,
clearTimeout,
setInterval,
setIntervalWithTarget,
setTimeout,
setTimeoutWithTarget,
};
Services.scriptloader.loadSubScript(
"resource://testing-common/sinon-7.2.7.js",
obj
);
const sinon = obj.global.sinon;
export const sinon = obj.global.sinon;
// ================================================

View File

@ -15,7 +15,7 @@ TESTING_JS_MODULES += [
"FileTestUtils.sys.mjs",
"MockRegistrar.sys.mjs",
"sinon-7.2.7.js",
"Sinon.jsm",
"Sinon.sys.mjs",
"StructuredLog.sys.mjs",
"TestUtils.sys.mjs",
"XPCShellContentUtils.sys.mjs",

View File

@ -7,7 +7,9 @@ const { RemoteSettings } = ChromeUtils.importESModule(
"resource://services-settings/remote-settings.sys.mjs"
);
let { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
let { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
// Name of the RemoteSettings collection containing the rules.
const COLLECTION_NAME = "cookie-banner-rules-list";

View File

@ -24,7 +24,9 @@ add_setup(async () => {
const { WebRequest } = ChromeUtils.import(
"resource://gre/modules/WebRequest.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
gTabLookupSpy = sinon.spy(WebRequest, "getTabIdForChannelWrapper");
await ExtensionTestUtils.startAddonManager();

View File

@ -19,7 +19,9 @@ const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
add_task(async function test_hasPersistedScripts_startup_cache() {
let extension1 = ExtensionTestUtils.loadExtension({

View File

@ -1 +1,3 @@
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { JsonSchema } = ChromeUtils.importESModule(
"resource://gre/modules/JsonSchema.sys.mjs"
);

View File

@ -1,4 +1,6 @@
"use strict";
// Globals
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);

View File

@ -20,6 +20,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
JsonSchema: "resource://gre/modules/JsonSchema.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
@ -29,7 +30,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
NormandyUtils: "resource://normandy/lib/NormandyUtils.jsm",
_RemoteSettingsExperimentLoader:
"resource://nimbus/lib/RemoteSettingsExperimentLoader.jsm",
sinon: "resource://testing-common/Sinon.jsm",
FeatureManifest: "resource://nimbus/FeatureManifest.js",
});

View File

@ -4,7 +4,9 @@
"use strict";
// Globals
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
XPCOMUtils.defineLazyModuleGetters(this, {
ExperimentManager: "resource://nimbus/lib/ExperimentManager.jsm",

View File

@ -1,7 +1,9 @@
"use strict";
// Globals
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);

View File

@ -15,7 +15,9 @@ const { NormandyUtils } = ChromeUtils.import(
const { RecipeRunner } = ChromeUtils.import(
"resource://normandy/lib/RecipeRunner.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const FIXTURE_ADDON_ID = "normandydriver-a@example.com";
const UUID_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;

View File

@ -40,7 +40,9 @@ const FileInputStream = Components.Constructor(
"init"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
// Make sinon assertions fail in a way that mochitest understands
sinon.assert.fail = function(message) {

View File

@ -1,3 +1,5 @@
"use strict";
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
var { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);

View File

@ -5,7 +5,9 @@ const { ExperimentAPI } = ChromeUtils.import(
"resource://nimbus/ExperimentAPI.jsm"
);
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
// Dummy migrator to change and detect importable behavior.
const gTestMigrator = {

View File

@ -1,4 +1,6 @@
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
add_task(async function test_noFilter() {
let openingFunc = () =>

View File

@ -1,4 +1,6 @@
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
const { getFxAccountsSingleton } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm"

View File

@ -4,7 +4,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { LoginManagerParent } = ChromeUtils.import(
"resource://gre/modules/LoginManagerParent.jsm"
);

View File

@ -4,7 +4,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { LoginManagerParent } = ChromeUtils.import(
"resource://gre/modules/LoginManagerParent.jsm"
);

View File

@ -4,7 +4,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const { LoginManagerParent } = ChromeUtils.import(
"resource://gre/modules/LoginManagerParent.jsm"
);

View File

@ -11,7 +11,9 @@
let { LoginExport } = ChromeUtils.import(
"resource://gre/modules/LoginExport.jsm"
);
let { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
let { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
/**
* Saves the logins to a temporary CSV file, reads the lines and returns the CSV lines.

View File

@ -3,7 +3,9 @@
"use strict";
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const NEW_VIDEO_ASPECT_RATIO = 1.334;

View File

@ -179,7 +179,9 @@ add_task(async function invalid_properties_for_bookmark_type() {
});
add_task(async function test_insert_into_root_throws() {
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
sandbox.stub(PlacesUtils, "isInAutomation").get(() => false);
registerCleanupFunction(() => sandbox.restore());

View File

@ -2808,7 +2808,9 @@ add_task(async function test_preventive_maintenance() {
// ------------------------------------------------------------------------------
add_task(async function test_idle_daily() {
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const sandbox = sinon.createSandbox();
sandbox.stub(PlacesDBUtils, "maintenanceOnIdle");
Services.prefs.clearUserPref("places.database.lastMaintenance");

View File

@ -7,13 +7,13 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
AddonTestUtils: "resource://testing-common/AddonTestUtils.jsm",
ExtensionTestUtils: "resource://testing-common/ExtensionXPCShellUtils.jsm",
sinon: "resource://testing-common/Sinon.jsm",
});
var gTestScope;

Some files were not shown because too many files have changed in this diff Show More