Backed out changeset 5018856d8fee (bug 1758474) for causing node eslint failure. CLOSED TREE

This commit is contained in:
smolnar 2022-03-10 11:58:45 +02:00
parent 413a559c70
commit e89faa903f
82 changed files with 218 additions and 189 deletions

View File

@ -885,7 +885,8 @@ var FullScreen = {
XPCOMUtils.defineLazyGetter(FullScreen, "_permissionNotificationIDs", () => {
let { PermissionUI } = ChromeUtils.import(
"resource:///modules/PermissionUI.jsm"
"resource:///modules/PermissionUI.jsm",
{}
);
return (
Object.values(PermissionUI)

View File

@ -1645,7 +1645,8 @@ var gBrowserInit = {
) {
let windowFrameColor = new Color(
...ChromeUtils.import(
"resource:///modules/Windows8WindowFrameColor.jsm"
"resource:///modules/Windows8WindowFrameColor.jsm",
{}
).Windows8WindowFrameColor.get()
);
// Default to black for foreground text.
@ -2338,7 +2339,8 @@ var gBrowserInit = {
try {
DownloadsCommon.initializeAllDataLinks();
ChromeUtils.import(
"resource:///modules/DownloadsTaskbar.jsm"
"resource:///modules/DownloadsTaskbar.jsm",
{}
).DownloadsTaskbar.registerIndicator(window);
if (AppConstants.platform == "macosx") {
ChromeUtils.import(

View File

@ -6,12 +6,14 @@
// Pass an empty scope object to the import to prevent "leaked window property"
// errors in tests.
var { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
var { TelemetryReportingPolicy } = ChromeUtils.import(
"resource://gre/modules/TelemetryReportingPolicy.jsm"
);
var Preferences = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm",
{}
).Preferences;
var TelemetryReportingPolicy = ChromeUtils.import(
"resource://gre/modules/TelemetryReportingPolicy.jsm",
{}
).TelemetryReportingPolicy;
const PREF_BRANCH = "datareporting.policy.";
const PREF_FIRST_RUN = "toolkit.telemetry.reportingpolicy.firstRun";

View File

@ -82,8 +82,10 @@ add_task(async function() {
let updateChannel = null;
try {
updateChannel = ChromeUtils.import("resource://gre/modules/UpdateUtils.jsm")
.UpdateUtils.UpdateChannel;
updateChannel = ChromeUtils.import(
"resource://gre/modules/UpdateUtils.jsm",
{}
).UpdateUtils.UpdateChannel;
} catch (ex) {}
if (!updateChannel) {
Assert.ok(

View File

@ -265,7 +265,8 @@ add_task(async function checkAllTheDTDs() {
add_task(async function checkAllTheFluents() {
let uris = await getAllTheFiles(".ftl");
let { FluentParser, Visitor } = ChromeUtils.import(
"resource://testing-common/FluentSyntax.jsm"
"resource://testing-common/FluentSyntax.jsm",
{}
);
class TextElementVisitor extends Visitor {

View File

@ -407,9 +407,10 @@ add_task(async function checkAllTheCSS() {
// Create a clean iframe to load all the files into. This needs to live at a
// chrome URI so that it's allowed to load and parse any styles.
let testFile = getRootDirectory(gTestPath) + "dummy_page.html";
let { HiddenFrame } = ChromeUtils.import(
"resource://gre/modules/HiddenFrame.jsm"
);
let HiddenFrame = ChromeUtils.import(
"resource://gre/modules/HiddenFrame.jsm",
{}
).HiddenFrame;
let hiddenFrame = new HiddenFrame();
let win = await hiddenFrame.get();
let iframe = win.document.createElementNS(

View File

@ -3,7 +3,7 @@
*/
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
});
ChromeUtils.defineModuleGetter(

View File

@ -3,7 +3,8 @@ const { AddonManagerPrivate } = ChromeUtils.import(
);
const { AddonTestUtils } = ChromeUtils.import(
"resource://testing-common/AddonTestUtils.jsm"
"resource://testing-common/AddonTestUtils.jsm",
{}
);
AddonTestUtils.initMochitest(this);

View File

@ -104,7 +104,7 @@ function promiseIndicatorWindow() {
}
async function assertWebRTCIndicatorStatus(expected) {
let ui = ChromeUtils.import("resource:///modules/webrtcUI.jsm").webrtcUI;
let ui = ChromeUtils.import("resource:///modules/webrtcUI.jsm", {}).webrtcUI;
let expectedState = expected ? "visible" : "hidden";
let msg = "WebRTC indicator " + expectedState;
if (!expected && ui.showGlobalIndicator) {

View File

@ -1642,7 +1642,8 @@ BrowserGlue.prototype = {
let updateChannel;
try {
updateChannel = ChromeUtils.import(
"resource://gre/modules/UpdateUtils.jsm"
"resource://gre/modules/UpdateUtils.jsm",
{}
).UpdateUtils.UpdateChannel;
} catch (ex) {}
if (updateChannel) {

View File

@ -33,7 +33,8 @@ ChromeUtils.defineModuleGetter(
"resource:///modules/MacAttribution.jsm"
);
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
// tip: set maxLogLevel to "debug" and use log.debug() to create detailed
// messages during development. See LOG_LEVELS in Console.jsm for details.

View File

@ -9,7 +9,8 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
// tip: set maxLogLevel to "debug" and use log.debug() to create detailed
// messages during development. See LOG_LEVELS in Console.jsm for details.

View File

@ -19,9 +19,10 @@ function checkSubviewButtonClass(menuId, buttonId, subviewId) {
return async function() {
// Initialize DevTools before starting the test in order to create menuitems in
// menuWebDeveloperPopup.
ChromeUtils.import("resource://devtools/shared/loader/Loader.jsm").require(
"devtools/client/framework/devtools-browser"
);
ChromeUtils.import(
"resource://devtools/shared/loader/Loader.jsm",
{}
).require("devtools/client/framework/devtools-browser");
info(
"Checking for items without the subviewbutton class in " +

View File

@ -318,9 +318,10 @@ DistributionCustomizer.prototype = {
return;
}
let { ProfileAge } = ChromeUtils.import(
"resource://gre/modules/ProfileAge.jsm"
);
let ProfileAge = ChromeUtils.import(
"resource://gre/modules/ProfileAge.jsm",
{}
).ProfileAge;
let profileAge = await ProfileAge();
let resetDate = await profileAge.reset;

View File

@ -21,7 +21,8 @@ const { XPCOMUtils } = ChromeUtils.import(
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
maxLogLevelPref: "browser.esedbreader.loglevel",
prefix: "ESEDBReader",

View File

@ -16,7 +16,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
FxAccountsPairingFlow: "resource://gre/modules/FxAccountsPairing.jsm",
});
const { require } = ChromeUtils.import(
"resource://devtools/shared/loader/Loader.jsm"
"resource://devtools/shared/loader/Loader.jsm",
{}
);
const QR = require("devtools/shared/qrcode/index");

View File

@ -5,7 +5,7 @@
/* import-globals-from preferences.js */
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
});
const FXA_PAGE_LOGGED_OUT = 0;

View File

@ -3,9 +3,13 @@
"use strict";
const { UIState } = ChromeUtils.import("resource://services-sync/UIState.jsm");
const { UIState } = ChromeUtils.import(
"resource://services-sync/UIState.jsm",
{}
);
const { FxAccountsPairingFlow } = ChromeUtils.import(
"resource://gre/modules/FxAccountsPairing.jsm"
"resource://gre/modules/FxAccountsPairing.jsm",
{}
);
// Use sinon for mocking.

View File

@ -41,12 +41,12 @@ function clearHistoryAndWait() {
*/
async function runTest() {
let { FileUtils } = ChromeUtils.import(
"resource://gre/modules/FileUtils.jsm"
);
let { DownloadLastDir } = ChromeUtils.import(
"resource://gre/modules/DownloadLastDir.jsm"
);
let FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", {})
.FileUtils;
let DownloadLastDir = ChromeUtils.import(
"resource://gre/modules/DownloadLastDir.jsm",
{}
).DownloadLastDir;
let tmpDir = FileUtils.getDir("TmpD", [], true);
let dir1 = newDirectory();

View File

@ -6,12 +6,12 @@
function test() {
waitForExplicitFinish();
let { FileUtils } = ChromeUtils.import(
"resource://gre/modules/FileUtils.jsm"
);
let { DownloadLastDir } = ChromeUtils.import(
"resource://gre/modules/DownloadLastDir.jsm"
);
let FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", {})
.FileUtils;
let DownloadLastDir = ChromeUtils.import(
"resource://gre/modules/DownloadLastDir.jsm",
{}
).DownloadLastDir;
let MockFilePicker = SpecialPowers.MockFilePicker;
let launcher = {
source: Services.io.newURI("http://test1.com/file"),

View File

@ -6,12 +6,12 @@
function test() {
waitForExplicitFinish();
let { FileUtils } = ChromeUtils.import(
"resource://gre/modules/FileUtils.jsm"
);
let { DownloadLastDir } = ChromeUtils.import(
"resource://gre/modules/DownloadLastDir.jsm"
);
let FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", {})
.FileUtils;
let DownloadLastDir = ChromeUtils.import(
"resource://gre/modules/DownloadLastDir.jsm",
{}
).DownloadLastDir;
let MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init(window);

View File

@ -20,11 +20,6 @@ ChromeUtils.defineModuleGetter(
"TestUtils",
"resource://testing-common/TestUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"FileUtils",
"resource://gre/modules/FileUtils.jsm"
);
function whenNewWindowLoaded(aOptions, aCallback) {
let win = OpenBrowserWindow(aOptions);
@ -61,6 +56,8 @@ async function openAboutPrivateBrowsing() {
}
function newDirectory() {
let FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", {})
.FileUtils;
let tmpDir = FileUtils.getDir("TmpD", [], true);
let dir = tmpDir.clone();
dir.append("testdir");
@ -69,6 +66,8 @@ function newDirectory() {
}
function newFileInDirectory(aDir) {
let FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", {})
.FileUtils;
let file = aDir.clone();
file.append("testfile");
file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_FILE);

View File

@ -102,10 +102,12 @@
window.addEventListener("unload", this.destroy);
this.FormHistory = ChromeUtils.import(
"resource://gre/modules/FormHistory.jsm"
"resource://gre/modules/FormHistory.jsm",
{}
).FormHistory;
this.SearchSuggestionController = ChromeUtils.import(
"resource://gre/modules/SearchSuggestionController.jsm"
"resource://gre/modules/SearchSuggestionController.jsm",
{}
).SearchSuggestionController;
Services.obs.addObserver(this.observer, "browser-search-engine-modified");

View File

@ -3,9 +3,10 @@
"use strict";
var { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
var Preferences = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm",
{}
).Preferences;
function test() {
waitForExplicitFinish();

View File

@ -83,9 +83,10 @@ add_task(async function test_add() {
add_task(async function test_diacritics() {
const diacritic_engine = "Foo \u2661";
let { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
let Preferences = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm",
{}
).Preferences;
Preferences.set("browser.search.hiddenOneOffs", diacritic_engine);
await SearchTestUtils.promiseNewSearchEngine(

View File

@ -7,9 +7,10 @@ const searchPopup = document.getElementById("PopupSearchAutoComplete");
const diacritic_engine = "Foo \u2661";
var { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);
var Preferences = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm",
{}
).Preferences;
let searchIcon;

View File

@ -28,7 +28,8 @@ add_task(async function init() {
// Make sure that we have a profile before initializing SessionFile
let profd = do_get_profile();
SessionFile = ChromeUtils.import(
"resource:///modules/sessionstore/SessionFile.jsm"
"resource:///modules/sessionstore/SessionFile.jsm",
{}
).SessionFile;
Paths = SessionFile.Paths;

View File

@ -58,7 +58,8 @@ add_task(async function test_migration() {
// Make sure that we have a profile before initializing SessionFile.
let profd = do_get_profile();
SessionFile = ChromeUtils.import(
"resource:///modules/sessionstore/SessionFile.jsm"
"resource:///modules/sessionstore/SessionFile.jsm",
{}
).SessionFile;
Paths = SessionFile.Paths;

View File

@ -4,7 +4,8 @@
function run_test() {
let profd = do_get_profile();
var SessionFile = ChromeUtils.import(
"resource:///modules/sessionstore/SessionFile.jsm"
"resource:///modules/sessionstore/SessionFile.jsm",
{}
).SessionFile;
let sourceSession = do_get_file("data/sessionstore_invalid.js");

View File

@ -9,7 +9,8 @@
function run_test() {
let profd = do_get_profile();
var SessionFile = ChromeUtils.import(
"resource:///modules/sessionstore/SessionFile.jsm"
"resource:///modules/sessionstore/SessionFile.jsm",
{}
).SessionFile;
let sourceSession = do_get_file("data/sessionstore_valid.js");

View File

@ -30,11 +30,12 @@ let { getChromeWindow } = ChromeUtils.import(
const { UIState } = ChromeUtils.import("resource://services-sync/UIState.jsm");
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
});
let log = ChromeUtils.import(
"resource://gre/modules/Log.jsm"
"resource://gre/modules/Log.jsm",
{}
).Log.repository.getLogger("Sync.RemoteTabs");
var EXPORTED_SYMBOLS = ["SyncedTabsDeckComponent"];

View File

@ -5,7 +5,8 @@
"use strict";
let log = ChromeUtils.import(
"resource://gre/modules/Log.jsm"
"resource://gre/modules/Log.jsm",
{}
).Log.repository.getLogger("Sync.RemoteTabs");
var EXPORTED_SYMBOLS = ["SyncedTabsDeckView"];

View File

@ -10,7 +10,8 @@ const { XPCOMUtils } = ChromeUtils.import(
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
let log = ChromeUtils.import(
"resource://gre/modules/Log.jsm"
"resource://gre/modules/Log.jsm",
{}
).Log.repository.getLogger("Sync.RemoteTabs");
XPCOMUtils.defineLazyModuleGetters(this, {

View File

@ -17,7 +17,8 @@ let { getChromeWindow } = ChromeUtils.import(
);
let log = ChromeUtils.import(
"resource://gre/modules/Log.jsm"
"resource://gre/modules/Log.jsm",
{}
).Log.repository.getLogger("Sync.RemoteTabs");
var EXPORTED_SYMBOLS = ["TabListView"];

View File

@ -5,7 +5,7 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
});
do_get_profile(); // fxa needs a profile directory for storage.

View File

@ -107,7 +107,8 @@ class TranslationChild extends JSWindowActorChild {
let engine = Services.prefs.getCharPref("browser.translation.engine");
let importScope = ChromeUtils.import(
`resource:///modules/translation/${engine}Translator.jsm`
`resource:///modules/translation/${engine}Translator.jsm`,
{}
);
let translator = new importScope[engine + "Translator"](
translationDocument,

View File

@ -58,7 +58,8 @@ const TARGET_SEARCHENGINE_PREFIX = "searchEngine-";
// Create a new instance of the ConsoleAPI so we can control the maxLogLevel with a pref.
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
maxLogLevelPref: PREF_LOG_LEVEL,
prefix: "UITour",

View File

@ -91,7 +91,7 @@ class ProvidersManager {
// providers at the front.
this.providers = [];
for (let [symbol, module] of Object.entries(localProviderModules)) {
let { [symbol]: provider } = ChromeUtils.import(module);
let { [symbol]: provider } = ChromeUtils.import(module, {});
this.registerProvider(provider);
}
// Tracks ongoing Query instances by queryContext.
@ -105,7 +105,7 @@ class ProvidersManager {
// This maps muxer names to muxers.
this.muxers = new Map();
for (let [symbol, module] of Object.entries(localMuxerModules)) {
let { [symbol]: muxer } = ChromeUtils.import(module);
let { [symbol]: muxer } = ChromeUtils.import(module, {});
this.registerMuxer(muxer);
}
}

View File

@ -278,7 +278,8 @@
this.setAttribute("formautofillattached", "true");
let { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
"resource://gre/modules/AppConstants.jsm",
{}
);
let buttonTextBundleKey;

View File

@ -6,7 +6,8 @@
"use strict";
const { setTimeout, clearTimeout } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm"
"resource://gre/modules/Timer.jsm",
{}
);
var FormAutofillHandler, OSKeyStore;

View File

@ -4,6 +4,8 @@
*/
"use strict";
ChromeUtils.import("resource:///modules/CustomizableUI.jsm", {});
add_task(async function testScreenshotButtonDisabled() {
info("Test the Screenshots button in the panel");

View File

@ -1,7 +1,7 @@
/* globals ProcessHangMonitor */
const { WebExtensionPolicy } = Cu.getGlobalForObject(
ChromeUtils.import("resource://gre/modules/Services.jsm")
ChromeUtils.import("resource://gre/modules/Services.jsm", {})
);
const { UpdateUtils } = ChromeUtils.import(

View File

@ -120,9 +120,10 @@ add_task(async function test_sessionRestore() {
};
// Save the current session.
let { SessionStore } = ChromeUtils.import(
"resource:///modules/sessionstore/SessionStore.jsm"
);
let SessionStore = ChromeUtils.import(
"resource:///modules/sessionstore/SessionStore.jsm",
{}
).SessionStore;
// Load the custom state and wait for SSTabRestored, as we want to make sure
// that the URI counting code was hit.

View File

@ -36,8 +36,10 @@ async function setup() {
let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
isnot(aAddon, null, "The mozscreenshots extension should be installed");
TestRunner = ChromeUtils.import("resource://mozscreenshots/TestRunner.jsm")
.TestRunner;
TestRunner = ChromeUtils.import(
"resource://mozscreenshots/TestRunner.jsm",
{}
).TestRunner;
TestRunner.initTest(this);
}

View File

@ -17,7 +17,8 @@ const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
// See LOG_LEVELS in Console.jsm. Common examples: "All", "Info", "Warn", & "Error".
const PREF_LOG_LEVEL = "extensions.mozscreenshots@mozilla.org.loglevel";
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
maxLogLevel: "info",
maxLogLevelPref: PREF_LOG_LEVEL,

View File

@ -10,9 +10,10 @@ registerManifests(manifests);
function run_test() {
const uuidGenerator = Services.uuid;
let { newAppInfo } = ChromeUtils.import(
"resource://testing-common/AppInfo.jsm"
);
let newAppInfo = ChromeUtils.import(
"resource://testing-common/AppInfo.jsm",
{}
).newAppInfo;
let XULAppInfo = newAppInfo({
name: "XPCShell",
ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",

View File

@ -8,7 +8,8 @@ const Services = require("Services");
const ChromeUtils = require("ChromeUtils");
const { RemoteSettings } = ChromeUtils.import(
"resource://services-settings/remote-settings.js"
"resource://services-settings/remote-settings.js",
{}
);
const TARGET_BROWSER_ID = [

View File

@ -5,7 +5,7 @@ reject-chromeutils-import-params
largely deprecated.
The use of object destructuring is preferred over the second parameter being
``this`` or ``{}``.
``this``.
Using explicit exports is preferred over the second parameter being ``null``.
@ -16,7 +16,6 @@ Examples of incorrect code for this rule:
ChromeUtils.import("resource://gre/modules/Services.jsm", this);
ChromeUtils.import("resource://gre/modules/Services.jsm", null);
ChromeUtils.import("resource://gre/modules/Services.jsm", {});
Examples of correct code for this rule:
---------------------------------------

View File

@ -37,7 +37,8 @@ ChromeUtils.defineModuleGetter(
XPCOMUtils.defineLazyGetter(this, "Log", () => {
return ChromeUtils.import(
"resource://gre/modules/AndroidLog.jsm"
"resource://gre/modules/AndroidLog.jsm",
{}
).AndroidLog.bind("Push");
});

View File

@ -1,7 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
var { Downloads } = ChromeUtils.import("resource://gre/modules/Downloads.jsm");
var Downloads = ChromeUtils.import("resource://gre/modules/Downloads.jsm", {})
.Downloads;
var gTestRoot = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",

View File

@ -6,7 +6,7 @@ const ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(
);
const { WebExtensionPolicy } = Cu.getGlobalForObject(
ChromeUtils.import("resource://gre/modules/Services.jsm")
ChromeUtils.import("resource://gre/modules/Services.jsm", {})
);
const FAKE_ADDON_ID = "test-webext-addon@mozilla.org";

View File

@ -39,9 +39,10 @@ add_task(async function test_windowlessBrowserTroubleshootCrash() {
}
ok(true, "not crashed");
var { Troubleshoot } = ChromeUtils.import(
"resource://gre/modules/Troubleshoot.jsm"
);
var Troubleshoot = ChromeUtils.import(
"resource://gre/modules/Troubleshoot.jsm",
{}
).Troubleshoot;
var data = await new Promise((resolve, reject) => {
Troubleshoot.snapshot(data => {
resolve(data);

View File

@ -88,7 +88,7 @@ var GeckoViewUtils = {
XPCOMUtils.defineLazyGetter(scope, name, _ => {
let ret = undefined;
if (module) {
ret = ChromeUtils.import(module)[name];
ret = ChromeUtils.import(module, {})[name];
} else if (service) {
ret = Cc[service].getService(Ci.nsISupports).wrappedJSObject;
} else if (typeof handler === "function") {

View File

@ -9,7 +9,7 @@ function test() {
// We overload this test to include verifying that httpd.js is
// importable as a testing-only JS module.
ChromeUtils.import("resource://testing-common/httpd.js");
ChromeUtils.import("resource://testing-common/httpd.js", {});
nextTest();
}

View File

@ -12,6 +12,10 @@
// * it does a sanity check to ensure other cert verifier behavior is
// unmodified
const { setTimeout } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm",
{}
);
const { RemoteSecuritySettings } = ChromeUtils.import(
"resource://gre/modules/psm/RemoteSecuritySettings.jsm"
);

View File

@ -18,7 +18,7 @@ function expectImportsToSucceed(mm, base = MODULE_BASE) {
let resource = base + m;
let succeeded = false;
try {
ChromeUtils.import(resource);
ChromeUtils.import(resource, {});
succeeded = true;
} catch (e) {}
@ -33,7 +33,7 @@ function expectImportsToFail(mm, base = MODULE_BASE) {
let resource = base + m;
let succeeded = false;
try {
ChromeUtils.import(resource);
ChromeUtils.import(resource, {});
succeeded = true;
} catch (e) {}

View File

@ -7,6 +7,6 @@ function run_test() {
for (let m of modules) {
let resource = "resource://services-crypto/" + m;
_("Attempting to import: " + resource);
ChromeUtils.import(resource);
ChromeUtils.import(resource, {});
}
}

View File

@ -85,7 +85,8 @@ FxAccountsPushService.prototype = {
this.fxai = options.fxai;
} else {
let { fxAccounts } = ChromeUtils.import(
"resource://gre/modules/FxAccounts.jsm"
"resource://gre/modules/FxAccounts.jsm",
{}
);
this.fxai = fxAccounts._internal;
}

View File

@ -4,16 +4,20 @@
"use strict";
const { FxAccountsPairingFlow } = ChromeUtils.import(
"resource://gre/modules/FxAccountsPairing.jsm"
"resource://gre/modules/FxAccountsPairing.jsm",
{}
);
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
"resource://gre/modules/EventEmitter.jsm",
{}
);
const { PromiseUtils } = ChromeUtils.import(
"resource://gre/modules/PromiseUtils.jsm"
"resource://gre/modules/PromiseUtils.jsm",
{}
);
const { CryptoUtils } = ChromeUtils.import(
"resource://services-crypto/utils.js"
"resource://services-crypto/utils.js",
{}
);
XPCOMUtils.defineLazyModuleGetters(this, {
jwcrypto: "resource://services-crypto/jwcrypto.jsm",

View File

@ -36,7 +36,8 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
// See LOG_LEVELS in Console.jsm. Common examples: "all", "debug", "info", "warn", "error".
XPCOMUtils.defineLazyGetter(this, "log", () => {
const { ConsoleAPI } = ChromeUtils.import(
"resource://gre/modules/Console.jsm"
"resource://gre/modules/Console.jsm",
{}
);
return new ConsoleAPI({
maxLogLevel: "warn",

View File

@ -20,7 +20,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js");
return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
});
this.EXPORTED_SYMBOLS = ["SyncDisconnectInternal", "SyncDisconnect"];
@ -32,7 +32,7 @@ this.SyncDisconnectInternal = {
// mocked by tests.
getWeave() {
return ChromeUtils.import("resource://services-sync/main.js").Weave;
return ChromeUtils.import("resource://services-sync/main.js", {}).Weave;
},
// Returns a promise that resolves when we are not syncing, waiting until

View File

@ -39,12 +39,12 @@ function run_test() {
for (let m of modules) {
let res = "resource://services-sync/" + m;
_("Attempting to load " + res);
ChromeUtils.import(res);
ChromeUtils.import(res, {});
}
for (let m of testingModules) {
let res = "resource://testing-common/services/sync/" + m;
_("Attempting to load " + res);
ChromeUtils.import(res);
ChromeUtils.import(res, {});
}
}

View File

@ -272,9 +272,10 @@ TalosPowersService.prototype = {
// We can wait for various startup items here to complete during
// the getInfo.html step for Talos so that subsequent runs don't
// have to do things like re-request the SafeBrowsing list.
let { SafeBrowsing } = ChromeUtils.import(
"resource://gre/modules/SafeBrowsing.jsm"
);
let SafeBrowsing = ChromeUtils.import(
"resource://gre/modules/SafeBrowsing.jsm",
{}
).SafeBrowsing;
// Speed things up in case nobody else called this:
SafeBrowsing.init();

View File

@ -562,7 +562,8 @@ function _execute_test() {
let coverageCollector = null;
if (typeof _JSCOV_DIR === "string") {
let _CoverageCollector = ChromeUtils.import(
"resource://testing-common/CoverageUtils.jsm"
"resource://testing-common/CoverageUtils.jsm",
{}
).CoverageCollector;
coverageCollector = new _CoverageCollector(_JSCOV_DIR);
}

View File

@ -15,7 +15,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
// tip: set maxLogLevel to "debug" and use log.debug() to create detailed
// messages during development. See LOG_LEVELS in Console.jsm for details.

View File

@ -11,7 +11,8 @@ const { XPCOMUtils } = ChromeUtils.import(
);
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
// tip: set maxLogLevel to "debug" and use log.debug() to create detailed
// messages during development. See LOG_LEVELS in Console.jsm for details.

View File

@ -150,9 +150,10 @@ var FormAutofill = {
scope.debug = debug;
XPCOMUtils.defineLazyGetter(scope, "log", () => {
let { ConsoleAPI } = ChromeUtils.import(
"resource://gre/modules/Console.jsm"
);
let ConsoleAPI = ChromeUtils.import(
"resource://gre/modules/Console.jsm",
{}
).ConsoleAPI;
return new ConsoleAPI({
maxLogLevelPref: "extensions.formautofill.loglevel",
prefix: logPrefix,

View File

@ -38,7 +38,7 @@ if (typeof Components != "undefined") {
this.exports = {};
({ Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"));
this.Services = Services;
Meta = ChromeUtils.import("resource://gre/modules/PromiseWorker.jsm")
Meta = ChromeUtils.import("resource://gre/modules/PromiseWorker.jsm", {})
.BasePromiseWorker.Meta;
} else {
importScripts("resource://gre/modules/workers/require.js");

View File

@ -7,7 +7,8 @@ const { LoginRelatedRealmsParent } = ChromeUtils.import(
"resource://gre/modules/LoginRelatedRealms.jsm"
);
const { RemoteSettings } = ChromeUtils.import(
"resource://services-settings/remote-settings.js"
"resource://services-settings/remote-settings.js",
{}
);
const REMOTE_SETTINGS_COLLECTION = "websites-with-shared-credential-backends";

View File

@ -9,7 +9,8 @@
"use strict";
const { RemoteSettings } = ChromeUtils.import(
"resource://services-settings/remote-settings.js"
"resource://services-settings/remote-settings.js",
{}
);
const REMOTE_SETTINGS_COLLECTION = "password-recipes";

View File

@ -27,7 +27,8 @@ XPCOMUtils.defineLazyServiceGetters(this, {
XPCOMUtils.defineLazyGlobalGetters(this, ["XMLSerializer"]);
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
let consoleOptions = {
// tip: set maxLogLevel to "debug" and use log.debug() to create detailed
// messages during development. See LOG_LEVELS in Console.jsm for details.

View File

@ -482,7 +482,7 @@
if (this.isRemoteBrowser) {
if (!this._remoteFinder) {
let jsm = "resource://gre/modules/FinderParent.jsm";
let { FinderParent } = ChromeUtils.import(jsm);
let { FinderParent } = ChromeUtils.import(jsm, {});
this._remoteFinder = new FinderParent(this);
}
return this._remoteFinder;
@ -492,9 +492,8 @@
return null;
}
let { Finder } = ChromeUtils.import(
"resource://gre/modules/Finder.jsm"
);
let Finder = ChromeUtils.import("resource://gre/modules/Finder.jsm", {})
.Finder;
this._finder = new Finder(this.docShell);
}
return this._finder;

View File

@ -50,9 +50,8 @@
return null;
}
let { Finder } = ChromeUtils.import(
"resource://gre/modules/Finder.jsm"
);
let Finder = ChromeUtils.import("resource://gre/modules/Finder.jsm", {})
.Finder;
this._finder = new Finder(this.docShell);
}
return this._finder;

View File

@ -377,7 +377,8 @@ var OSKeyStore = {
};
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {})
.ConsoleAPI;
return new ConsoleAPI({
maxLogLevelPref: "toolkit.osKeyStore.loglevel",
prefix: "OSKeyStore",

View File

@ -229,7 +229,8 @@ var dataProviders = {
if (AppConstants.MOZ_UPDATER) {
data.updateChannel = ChromeUtils.import(
"resource://gre/modules/UpdateUtils.jsm"
"resource://gre/modules/UpdateUtils.jsm",
{}
).UpdateUtils.UpdateChannel;
}

View File

@ -720,7 +720,7 @@ var AddonManagerInternal = {
CATEGORY_PROVIDER_MODULE
)) {
try {
ChromeUtils.import(url);
ChromeUtils.import(url, {});
logger.debug(`Loaded provider scope for ${url}`);
} catch (e) {
AddonManagerPrivate.recordException(

View File

@ -54,7 +54,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
});
XPCOMUtils.defineLazyGetter(this, "IconDetails", () => {
return ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm")
return ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm", {})
.ExtensionParent.IconDetails;
});

View File

@ -1,11 +1,13 @@
/* eslint max-len: ["error", 80] */
const { AddonTestUtils } = ChromeUtils.import(
"resource://testing-common/AddonTestUtils.jsm"
"resource://testing-common/AddonTestUtils.jsm",
{}
);
const { ExtensionPermissions } = ChromeUtils.import(
"resource://gre/modules/ExtensionPermissions.jsm"
"resource://gre/modules/ExtensionPermissions.jsm",
{}
);
const SUPPORT_URL = Services.urlFormatter.formatURL(

View File

@ -1,5 +1,6 @@
const { AddonTestUtils } = ChromeUtils.import(
"resource://testing-common/AddonTestUtils.jsm"
"resource://testing-common/AddonTestUtils.jsm",
{}
);
AddonTestUtils.initMochitest(this);

View File

@ -11,7 +11,8 @@ registerCleanupFunction(() => {
});
const { AddonTestUtils } = ChromeUtils.import(
"resource://testing-common/AddonTestUtils.jsm"
"resource://testing-common/AddonTestUtils.jsm",
{}
);
const PREF_UPDATE_ENABLED = "extensions.update.enabled";

View File

@ -19,13 +19,6 @@ function isIdentifier(node, id) {
}
module.exports = function(context) {
function getRangeAfterArgToEnd(argNumber, args) {
let sourceCode = context.getSourceCode();
return [
sourceCode.getTokenAfter(args[argNumber]).range[0],
args.at(-1).range[1],
];
}
// ---------------------------------------------------------------------------
// Public
// --------------------------------------------------------------------------
@ -38,14 +31,16 @@ module.exports = function(context) {
isIdentifier(callee.property, "import") &&
node.arguments.length >= 2
) {
let targetObj = node.arguments[1];
if (targetObj.type == "Literal" && targetObj.raw == "null") {
if (
node.arguments[1].type == "Literal" &&
node.arguments[1].raw == "null"
) {
context.report(
node,
"ChromeUtils.import should not be called with (..., null) to " +
"retrieve the JSM global object. Rely on explicit exports instead."
);
} else if (targetObj.type == "ThisExpression") {
} else if (node.arguments[1].type == "ThisExpression") {
context.report({
node,
message:
@ -68,27 +63,6 @@ module.exports = function(context) {
},
],
});
} else if (
targetObj.type == "ObjectExpression" &&
targetObj.properties.length == 0
) {
context.report({
node,
message:
"Passing an empty object to ChromeUtils.import is unnecessary",
suggest: [
{
desc:
"Passing an empty object to ChromeUtils.import is " +
"unnecessary - remove the empty object",
fix: fixer => {
return fixer.removeRange(
getRangeAfterArgToEnd(0, node.arguments)
);
},
},
],
});
}
}
},

View File

@ -82,19 +82,5 @@ const { My } = ChromeUtils.import("resource://some/path/to/My.jsm");`,
},
],
},
{
code: 'ChromeUtils.import("resource://some/path/to/My.js", {})',
errors: [
{
suggestions: [
{
desc:
"Passing an empty object to ChromeUtils.import is unnecessary - remove the empty object",
output: `ChromeUtils.import("resource://some/path/to/My.js")`,
},
],
},
],
},
],
});