Bug 1791969 - [devtools] Migrate lazyRequireGetter for JSM to ChromeUtils.defineModuleGetter. r=jdescottes

There was some imports of sys.mjs which I migrated to `ChromeUtils.defineESModuleGetters`.

Differential Revision: https://phabricator.services.mozilla.com/D158129
This commit is contained in:
Alexandre Poirot 2022-09-28 16:20:08 +00:00
Родитель d5c7f69016
Коммит 75672c3505
35 изменённых файлов: 187 добавлений и 213 удалений

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

@ -11,11 +11,10 @@ ChromeUtils.defineModuleGetter(
"AddonManager",
"resource://gre/modules/AddonManager.jsm"
);
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
const { PREFERENCES } = require("devtools/client/aboutdebugging/src/constants");
@ -74,7 +73,7 @@ exports.openTemporaryExtension = function(win, message) {
PREFERENCES.TEMPORARY_EXTENSION_PATH,
""
);
const lastDir = new FileUtils.File(lastDirPath);
const lastDir = new lazy.FileUtils.File(lastDirPath);
fp.displayDirectory = lastDir;
} catch (e) {
// Empty or invalid value, nothing to handle.

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

@ -75,11 +75,11 @@ loader.lazyRequireGetter(
"devtools/client/responsive/manager"
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
loader.lazyRequireGetter(
this,
@ -472,7 +472,7 @@ exports.ToolboxButtons = [
{
id: "command-button-experimental-prefs",
description: "DevTools Experimental preferences",
isToolSupported: () => !AppConstants.MOZILLA_OFFICIAL,
isToolSupported: () => !lazy.AppConstants.MOZILLA_OFFICIAL,
onClick: (event, toolbox) => DevToolsExperimentalPrefs.showTooltip(toolbox),
isChecked: () => DevToolsExperimentalPrefs.isAnyPreferenceEnabled(),
},

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

@ -13,11 +13,11 @@ loader.lazyRequireGetter(
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm",
true
"resource://gre/modules/PrivateBrowsingUtils.jsm"
);
/* A host should always allow this much space for the page to be displayed.
@ -256,7 +256,7 @@ WindowHost.prototype = {
// the owner window was passed in the host options.
const owner =
this.hostTab?.ownerGlobal || this.options?.browserContentToolboxOpener;
if (owner && PrivateBrowsingUtils.isWindowPrivate(owner)) {
if (owner && lazy.PrivateBrowsingUtils.isWindowPrivate(owner)) {
flags += ",private";
}

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

@ -79,11 +79,11 @@ loader.lazyRequireGetter(
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
loader.lazyRequireGetter(this, "flags", "devtools/shared/flags");
loader.lazyRequireGetter(
@ -1269,7 +1269,7 @@ Toolbox.prototype = {
L10N.getStr("toolbox.toggleToolboxF12.key"),
this.closeToolbox
);
if (AppConstants.platform == "macosx") {
if (lazy.AppConstants.platform == "macosx") {
shortcuts.on(
L10N.getStr("toolbox.toggleToolboxOSX.key"),
this.closeToolbox

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

@ -10,11 +10,11 @@ const {
registerFront,
} = require("devtools/shared/protocol");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
loader.lazyRequireGetter(
this,
@ -86,8 +86,8 @@ class MemoryFront extends FrontClassWithSpec(memorySpec) {
});
const outFilePath = HeapSnapshotFileUtils.getNewUniqueHeapSnapshotTempFilePath();
const outFile = new FileUtils.File(outFilePath);
const outFileStream = FileUtils.openSafeFileOutputStream(outFile);
const outFile = new lazy.FileUtils.File(outFilePath);
const outFileStream = lazy.FileUtils.openSafeFileOutputStream(outFile);
// This request is a bulk request. That's why the result of the request is
// an object with the `copyTo` function that can transfer the data to
@ -96,7 +96,7 @@ class MemoryFront extends FrontClassWithSpec(memorySpec) {
const { copyTo } = await request;
await copyTo(outFileStream);
FileUtils.closeSafeFileOutputStream(outFileStream);
lazy.FileUtils.closeSafeFileOutputStream(outFileStream);
return outFilePath;
} catch (e) {
if (e.error) {

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

@ -3,12 +3,6 @@
"use strict";
ChromeUtils.defineModuleGetter(
this,
"ContentTaskUtils",
"resource://testing-common/ContentTaskUtils.jsm"
);
const SIDEBAR_ID = "an-extension-sidebar";
const SIDEBAR_TITLE = "Sidebar Title";

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

@ -9,9 +9,7 @@
"use strict";
ChromeUtils.defineModuleGetter(
this,
"ContentTaskUtils",
const { ContentTaskUtils } = ChromeUtils.import(
"resource://testing-common/ContentTaskUtils.jsm"
);

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

@ -8,11 +8,6 @@
// Have to use the same timer functions used by the inspector.
const { clearTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
ChromeUtils.defineModuleGetter(
this,
"Preferences",
"resource://gre/modules/Preferences.jsm"
);
const TEST_URL = URL_ROOT + "doc_markup_flashing.html";
@ -118,12 +113,7 @@ const TEST_DATA = [
];
add_task(async function() {
const timerPrecision = Preferences.get("privacy.reduceTimerPrecision");
Preferences.set("privacy.reduceTimerPrecision", false);
registerCleanupFunction(function() {
Preferences.set("privacy.reduceTimerPrecision", timerPrecision);
});
await pushPref("privacy.reduceTimerPrecision", false);
const { inspector } = await openInspectorForURL(TEST_URL);

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

@ -9,11 +9,11 @@
// Bug 1275446 - This test happen to hit the default timeout on linux32
requestLongerTimeout(2);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
const TEST_URI = `
@ -784,7 +784,7 @@ async function testIncrement(editor, options, view) {
}
let smallIncrementKey = { ctrlKey: options.ctrl };
if (AppConstants.platform === "macosx") {
if (lazy.AppConstants.platform === "macosx") {
smallIncrementKey = { altKey: options.alt };
}
@ -806,7 +806,7 @@ async function testIncrement(editor, options, view) {
}
function getSmallIncrementKey() {
if (AppConstants.platform === "macosx") {
if (lazy.AppConstants.platform === "macosx") {
return { alt: true };
}
return { ctrl: true };

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

@ -38,11 +38,11 @@ loader.lazyRequireGetter(
"devtools/shared/inspector/css-logic",
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
const HTML_NS = "http://www.w3.org/1999/xhtml";
@ -1341,7 +1341,8 @@ TextPropertyEditor.prototype = {
* @returns {Boolean}
*/
_hasSmallIncrementModifier(event) {
const modifier = AppConstants.platform === "macosx" ? "altKey" : "ctrlKey";
const modifier =
lazy.AppConstants.platform === "macosx" ? "altKey" : "ctrlKey";
return event[modifier] === true;
},

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

@ -28,11 +28,11 @@ const {
findMostRelevantCssPropertyIndex,
} = require("devtools/client/shared/suggestion-picker");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
const HTML_NS = "http://www.w3.org/1999/xhtml";
@ -1368,7 +1368,7 @@ InplaceEditor.prototype = {
*/
_getIncrement(event) {
const getSmallIncrementKey = evt => {
if (AppConstants.platform === "macosx") {
if (lazy.AppConstants.platform === "macosx") {
return evt.altKey;
}
return evt.ctrlKey;

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

@ -13,17 +13,15 @@ ChromeUtils.defineModuleGetter(
"ExtensionParent",
"resource://gre/modules/ExtensionParent.jsm"
);
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm",
true
"resource://gre/modules/NetUtil.jsm"
);
loader.lazyGetter(this, "UNPACKED_ROOT_PATH", () => {
return PathUtils.join(PathUtils.localProfileDir, "adb");
@ -47,14 +45,14 @@ const MANIFEST = "manifest.json";
*/
async function readFromExtension(fileUri) {
return new Promise(resolve => {
NetUtil.asyncFetch(
lazy.NetUtil.asyncFetch(
{
uri: fileUri,
loadUsingSystemPrincipal: true,
},
input => {
try {
const string = NetUtil.readInputStreamToString(
const string = lazy.NetUtil.readInputStreamToString(
input,
input.available()
);
@ -85,7 +83,7 @@ async function unpackFile(file) {
const basePath = file.substring(file.lastIndexOf("/") + 1);
const filePath = PathUtils.join(UNPACKED_ROOT_PATH, basePath);
await new Promise((resolve, reject) => {
NetUtil.asyncFetch(
lazy.NetUtil.asyncFetch(
{
uri: policy.getURL(file),
loadUsingSystemPrincipal: true,
@ -94,9 +92,9 @@ async function unpackFile(file) {
try {
// Since we have to use NetUtil to read, probably it's okay to use for
// writing, rather than bouncing to IOUtils...?
const outputFile = new FileUtils.File(filePath);
const output = FileUtils.openAtomicFileOutputStream(outputFile);
NetUtil.asyncCopy(input, output, resolve);
const outputFile = new lazy.FileUtils.File(filePath);
const output = lazy.FileUtils.openAtomicFileOutputStream(outputFile);
lazy.NetUtil.asyncCopy(input, output, resolve);
} catch (e) {
dumpn(`Could not unpack file ${file} in the extension: ${e}`);
reject(e);
@ -242,7 +240,7 @@ async function getFileForBinary() {
return null;
}
const file = new FileUtils.File(ADB_BINARY_PATH);
const file = new lazy.FileUtils.File(ADB_BINARY_PATH);
if (!file.exists()) {
return null;
}

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

@ -39,17 +39,15 @@ loader.lazyRequireGetter(
true
);
loader.lazyRequireGetter(
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
loader.lazyRequireGetter(
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm",
true
"resource://gre/modules/NetUtil.jsm"
);
loader.lazyRequireGetter(
lazy,

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

@ -23,17 +23,15 @@ loader.lazyGetter(lazy, "BufferStream", () => {
);
});
loader.lazyRequireGetter(
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
loader.lazyRequireGetter(
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm",
true
"resource://gre/modules/NetUtil.jsm"
);
const { getString, showFilePicker } = ChromeUtils.import(

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

@ -19,11 +19,11 @@ const { PREFS } = require("devtools/client/webconsole/constants");
const FirefoxDataProvider = require("devtools/client/netmonitor/src/connector/firefox-data-provider");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
loader.lazyRequireGetter(
this,
@ -670,7 +670,7 @@ class WebConsoleUI {
});
let clearShortcut;
if (AppConstants.platform === "macosx") {
if (lazy.AppConstants.platform === "macosx") {
const alternativaClearShortcut = l10n.getStr(
"webconsole.clear.alternativeKeyOSX"
);

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

@ -53,11 +53,11 @@ loader.lazyRequireGetter(
"devtools/shared/layout/utils",
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"ContentDOMReference",
"resource://gre/modules/ContentDOMReference.jsm",
true
"resource://gre/modules/ContentDOMReference.jsm"
);
const RELATIONS_TO_IGNORE = new Set([
@ -171,7 +171,7 @@ function getSnapshot(acc, a11yService, targetActor) {
if (useChildTargetToFetchChildren) {
snapshot.useChildTargetToFetchChildren = useChildTargetToFetchChildren;
snapshot.childCount = 1;
snapshot.contentDOMReference = ContentDOMReference.get(acc.DOMNode);
snapshot.contentDOMReference = lazy.ContentDOMReference.get(acc.DOMNode);
}
return snapshot;

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

@ -4,11 +4,11 @@
"use strict";
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"ContentDOMReference",
"resource://gre/modules/ContentDOMReference.jsm",
true
"resource://gre/modules/ContentDOMReference.jsm"
);
loader.lazyRequireGetter(
this,
@ -140,7 +140,7 @@ class TabbingOrderHighlighter {
this._trackMutations();
return {
contentDOMReference: endElm && ContentDOMReference.get(endElm),
contentDOMReference: endElm && lazy.ContentDOMReference.get(endElm),
index,
};
}

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

@ -99,12 +99,12 @@ loader.lazyRequireGetter(
);
// ContentDOMReference requires ChromeUtils, which isn't available in worker context.
const lazy = {};
if (!isWorker) {
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"ContentDOMReference",
"resource://gre/modules/ContentDOMReference.jsm",
true
"resource://gre/modules/ContentDOMReference.jsm"
);
}
@ -2646,7 +2646,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
* Given a contentDomReference return the NodeActor for the corresponding frameElement.
*/
getNodeActorFromContentDomReference(contentDomReference) {
let rawNode = ContentDOMReference.resolve(contentDomReference);
let rawNode = lazy.ContentDOMReference.resolve(contentDomReference);
if (!rawNode || !this._isInDOMTree(rawNode)) {
return null;
}

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

@ -7,11 +7,11 @@
const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
const { networkContentSpec } = require("devtools/shared/specs/network-content");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm",
true
"resource://gre/modules/NetUtil.jsm"
);
loader.lazyRequireGetter(
@ -68,8 +68,8 @@ const NetworkContentActor = ActorClassWithSpec(networkContentSpec, {
// request won't show up in the opened netmonitor.
const doc = this.targetActor.window.document;
const channel = NetUtil.newChannel({
uri: NetUtil.newURI(url),
const channel = lazy.NetUtil.newChannel({
uri: lazy.NetUtil.newURI(url),
loadingNode: doc,
securityFlags:
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
@ -121,7 +121,7 @@ const NetworkContentActor = ActorClassWithSpec(networkContentSpec, {
// Make sure the fetch has completed before sending the channel id,
// so that there is a higher possibilty that the request get into the
// redux store beforehand (but this does not gurantee that).
NetUtil.asyncFetch(channel, () =>
lazy.NetUtil.asyncFetch(channel, () =>
resolve({ channelId: channel.channelId })
);
});

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

@ -42,12 +42,12 @@ loader.lazyRequireGetter(
);
// ContentDOMReference requires ChromeUtils, which isn't available in worker context.
const lazy = {};
if (!isWorker) {
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"ContentDOMReference",
"resource://gre/modules/ContentDOMReference.jsm",
true
"resource://gre/modules/ContentDOMReference.jsm"
);
}
@ -190,14 +190,14 @@ const proto = {
this._populateGripPreview(g, raw);
this.hooks.decrementGripDepth();
if (raw && Node.isInstance(raw) && ContentDOMReference) {
if (raw && Node.isInstance(raw) && lazy.ContentDOMReference) {
// ContentDOMReference.get takes a DOM element and returns an object with
// its browsing context id, as well as a unique identifier. We are putting it in
// the grip here in order to be able to retrieve the node later, potentially from a
// different DevToolsServer running in the same process.
// If ContentDOMReference.get throws, we simply don't add the property to the grip.
try {
g.contentDomReference = ContentDOMReference.get(raw);
g.contentDomReference = lazy.ContentDOMReference.get(raw);
} catch (e) {}
}

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

@ -7,12 +7,11 @@
const { storageTypePool } = require("devtools/server/actors/storage");
const EventEmitter = require("devtools/shared/event-emitter");
loader.lazyRequireGetter(
this,
"getAddonIdForWindowGlobal",
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
true
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
getAddonIdForWindowGlobal:
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
});
// ms of delay to throttle updates
const BATCH_DELAY = 200;
@ -223,7 +222,7 @@ class StorageActorMock extends EventEmitter {
}
isIncludedInTargetExtension(subject) {
const addonId = getAddonIdForWindowGlobal(subject.windowGlobalChild);
const addonId = lazy.getAddonIdForWindowGlobal(subject.windowGlobalChild);
return addonId && addonId === this.targetActor.addonId;
}

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

@ -18,12 +18,11 @@ loader.lazyGetter(this, "ExtensionStorageIDB", () => {
return ChromeUtils.import("resource://gre/modules/ExtensionStorageIDB.jsm")
.ExtensionStorageIDB;
});
loader.lazyRequireGetter(
this,
"getAddonIdForWindowGlobal",
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
true
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
getAddonIdForWindowGlobal:
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
});
const EXTENSION_STORAGE_ENABLED_PREF =
"devtools.storage.extensionStorage.enabled";
@ -53,8 +52,6 @@ const SAFE_HOSTS_PREFIXES_REGEX = /^(about\+|https?\+|file\+|moz-extension\+)/;
// devtools/server/tests/browser/head.js
const SEPARATOR_GUID = "{9d414cc5-8319-0a04-0586-c0a6ae01670a}";
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"Sqlite",
@ -3632,7 +3629,7 @@ const StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
},
isIncludedInTargetExtension(subject) {
const addonId = getAddonIdForWindowGlobal(subject.windowGlobalChild);
const addonId = lazy.getAddonIdForWindowGlobal(subject.windowGlobalChild);
return addonId && addonId === this.parentActor.addonId;
},

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

@ -36,12 +36,11 @@ loader.lazyRequireGetter(
true
);
loader.lazyRequireGetter(
this,
"getAddonIdForWindowGlobal",
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
true
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
getAddonIdForWindowGlobal:
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
});
const FALLBACK_DOC_URL =
"chrome://devtools/content/shared/webextension-fallback.html";
@ -309,7 +308,7 @@ webExtensionTargetPrototype.isExtensionWindowDescendent = function(window) {
// Check if the source is coming from a descendant docShell of an extension window.
// We may have an iframe that loads http content which won't use the add-on principal.
const rootWin = window.docShell.sameTypeRootTreeItem.domWindow;
const addonId = getAddonIdForWindowGlobal(rootWin.windowGlobalChild);
const addonId = lazy.getAddonIdForWindowGlobal(rootWin.windowGlobalChild);
return addonId == this.addonId;
};

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

@ -52,11 +52,11 @@ loader.lazyRequireGetter(
"devtools/shared/webconsole/js-property-provider",
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm",
true
"resource://gre/modules/NetUtil.jsm"
);
loader.lazyRequireGetter(
this,
@ -1829,8 +1829,8 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
// request won't show up in the opened netmonitor.
const doc = this.global.document;
const channel = NetUtil.newChannel({
uri: NetUtil.newURI(url),
const channel = lazy.NetUtil.newChannel({
uri: lazy.NetUtil.newURI(url),
loadingNode: doc,
securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
contentPolicyType:
@ -1873,7 +1873,7 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
channel.explicitSetUploadStream(bodyStream, null, -1, method, false);
}
NetUtil.asyncFetch(channel, () => {});
lazy.NetUtil.asyncFetch(channel, () => {});
if (!this.netmonitors) {
return null;

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

@ -10,8 +10,9 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {};
ChromeUtils.defineModuleGetter(
this,
lazy,
"E10SUtils",
"resource://gre/modules/E10SUtils.jsm"
);
@ -96,7 +97,9 @@ ContentProcessForward.prototype = {
(typeof arg == "object" || typeof arg == "function") &&
arg !== null
) {
if (Services.appinfo.remoteType === E10SUtils.EXTENSION_REMOTE_TYPE) {
if (
Services.appinfo.remoteType === lazy.E10SUtils.EXTENSION_REMOTE_TYPE
) {
// For OOP extensions: we want the developer to be able to see the
// logs in the Browser Console. When the Addon Toolbox will be more
// prominent we can revisit.

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

@ -7,11 +7,11 @@
const Debugger = require("Debugger");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"Reflect",
"resource://gre/modules/reflect.jsm",
true
"resource://gre/modules/reflect.jsm"
);
loader.lazyRequireGetter(
this,
@ -268,7 +268,7 @@ function parseErrorOutput(dbgGlobal, string) {
// since it's already being handled elsewhere and we are only interested
// in initializing bindings.
try {
ast = Reflect.parse(string);
ast = lazy.Reflect.parse(string);
} catch (ex) {
return;
}

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

@ -8,11 +8,11 @@ const { reportException } = require("devtools/shared/DevToolsUtils");
const { expectState } = require("devtools/server/actors/common");
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"DeferredTask",
"resource://gre/modules/DeferredTask.jsm",
true
"resource://gre/modules/DeferredTask.jsm"
);
loader.lazyRequireGetter(
this,
@ -229,7 +229,7 @@ Memory.prototype = {
if (this._poller) {
this._poller.disarm();
}
this._poller = new DeferredTask(
this._poller = new lazy.DeferredTask(
this._emitAllocations,
this.drainAllocationsTimeoutTimer,
0

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

@ -7,8 +7,9 @@ const { ExtensionTestUtils } = ChromeUtils.import(
"resource://testing-common/ExtensionXPCShellUtils.jsm"
);
const lazy = {};
ChromeUtils.defineModuleGetter(
this,
lazy,
"ExtensionParent",
"resource://gre/modules/ExtensionParent.jsm"
);
@ -97,7 +98,7 @@ add_task(
equal(threadFront.paused, false, "The addon threadActor isn't paused");
equal(
ExtensionParent.DebugUtils.debugBrowserPromises.size,
lazy.ExtensionParent.DebugUtils.debugBrowserPromises.size,
1,
"The expected number of debug browser has been created by the addon actor"
);
@ -116,7 +117,7 @@ add_task(
await promiseBgPageFrameUpdate;
equal(
ExtensionParent.DebugUtils.debugBrowserPromises.size,
lazy.ExtensionParent.DebugUtils.debugBrowserPromises.size,
1,
"The number of debug browser has not been changed after an addon reload"
);
@ -149,7 +150,7 @@ add_task(
// Check that if we close the debugging client without uninstalling the addon,
// the webextension debugging actor should release the debug browser.
equal(
ExtensionParent.DebugUtils.debugBrowserPromises.size,
lazy.ExtensionParent.DebugUtils.debugBrowserPromises.size,
0,
"The debug browser has been released when the RDP connection has been closed"
);

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

@ -14,20 +14,19 @@ var {
callFunctionWithAsyncStack,
} = require("devtools/shared/platform/stack");
loader.lazyRequireGetter(this, "OS", "resource://gre/modules/osfile.jsm", true);
const lazy = {};
ChromeUtils.defineModuleGetter(lazy, "OS", "resource://gre/modules/osfile.jsm");
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
loader.lazyRequireGetter(
this,
ChromeUtils.defineModuleGetter(
lazy,
"ObjectUtils",
"resource://gre/modules/ObjectUtils.jsm",
true
"resource://gre/modules/ObjectUtils.jsm"
);
// Using this name lets the eslint plugin know about lazy defines in
@ -652,7 +651,7 @@ function mainThreadFetch(
uri.QueryInterface(Ci.nsIFileURL);
// Bug 1779574: IOUtils is not available in non-parent processes.
// eslint-disable-next-line mozilla/reject-osfile
const result = OS.File.read(uri.file.path).then(bytes => {
const result = lazy.OS.File.read(uri.file.path).then(bytes => {
// Convert the bytearray to a String.
const decoder = new TextDecoder();
const content = decoder.decode(bytes);
@ -778,7 +777,7 @@ if (this.isWorker) {
*/
exports.openFileStream = function(filePath) {
return new Promise((resolve, reject) => {
const uri = NetUtil.newURI(new FileUtils.File(filePath));
const uri = NetUtil.newURI(new lazy.FileUtils.File(filePath));
NetUtil.asyncFetch(
{ uri, loadUsingSystemPrincipal: true },
(stream, result) => {
@ -976,7 +975,7 @@ exports.getTopWindow = getTopWindow;
* @return {Boolean}
*/
exports.deepEqual = (a, b) => {
return ObjectUtils.deepEqual(a, b);
return lazy.ObjectUtils.deepEqual(a, b);
};
function isWorkerDebuggerAlive(dbg) {

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

@ -22,11 +22,11 @@
"use strict";
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"FileUtils",
"resource://gre/modules/FileUtils.jsm",
true
"resource://gre/modules/FileUtils.jsm"
);
function getHeapSnapshotFileTemplate() {
@ -40,7 +40,7 @@ function getHeapSnapshotFileTemplate() {
* @returns String
*/
exports.getNewUniqueHeapSnapshotTempFilePath = function() {
const file = new FileUtils.File(getHeapSnapshotFileTemplate());
const file = new lazy.FileUtils.File(getHeapSnapshotFileTemplate());
// The call to createUnique will append "-N" after the leaf name (but before
// the extension) until a new file is found and create it. This guarantees we
// won't accidentally choose the same file twice.

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

@ -10,11 +10,11 @@ loader.lazyRequireGetter(
"DevToolsUtils",
"devtools/shared/DevToolsUtils"
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"NetUtil",
"resource://gre/modules/NetUtil.jsm",
true
"resource://gre/modules/NetUtil.jsm"
);
const SHEET_TYPE = {
@ -916,7 +916,7 @@ function isFrameBlockedByCSP(node) {
let uri;
try {
uri = NetUtil.newURI(node.src);
uri = lazy.NetUtil.newURI(node.src);
} catch (e) {
return false;
}

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

@ -42,11 +42,11 @@ loader.lazyRequireGetter(
"devtools/shared/security/auth",
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"DevToolsSocketStatus",
"resource://devtools/shared/security/DevToolsSocketStatus.jsm",
true
"resource://devtools/shared/security/DevToolsSocketStatus.jsm"
);
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
@ -411,7 +411,7 @@ SocketListener.prototype = {
dumpn("Socket listening on: " + (self.port || self.portOrPath));
})()
.then(() => {
DevToolsSocketStatus.notifySocketOpened({
lazy.DevToolsSocketStatus.notifySocketOpened({
fromBrowserToolbox: self.fromBrowserToolbox,
});
this._advertise();
@ -459,7 +459,7 @@ SocketListener.prototype = {
this._socket.close();
this._socket = null;
DevToolsSocketStatus.notifySocketClosed({
lazy.DevToolsSocketStatus.notifySocketClosed({
fromBrowserToolbox: this.fromBrowserToolbox,
});
}

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

@ -9,11 +9,11 @@ loader.lazyRequireGetter(
"devtools/server/devtools-server",
true
);
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"AppConstants",
"resource://gre/modules/AppConstants.jsm",
true
"resource://gre/modules/AppConstants.jsm"
);
loader.lazyGetter(this, "hostname", () => {
try {
@ -154,7 +154,7 @@ function getSystemInfo() {
profile: getProfileLocation(),
// Update channel
channel: AppConstants.MOZ_UPDATE_CHANNEL,
channel: lazy.AppConstants.MOZ_UPDATE_CHANNEL,
dpi,
useragent,

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

@ -18,11 +18,11 @@ if (!isWorker) {
true
);
}
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"Reflect",
"resource://gre/modules/reflect.jsm",
true
"resource://gre/modules/reflect.jsm"
);
loader.lazyRequireGetter(
this,
@ -561,7 +561,7 @@ function prepareReturnedObject({
// In order to know if the property is suited for dot notation, we use Reflect
// to parse an expression where we try to access the property with a dot. If it
// throws, this means that we need to do an element access instead.
Reflect.parse(`({${match}: true})`);
lazy.Reflect.parse(`({${match}: true})`);
} catch (e) {
matches.delete(match);
}

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

@ -4,11 +4,11 @@
"use strict";
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
loader.lazyRequireGetter(
this,
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"Reflect",
"resource://gre/modules/reflect.jsm",
true
"resource://gre/modules/reflect.jsm"
);
/**
@ -42,7 +42,7 @@ function getSyntaxTrees(source, logExceptions) {
if (!scriptMatches.length) {
// Reflect.parse throws when encounters a syntax error.
try {
syntaxTrees.push(Reflect.parse(source));
syntaxTrees.push(lazy.Reflect.parse(source));
} catch (e) {
if (logExceptions) {
DevToolsUtils.reportException("Parser:get", e);
@ -53,7 +53,7 @@ function getSyntaxTrees(source, logExceptions) {
for (const script of scriptMatches) {
// Reflect.parse throws when encounters a syntax error.
try {
syntaxTrees.push(Reflect.parse(script));
syntaxTrees.push(lazy.Reflect.parse(script));
} catch (e) {
if (logExceptions) {
DevToolsUtils.reportException("Parser:get", e);