Bug 1765167 - Part 4: Stop using Cu.import in dom/. r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D144097
This commit is contained in:
Tooru Fujisawa 2022-05-03 06:32:30 +00:00
Родитель 2ee2b23f67
Коммит f41fbce75e
14 изменённых файлов: 22 добавлений и 16 удалений

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

@ -1,4 +1,3 @@
// Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
var prefetch = Cc["@mozilla.org/prefetch-service;1"].getService(
Ci.nsIPrefetchService
);

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

@ -2261,7 +2261,9 @@ Here's an example JS implementation of the above interface. The
usable by the doNothing() method.
``` js
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
function MyNumberInner() {
this.value = 111;

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

@ -215,7 +215,9 @@
messageManager.loadFrameScript("data:,addEventListener('MozAfterPaint', function(e) { sendAsyncMessage('MozAfterPaint'); },true);", false);
}
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
</script>
<toolbar id="controls">

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

@ -3,8 +3,10 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
const { AppConstants } = Cu.import("resource://gre/modules/AppConstants.jsm");
const { TelemetryTestUtils } = Cu.import(
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);

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

@ -1367,7 +1367,7 @@ bool nsContentSecurityUtils::ValidateScriptFilename(JSContext* cx,
auto kAllowedFilenamesExact = {
// Allow through the injection provided by about:sync addon
u"data:,new function() {\n Components.utils.import(\"chrome://aboutsync/content/AboutSyncRedirector.js\");\n AboutSyncRedirector.register();\n}"_ns,
u"data:,new function() {\n const { AboutSyncRedirector } = ChromeUtils.import(\"chrome://aboutsync/content/AboutSyncRedirector.js\");\n AboutSyncRedirector.register();\n}"_ns,
};
for (auto allowedFilename : kAllowedFilenamesExact) {

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

@ -1,4 +1,4 @@
Cu.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function handleRequest(request, response) {
var query = {};

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

@ -4,7 +4,7 @@ const BinaryInputStream = CC(
"nsIBinaryInputStream",
"setInputStream"
);
Cu.import("resource://gre/modules/Services.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
function handleRequest(request, response) {

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

@ -1,6 +1,6 @@
// SJS file for CSP mochitests
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
function loadHTMLFromFile(path) {
// Load the HTML to return in the response from file.

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

@ -1,6 +1,6 @@
// Server side js file for bug 910139, see file test_bug910139.html for details.
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
function loadResponseFromFile(path) {
var testHTMLFile = Components.classes["@mozilla.org/file/directory_service;1"]

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

@ -2,7 +2,7 @@
// * Bug 1004703 - ignore 'unsafe-inline' if nonce- or hash-source specified
// * Bug 1198422: should not block inline script if default-src is not specified
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
function loadHTMLFromFile(path) {
// Load the HTML to return in the response from file.

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

@ -1,6 +1,6 @@
// SJS file for CSP mochitests
"use strict";
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.importGlobalProperties(["URLSearchParams"]);
function loadHTMLFromFile(path) {

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

@ -1,7 +1,7 @@
// Custom *.sjs specifically for the needs of Bug
// Bug 1139297 - Implement CSP upgrade-insecure-requests directive
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
// small red image
const IMG_BYTES = atob(

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

@ -1,4 +1,4 @@
Components.utils.import("resource://gre/modules/NetUtil.jsm");
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
function ERR(response, msg) {
dump("ERROR: " + msg + "\n");

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

@ -1,8 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://gre/modules/Timer.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
const { setInterval, clearInterval } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm"
);
// stolen from file_blocked_script.sjs
function setGlobalState(data, key) {