Bug 1819597 - Convert security to ES modules. r=keeler,geckoview-reviewers,owlish

Differential Revision: https://phabricator.services.mozilla.com/D171333
This commit is contained in:
Mark Banner 2023-03-02 07:54:35 +00:00
Родитель 9b1f15288f
Коммит 6044092bf9
12 изменённых файлов: 30 добавлений и 39 удалений

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

@ -42,6 +42,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs",
RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs",
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
ScreenshotsUtils: "resource:///modules/ScreenshotsUtils.sys.mjs",
SearchSERPTelemetry: "resource:///modules/SearchSERPTelemetry.sys.mjs",
@ -90,10 +94,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
PluralForm: "resource://gre/modules/PluralForm.jsm",
ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm",
PublicSuffixList: "resource://gre/modules/netwerk-dns/PublicSuffixList.jsm",
RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.jsm",
RFPHelper: "resource://gre/modules/RFPHelper.jsm",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
Sanitizer: "resource:///modules/Sanitizer.jsm",

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

@ -16,6 +16,8 @@ ChromeUtils.defineESModuleGetters(this, {
EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
GeckoViewActorManager: "resource://gre/modules/GeckoViewActorManager.sys.mjs",
GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.sys.mjs",
RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(this, {
@ -24,8 +26,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
HistogramStopwatch: "resource://gre/modules/GeckoViewTelemetry.jsm",
InitializationTracker: "resource://gre/modules/GeckoViewTelemetry.jsm",
SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
RemoteSecuritySettings:
"resource://gre/modules/psm/RemoteSecuritySettings.jsm",
});
XPCOMUtils.defineLazyGetter(this, "WindowEventDispatcher", () =>

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

@ -2,8 +2,6 @@
* 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";
// A minimal ASN.1 DER decoder. Supports input lengths up to 65539 (one byte for
// the outer tag, one byte for the 0x82 length-length indicator, two bytes
// indicating a contents length of 65535, and then the 65535 bytes of contents).
@ -315,7 +313,7 @@ class DERDecoder {
}
}
const DER = {
export const DER = {
UNIVERSAL,
CONSTRUCTED,
CONTEXT_SPECIFIC,
@ -333,4 +331,3 @@ const DER = {
SET,
DERDecoder,
};
var EXPORTED_SYMBOLS = ["DER"];

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

@ -1,18 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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";
const EXPORTED_SYMBOLS = ["RemoteSecuritySettings"];
import { RemoteSettings } from "resource://services-settings/remote-settings.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const { RemoteSettings } = ChromeUtils.importESModule(
"resource://services-settings/remote-settings.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { X509 } = ChromeUtils.import("resource://gre/modules/psm/X509.jsm");
import { X509 } from "resource://gre/modules/psm/X509.sys.mjs";
const SECURITY_STATE_BUCKET = "security-state";
const SECURITY_STATE_SIGNER = "onecrl.content-signature.mozilla.org";
@ -225,7 +218,7 @@ const updateCertBlocklist = async function({
}
};
var RemoteSecuritySettings = {
export var RemoteSecuritySettings = {
_initialized: false,
OneCRLBlocklistClient: null,
IntermediatePreloadsClient: null,

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

@ -2,9 +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/. */
"use strict";
var { DER } = ChromeUtils.import("resource://gre/modules/psm/DER.jsm");
import { DER } from "resource://gre/modules/psm/DER.sys.mjs";
const ERROR_UNSUPPORTED_ASN1 = "unsupported asn.1";
const ERROR_TIME_NOT_VALID = "Time not valid";
@ -640,5 +638,4 @@ class SubjectPublicKeyInfo extends DecodedDER {
}
}
var X509 = { Certificate };
var EXPORTED_SYMBOLS = ["X509"];
export var X509 = { Certificate };

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

@ -55,9 +55,9 @@ XPCOM_MANIFESTS += [
]
EXTRA_JS_MODULES.psm += [
"DER.jsm",
"RemoteSecuritySettings.jsm",
"X509.jsm",
"DER.sys.mjs",
"RemoteSecuritySettings.sys.mjs",
"X509.sys.mjs",
]
EXPORTS += [

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

@ -23,7 +23,9 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { X509 } = ChromeUtils.import("resource://gre/modules/psm/X509.jsm");
const { X509 } = ChromeUtils.importESModule(
"resource://gre/modules/psm/X509.sys.mjs"
);
const isDebugBuild = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2)
.isDebugBuild;

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

@ -6,8 +6,8 @@ const { Utils } = ChromeUtils.import("resource://services-settings/Utils.jsm");
const { RemoteSettings } = ChromeUtils.importESModule(
"resource://services-settings/remote-settings.sys.mjs"
);
const { RemoteSecuritySettings } = ChromeUtils.import(
"resource://gre/modules/psm/RemoteSecuritySettings.jsm"
const { RemoteSecuritySettings } = ChromeUtils.importESModule(
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs"
);
const { OneCRLBlocklistClient } = RemoteSecuritySettings.init();

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

@ -12,8 +12,8 @@
// * it does a sanity check to ensure other cert verifier behavior is
// unmodified
const { RemoteSecuritySettings } = ChromeUtils.import(
"resource://gre/modules/psm/RemoteSecuritySettings.jsm"
const { RemoteSecuritySettings } = ChromeUtils.importESModule(
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs"
);
// First, we need to setup appInfo for the blocklist service to work

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

@ -36,8 +36,8 @@
"use strict";
do_get_profile(); // must be called before getting nsIX509CertDB
const { RemoteSecuritySettings } = ChromeUtils.import(
"resource://gre/modules/psm/RemoteSecuritySettings.jsm"
const { RemoteSecuritySettings } = ChromeUtils.importESModule(
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"

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

@ -7,7 +7,9 @@
// Until DER.jsm is actually used in production code, this is where we have to
// import it from.
var { DER } = ChromeUtils.import("resource://gre/modules/psm/DER.jsm");
var { DER } = ChromeUtils.importESModule(
"resource://gre/modules/psm/DER.sys.mjs"
);
function run_simple_tests() {
throws(

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

@ -6,8 +6,8 @@
"use strict";
do_get_profile(); // must be called before getting nsIX509CertDB
const { RemoteSecuritySettings } = ChromeUtils.import(
"resource://gre/modules/psm/RemoteSecuritySettings.jsm"
const { RemoteSecuritySettings } = ChromeUtils.importESModule(
"resource://gre/modules/psm/RemoteSecuritySettings.sys.mjs"
);
const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"