Bug 1797686 - Convert subprocess import consumers to import ES modules directly. r=kmag,application-update-reviewers,bytesized

Differential Revision: https://phabricator.services.mozilla.com/D160489
This commit is contained in:
Mark Banner 2022-10-27 20:17:39 +00:00
Родитель 4aeeff12a7
Коммит 640cf06c1b
17 изменённых файлов: 51 добавлений и 64 удалений

Просмотреть файл

@ -24,11 +24,9 @@ XPCOMUtils.defineLazyGetter(lazy, "log", () => {
return new ConsoleAPI(consoleOptions); return new ConsoleAPI(consoleOptions);
}); });
ChromeUtils.defineModuleGetter( ChromeUtils.defineESModuleGetters(lazy, {
lazy, Subprocess: "resource://gre/modules/Subprocess.sys.mjs",
"Subprocess", });
"resource://gre/modules/Subprocess.jsm"
);
/** /**
* Get the location of the user's macOS quarantine database. * Get the location of the user's macOS quarantine database.

Просмотреть файл

@ -15,13 +15,13 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
Subprocess: "resource://gre/modules/Subprocess.sys.mjs",
WindowsRegistry: "resource://gre/modules/WindowsRegistry.sys.mjs", WindowsRegistry: "resource://gre/modules/WindowsRegistry.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs", setTimeout: "resource://gre/modules/Timer.sys.mjs",
}); });
XPCOMUtils.defineLazyModuleGetters(lazy, { XPCOMUtils.defineLazyModuleGetters(lazy, {
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm", NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
Subprocess: "resource://gre/modules/Subprocess.jsm",
}); });
XPCOMUtils.defineLazyServiceGetter( XPCOMUtils.defineLazyServiceGetter(

Просмотреть файл

@ -1,7 +1,7 @@
"use strict"; "use strict";
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
const TEMP_DIR = Services.dirsvc.get("TmpD", Ci.nsIFile).path; const TEMP_DIR = Services.dirsvc.get("TmpD", Ci.nsIFile).path;

Просмотреть файл

@ -10,16 +10,13 @@ const BROWSER_TOOLBOX_WINDOW_URL =
"chrome://devtools/content/framework/browser-toolbox/window.html"; "chrome://devtools/content/framework/browser-toolbox/window.html";
const CHROME_DEBUGGER_PROFILE_NAME = "chrome_debugger_profile"; const CHROME_DEBUGGER_PROFILE_NAME = "chrome_debugger_profile";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { import {
require, require,
useDistinctSystemPrincipalLoader, useDistinctSystemPrincipalLoader,
releaseDistinctSystemPrincipalLoader, releaseDistinctSystemPrincipalLoader,
} from "resource://devtools/shared/loader/Loader.sys.mjs"; } from "resource://devtools/shared/loader/Loader.sys.mjs";
import { Subprocess } from "resource://gre/modules/Subprocess.sys.mjs";
const { Subprocess } = ChromeUtils.import(
"resource://gre/modules/Subprocess.jsm"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {}; const lazy = {};

Просмотреть файл

@ -23,8 +23,8 @@ function wrapInputStream(input) {
return wrapper; return wrapper;
} }
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
const XPI_NAME = "testjar.xpi"; const XPI_NAME = "testjar.xpi";

Просмотреть файл

@ -4,9 +4,7 @@
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const { Subprocess } = ChromeUtils.import( import { Subprocess } from "resource://gre/modules/Subprocess.sys.mjs";
"resource://gre/modules/Subprocess.jsm"
);
function getFirefoxExecutableFilename() { function getFirefoxExecutableFilename() {
if (AppConstants.platform === "win") { if (AppConstants.platform === "win") {

Просмотреть файл

@ -3,9 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { Subprocess } = ChromeUtils.import( import { Subprocess } from "resource://gre/modules/Subprocess.sys.mjs";
"resource://gre/modules/Subprocess.jsm"
);
export async function runBackgroundTask(commandLine) { export async function runBackgroundTask(commandLine) {
let sentinel = commandLine.getArgument(0); let sentinel = commandLine.getArgument(0);

Просмотреть файл

@ -24,11 +24,14 @@ const {
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
Subprocess: "resource://gre/modules/Subprocess.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, { XPCOMUtils.defineLazyModuleGetters(lazy, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm", AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
NativeManifests: "resource://gre/modules/NativeManifests.jsm", NativeManifests: "resource://gre/modules/NativeManifests.jsm",
OS: "resource://gre/modules/osfile.jsm", OS: "resource://gre/modules/osfile.jsm",
Subprocess: "resource://gre/modules/Subprocess.jsm",
}); });
// For a graceful shutdown (i.e., when the extension is unloaded or when it // For a graceful shutdown (i.e., when the extension is unloaded or when it

Просмотреть файл

@ -12,21 +12,17 @@ ChromeUtils.defineModuleGetter(
); );
ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
if (AppConstants.platform == "win") { if (AppConstants.platform == "win") {
ChromeUtils.defineModuleGetter( ChromeUtils.defineESModuleGetters(this, {
this, SubprocessImpl: "resource://gre/modules/subprocess/subprocess_win.sys.mjs",
"SubprocessImpl", });
"resource://gre/modules/subprocess/subprocess_win.jsm"
);
} else { } else {
ChromeUtils.defineModuleGetter( ChromeUtils.defineESModuleGetters(this, {
this, SubprocessImpl: "resource://gre/modules/subprocess/subprocess_unix.sys.mjs",
"SubprocessImpl", });
"resource://gre/modules/subprocess/subprocess_unix.jsm"
);
} }
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
// It's important that we use a space in this directory name to make sure we // It's important that we use a space in this directory name to make sure we

Просмотреть файл

@ -10,8 +10,8 @@ const { FileUtils } = ChromeUtils.importESModule(
"resource://gre/modules/FileUtils.sys.mjs" "resource://gre/modules/FileUtils.sys.mjs"
); );
const { Schemas } = ChromeUtils.import("resource://gre/modules/Schemas.jsm"); const { Schemas } = ChromeUtils.import("resource://gre/modules/Schemas.jsm");
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
const { NativeApp } = ChromeUtils.import( const { NativeApp } = ChromeUtils.import(
"resource://gre/modules/NativeMessaging.jsm" "resource://gre/modules/NativeMessaging.jsm"
@ -27,17 +27,13 @@ if (AppConstants.platform == "win") {
registerCleanupFunction(() => { registerCleanupFunction(() => {
registry.shutdown(); registry.shutdown();
}); });
ChromeUtils.defineModuleGetter( ChromeUtils.defineESModuleGetters(this, {
this, SubprocessImpl: "resource://gre/modules/subprocess/subprocess_win.sys.mjs",
"SubprocessImpl", });
"resource://gre/modules/subprocess/subprocess_win.jsm"
);
} else { } else {
ChromeUtils.defineModuleGetter( ChromeUtils.defineESModuleGetters(this, {
this, SubprocessImpl: "resource://gre/modules/subprocess/subprocess_unix.sys.mjs",
"SubprocessImpl", });
"resource://gre/modules/subprocess/subprocess_unix.jsm"
);
} }
const REGPATH = "Software\\Mozilla\\NativeMessagingHosts"; const REGPATH = "Software\\Mozilla\\NativeMessagingHosts";

Просмотреть файл

@ -5,8 +5,8 @@ const { setTimeout } = ChromeUtils.importESModule(
"resource://gre/modules/Timer.sys.mjs" "resource://gre/modules/Timer.sys.mjs"
); );
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
const ProcessTools = Cc["@mozilla.org/processtools-service;1"].getService( const ProcessTools = Cc["@mozilla.org/processtools-service;1"].getService(

Просмотреть файл

@ -16,8 +16,8 @@ const { AppConstants } = ChromeUtils.importESModule(
const lazy = {}; const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
Subprocess: "resource://gre/modules/Subprocess.jsm", Subprocess: "resource://gre/modules/Subprocess.sys.mjs",
}); });
XPCOMUtils.defineLazyServiceGetters(lazy, { XPCOMUtils.defineLazyServiceGetters(lazy, {

Просмотреть файл

@ -452,8 +452,9 @@ var dataProviders = {
let Subprocess; let Subprocess;
try { try {
// Subprocess is not available in all builds // Subprocess is not available in all builds
Subprocess = ChromeUtils.import("resource://gre/modules/Subprocess.jsm") Subprocess = ChromeUtils.importESModule(
.Subprocess; "resource://gre/modules/Subprocess.sys.mjs"
).Subprocess;
} catch (ex) { } catch (ex) {
done({}); done({});
return; return;

Просмотреть файл

@ -8,6 +8,6 @@ const { AppConstants } = ChromeUtils.importESModule(
); );
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
XPCOMUtils.defineLazyModuleGetters(this, { ChromeUtils.defineESModuleGetters(this, {
Subprocess: "resource://gre/modules/Subprocess.jsm", Subprocess: "resource://gre/modules/Subprocess.sys.mjs",
}); });

Просмотреть файл

@ -455,8 +455,8 @@ add_task(async function test_subprocess_invalid_json() {
if (AppConstants.isPlatformAndVersionAtLeast("win", "6")) { if (AppConstants.isPlatformAndVersionAtLeast("win", "6")) {
add_task(async function test_subprocess_inherited_descriptors() { add_task(async function test_subprocess_inherited_descriptors() {
let { libc, win32 } = ChromeUtils.import( let { libc, win32 } = ChromeUtils.importESModule(
"resource://gre/modules/subprocess/subprocess_win.jsm" "resource://gre/modules/subprocess/subprocess_win.sys.mjs"
); );
const { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm"); const { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
@ -791,8 +791,8 @@ add_task(async function test_subprocess_environmentAppend() {
if (AppConstants.platform !== "win") { if (AppConstants.platform !== "win") {
add_task(async function test_subprocess_nonASCII() { add_task(async function test_subprocess_nonASCII() {
const { libc } = ChromeUtils.import( const { libc } = ChromeUtils.importESModule(
"resource://gre/modules/subprocess/subprocess_unix.jsm" "resource://gre/modules/subprocess/subprocess_unix.sys.mjs"
); );
// Use TextDecoder rather than a string with a \xff escape, since // Use TextDecoder rather than a string with a \xff escape, since
@ -859,8 +859,8 @@ add_task(async function test_bad_executable() {
}); });
add_task(async function test_cleanup() { add_task(async function test_cleanup() {
let { getSubprocessImplForTest } = ChromeUtils.import( let { getSubprocessImplForTest } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
let worker = getSubprocessImplForTest().Process.getWorker(); let worker = getSubprocessImplForTest().Process.getWorker();

Просмотреть файл

@ -7,8 +7,8 @@
// b) starting a second copy of the same binary and making sure we can tell we // b) starting a second copy of the same binary and making sure we can tell we
// are no longer the only one that's opened it. // are no longer the only one that's opened it.
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
// Save off the real GRE directory and binary path before we register our // Save off the real GRE directory and binary path before we register our

Просмотреть файл

@ -6,8 +6,8 @@
* They should all result in the same installation hash. * They should all result in the same installation hash.
*/ */
const { Subprocess } = ChromeUtils.import( const { Subprocess } = ChromeUtils.importESModule(
"resource://gre/modules/Subprocess.jsm" "resource://gre/modules/Subprocess.sys.mjs"
); );
const XRE = Cc["@mozilla.org/xre/directory-provider;1"].getService( const XRE = Cc["@mozilla.org/xre/directory-provider;1"].getService(