зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1863204 - Correct ESLint scope for some privileged globals and remove importGlobalProperties from more places. r=Gijs,sessionstore-reviewers,dom-storage-reviewers,sclements,asuth
Differential Revision: https://phabricator.services.mozilla.com/D192806
This commit is contained in:
Родитель
179d2c894d
Коммит
5eb2171730
|
@ -12,8 +12,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
JsonSchema: "resource://gre/modules/JsonSchema.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
|
||||
|
||||
function assertValidates(validator, obj, msg) {
|
||||
const result = validator.validate(obj);
|
||||
Assert.ok(
|
||||
|
|
|
@ -22,8 +22,6 @@ const {
|
|||
const MAX_ENTRIES = 9;
|
||||
const URL = "http://example.com/#";
|
||||
|
||||
Cu.importGlobalProperties(["structuredClone"]);
|
||||
|
||||
async function prepareWithLimit(back, fwd) {
|
||||
SessionWriter.init("empty", false, Paths, {
|
||||
maxSerializeBack: back,
|
||||
|
|
|
@ -47,8 +47,7 @@ add_setup(function () {
|
|||
|
||||
enableTesting();
|
||||
|
||||
// Expose Cache and Fetch symbols on the global
|
||||
Cu.importGlobalProperties(["caches", "fetch"]);
|
||||
Cu.importGlobalProperties(["caches"]);
|
||||
|
||||
registerCleanupFunction(resetTesting);
|
||||
});
|
||||
|
|
|
@ -26,8 +26,6 @@ async function chromeScriptFunc() {
|
|||
const blobText = blobData.join("");
|
||||
const blobType = "text/plain";
|
||||
|
||||
Cu.importGlobalProperties(["indexedDB"]);
|
||||
|
||||
function info(msg) {
|
||||
sendAsyncMessage(mmName, { op: "info", msg });
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ function finishTest() {
|
|||
function run_test() {
|
||||
const name = "Splendid Test";
|
||||
|
||||
Cu.importGlobalProperties(["indexedDB"]);
|
||||
|
||||
do_test_pending();
|
||||
|
||||
let keyRange = IDBKeyRange.only(42);
|
||||
|
|
|
@ -77,7 +77,6 @@ function run_test() {
|
|||
sb
|
||||
);
|
||||
|
||||
Cu.importGlobalProperties(["indexedDB"]);
|
||||
do_test_pending();
|
||||
Promise.all([innerPromise, exerciseInterface()]).then(do_test_finished);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,6 @@ if (!this.runTest) {
|
|||
enableExperimental();
|
||||
}
|
||||
|
||||
Cu.importGlobalProperties(["indexedDB"]);
|
||||
|
||||
// In order to support converting tests to using async functions from using
|
||||
// generator functions, we detect async functions by checking the name of
|
||||
// function's constructor.
|
||||
|
|
|
@ -21,8 +21,6 @@ add_setup(function () {
|
|||
|
||||
enableTesting();
|
||||
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
registerCleanupFunction(resetTesting);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// Test PushCrypto.encrypt()
|
||||
"use strict";
|
||||
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
const { PushCrypto } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/PushCrypto.sys.mjs"
|
||||
);
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
var db;
|
||||
|
||||
function done() {
|
||||
|
|
|
@ -12,7 +12,6 @@ AddonTestUtils.createAppInfo(
|
|||
"42"
|
||||
);
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
add_task(async function helper() {
|
||||
do_get_profile();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
const { HttpServer } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/httpd.sys.mjs"
|
||||
);
|
||||
|
|
|
@ -27,7 +27,6 @@ function run_test() {
|
|||
sb
|
||||
);
|
||||
|
||||
Cu.importGlobalProperties(["structuredClone"]);
|
||||
const clone = structuredClone({ b: 2 });
|
||||
Assert.equal(clone.b, 2);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
/* import-globals-from trr_common.js */
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
const { setTimeout } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/Timer.sys.mjs"
|
||||
);
|
||||
|
|
|
@ -7,8 +7,6 @@ ChromeUtils.defineESModuleGetters(this, {
|
|||
jwcrypto: "resource://services-crypto/jwcrypto.sys.mjs",
|
||||
});
|
||||
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
// Enable logging from jwcrypto.jsm.
|
||||
Services.prefs.setCharPref("services.crypto.jwcrypto.log.level", "Debug");
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ const { EventEmitter } = ChromeUtils.importESModule(
|
|||
ChromeUtils.defineESModuleGetters(this, {
|
||||
jwcrypto: "resource://services-crypto/jwcrypto.sys.mjs",
|
||||
});
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["crypto"]);
|
||||
|
||||
const CHANNEL_ID = "sW-UA97Q6Dljqen7XRlYPw";
|
||||
const CHANNEL_KEY = crypto.getRandomValues(new Uint8Array(32));
|
||||
|
|
|
@ -4,8 +4,6 @@ const { Utils } = ChromeUtils.importESModule(
|
|||
"resource://services-settings/Utils.sys.mjs"
|
||||
);
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
async function getLocalDumpLastModified(bucket, collection) {
|
||||
let res;
|
||||
try {
|
||||
|
|
|
@ -17,8 +17,6 @@ const { Database } = ChromeUtils.importESModule(
|
|||
"resource://services-settings/Database.sys.mjs"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["indexedDB"]);
|
||||
|
||||
const IS_ANDROID = AppConstants.platform == "android";
|
||||
|
||||
add_task(async function test_canonicaljson() {
|
||||
|
|
|
@ -7,8 +7,6 @@ const { JsonSchema } = ChromeUtils.importESModule(
|
|||
"resource://gre/modules/JsonSchema.sys.mjs"
|
||||
);
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
ChromeUtils.defineLazyGetter(this, "fetchSchema", () => {
|
||||
return fetch("resource://nimbus/schemas/NimbusEnrollment.schema.json", {
|
||||
credentials: "omit",
|
||||
|
|
|
@ -11,8 +11,6 @@ load("utils.js");
|
|||
NormandyTestUtils.init({ add_task });
|
||||
const { decorate_task } = NormandyTestUtils;
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
decorate_task(withMockApiServer(), async function test_get({ serverUrl }) {
|
||||
// Test that NormandyApi can fetch from the test server.
|
||||
const response = await NormandyApi.get(`${serverUrl}/api/v1/`);
|
||||
|
|
|
@ -21,8 +21,6 @@ ChromeUtils.defineESModuleGetters(this, {
|
|||
updateAppInfo: "resource://testing-common/AppInfo.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
|
||||
|
||||
const GLOBAL_SCOPE = this;
|
||||
const TEST_DEBUG = Services.env.get("TEST_DEBUG");
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Cu.importGlobalProperties(["structuredClone"]);
|
||||
|
||||
const CONFIG = [
|
||||
{
|
||||
// Engine initially default, but the defaults will be changed to engine-pref.
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
const { ExtensionData } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/Extension.sys.mjs"
|
||||
);
|
||||
|
|
|
@ -4,8 +4,6 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
|
|||
"use strict";
|
||||
/* exported createHttpServer, loadJSONfromFile, readFile */
|
||||
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
|
||||
const { AddonTestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/AddonTestUtils.sys.mjs"
|
||||
);
|
||||
|
|
|
@ -804,7 +804,6 @@ add_task(async function test_encryptedPing() {
|
|||
// The underlying jwcrypto module being used here is not currently available on Android.
|
||||
return;
|
||||
}
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
const ECDH_PARAMS = {
|
||||
name: "ECDH",
|
||||
|
@ -1050,7 +1049,6 @@ add_task(async function test_encryptedPing_overrideId() {
|
|||
// The underlying jwcrypto module being used here is not currently available on Android.
|
||||
return;
|
||||
}
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
|
||||
const publicKey = {
|
||||
crv: "P-256",
|
||||
|
|
|
@ -1147,7 +1147,6 @@ function copyBlocklistToProfile(blocklistFile) {
|
|||
}
|
||||
|
||||
async function mockGfxBlocklistItemsFromDisk(path) {
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
let response = await fetch(Services.io.newFileURI(do_get_file(path)).spec);
|
||||
let json = await response.json();
|
||||
return mockGfxBlocklistItems(json);
|
||||
|
|
|
@ -38,7 +38,6 @@ async function load_mlbf_record_as_blob() {
|
|||
const url = Services.io.newFileURI(
|
||||
do_get_file("../data/mlbf-blocked1-unblocked2.bin")
|
||||
).spec;
|
||||
Cu.importGlobalProperties(["fetch"]);
|
||||
return (await fetch(url)).blob();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ const nonBlockedAddon = {
|
|||
};
|
||||
|
||||
async function sha256(arrayBuffer) {
|
||||
Cu.importGlobalProperties(["crypto"]);
|
||||
let hash = await crypto.subtle.digest("SHA-256", arrayBuffer);
|
||||
const toHex = b => b.toString(16).padStart(2, "0");
|
||||
return Array.from(new Uint8Array(hash), toHex).join("");
|
||||
|
|
|
@ -21,11 +21,5 @@ module.exports = {
|
|||
// JS can run. It's definitely available in JSMs. So even if this is not
|
||||
// the perfect place to add it, it's not wrong, and we can move it later.
|
||||
WebAssembly: false,
|
||||
// These are hard-coded and available in .jsm scopes.
|
||||
// See BackstagePass::Resolve.
|
||||
fetch: false,
|
||||
crypto: false,
|
||||
indexedDB: false,
|
||||
structuredClone: false,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -810,5 +810,11 @@ module.exports = {
|
|||
XULScrollElement: false,
|
||||
XULTextElement: false,
|
||||
console: false,
|
||||
// These are hard-coded and available in privileged scopes.
|
||||
// See BackstagePass::Resolve.
|
||||
fetch: false,
|
||||
crypto: false,
|
||||
indexedDB: false,
|
||||
structuredClone: false,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -23,11 +23,11 @@ ruleTester.run("reject-importGlobalProperties", rule, {
|
|||
},
|
||||
{
|
||||
options: ["allownonwebidl"],
|
||||
code: "Cu.importGlobalProperties(['fetch'])",
|
||||
code: "Cu.importGlobalProperties(['caches'])",
|
||||
},
|
||||
{
|
||||
options: ["allownonwebidl"],
|
||||
code: "XPCOMUtils.defineLazyGlobalGetters(this, ['fetch'])",
|
||||
code: "XPCOMUtils.defineLazyGlobalGetters(this, ['caches'])",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
|
|
Загрузка…
Ссылка в новой задаче