forked from mirrors/gecko-dev
Bug 1789981 - [devtools] Convert last DevTools JSM to ESM. r=devtools-reviewers,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D202438
This commit is contained in:
parent
d10de08d0d
commit
40ad6a2dc0
15 changed files with 59 additions and 93 deletions
|
|
@ -4,8 +4,9 @@
|
|||
"use strict";
|
||||
|
||||
const asyncStoreHelper = require("resource://devtools/client/shared/async-store-helper.js");
|
||||
const { validateBreakpointLocation } = ChromeUtils.import(
|
||||
"resource://devtools/shared/validate-breakpoint.jsm"
|
||||
const { validateBreakpointLocation } = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/validate-breakpoint.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
|
||||
const asyncStore = asyncStoreHelper("debugger", {
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ const {
|
|||
blackboxingSpec,
|
||||
} = require("resource://devtools/shared/specs/blackboxing.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
const { SUPPORTED_DATA } = SessionDataHelpers;
|
||||
const { BLACKBOXING } = SUPPORTED_DATA;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ const {
|
|||
breakpointListSpec,
|
||||
} = require("resource://devtools/shared/specs/breakpoint-list.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
const { SUPPORTED_DATA } = SessionDataHelpers;
|
||||
const { BREAKPOINTS, XHR_BREAKPOINTS, EVENT_BREAKPOINTS } = SUPPORTED_DATA;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ const {
|
|||
targetConfigurationSpec,
|
||||
} = require("resource://devtools/shared/specs/target-configuration.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
const { isBrowsingContextPartOfContext } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
const { SUPPORTED_DATA } = SessionDataHelpers;
|
||||
|
||||
const SessionDataProcessors = {};
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ const {
|
|||
threadConfigurationSpec,
|
||||
} = require("resource://devtools/shared/specs/thread-configuration.js");
|
||||
|
||||
const {
|
||||
SessionDataHelpers,
|
||||
} = require("resource://devtools/server/actors/watcher/SessionDataHelpers.jsm");
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
const {
|
||||
SUPPORTED_DATA: { THREAD_CONFIGURATION },
|
||||
} = SessionDataHelpers;
|
||||
|
|
|
|||
|
|
@ -2,49 +2,30 @@
|
|||
* 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";
|
||||
|
||||
/**
|
||||
* Helper module alongside WatcherRegistry, which focus on updating the "sessionData" object.
|
||||
* This object is shared across processes and threads and have to be maintained in all these runtimes.
|
||||
*/
|
||||
|
||||
var EXPORTED_SYMBOLS = ["SessionDataHelpers"];
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(
|
||||
lazy,
|
||||
{
|
||||
validateBreakpointLocation:
|
||||
"resource://devtools/shared/validate-breakpoint.sys.mjs",
|
||||
},
|
||||
{ global: "contextual" }
|
||||
);
|
||||
|
||||
if (typeof module == "object") {
|
||||
// Allow this JSM to also be loaded as a CommonJS module
|
||||
// Because this module is used from the worker thread,
|
||||
// (via target-actor-mixin), and workers can't load JSMs via ChromeUtils.import.
|
||||
loader.lazyRequireGetter(
|
||||
lazy,
|
||||
"validateBreakpointLocation",
|
||||
"resource://devtools/shared/validate-breakpoint.jsm",
|
||||
true
|
||||
ChromeUtils.defineLazyGetter(lazy, "validateEventBreakpoint", () => {
|
||||
const { loader } = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
lazy,
|
||||
"validateEventBreakpoint",
|
||||
"resource://devtools/server/actors/utils/event-breakpoints.js",
|
||||
true
|
||||
);
|
||||
} else {
|
||||
ChromeUtils.defineLazyGetter(lazy, "validateBreakpointLocation", () => {
|
||||
return ChromeUtils.import(
|
||||
"resource://devtools/shared/validate-breakpoint.jsm"
|
||||
).validateBreakpointLocation;
|
||||
});
|
||||
ChromeUtils.defineLazyGetter(lazy, "validateEventBreakpoint", () => {
|
||||
const { loader } = ChromeUtils.importESModule(
|
||||
"resource://devtools/shared/loader/Loader.sys.mjs"
|
||||
);
|
||||
return loader.require(
|
||||
"resource://devtools/server/actors/utils/event-breakpoints.js"
|
||||
).validateEventBreakpoint;
|
||||
});
|
||||
}
|
||||
return loader.require(
|
||||
"resource://devtools/server/actors/utils/event-breakpoints.js"
|
||||
).validateEventBreakpoint;
|
||||
});
|
||||
|
||||
// List of all arrays stored in `sessionData`, which are replicated across processes and threads
|
||||
const SUPPORTED_DATA = {
|
||||
|
|
@ -151,7 +132,7 @@ function idFunction(v) {
|
|||
return v;
|
||||
}
|
||||
|
||||
const SessionDataHelpers = {
|
||||
export const SessionDataHelpers = {
|
||||
SUPPORTED_DATA,
|
||||
|
||||
/**
|
||||
|
|
@ -235,10 +216,3 @@ const SessionDataHelpers = {
|
|||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
// Allow this JSM to also be loaded as a CommonJS module
|
||||
// Because this module is used from the worker thread,
|
||||
// (via target-actor-mixin), and workers can't load JSMs.
|
||||
if (typeof module == "object") {
|
||||
module.exports.SessionDataHelpers = SessionDataHelpers;
|
||||
}
|
||||
|
|
@ -26,8 +26,9 @@
|
|||
|
||||
import { ActorManagerParent } from "resource://gre/modules/ActorManagerParent.sys.mjs";
|
||||
|
||||
const { SessionDataHelpers } = ChromeUtils.import(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.jsm"
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
|
||||
const { SUPPORTED_DATA } = SessionDataHelpers;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ DIRS += [
|
|||
DevToolsModules(
|
||||
"browsing-context-helpers.sys.mjs",
|
||||
"session-context.js",
|
||||
"SessionDataHelpers.jsm",
|
||||
"SessionDataHelpers.sys.mjs",
|
||||
"WatcherRegistry.sys.mjs",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,13 +22,11 @@ ChromeUtils.defineLazyGetter(lazy, "Loader", () =>
|
|||
ChromeUtils.defineLazyGetter(lazy, "DevToolsUtils", () =>
|
||||
lazy.Loader.require("resource://devtools/shared/DevToolsUtils.js")
|
||||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
SessionDataHelpers:
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.jsm",
|
||||
});
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
isWindowGlobalPartOfContext:
|
||||
"resource://devtools/server/actors/watcher/browsing-context-helpers.sys.mjs",
|
||||
SessionDataHelpers:
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
});
|
||||
|
||||
// Name of the attribute into which we save data in `sharedData` object.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
|||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
loader: "resource://devtools/shared/loader/Loader.sys.mjs",
|
||||
SessionDataHelpers:
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(
|
||||
|
|
@ -17,11 +19,6 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||
"nsIWorkerDebuggerManager"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
SessionDataHelpers:
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.jsm",
|
||||
});
|
||||
|
||||
ChromeUtils.defineLazyGetter(lazy, "DevToolsUtils", () =>
|
||||
lazy.loader.require("devtools/shared/DevToolsUtils")
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { SessionDataHelpers } = ChromeUtils.import(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.jsm"
|
||||
const { SessionDataHelpers } = ChromeUtils.importESModule(
|
||||
"resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs",
|
||||
{ global: "contextual" }
|
||||
);
|
||||
const { SUPPORTED_DATA } = SessionDataHelpers;
|
||||
const { TARGETS } = SUPPORTED_DATA;
|
||||
|
|
|
|||
|
|
@ -173,9 +173,7 @@ function WorkerDebuggerLoader(options) {
|
|||
}
|
||||
|
||||
// If the url has no extension, use ".js" by default.
|
||||
// Also allow loading JSMs, but they would need a shim in order to
|
||||
// be loaded as a CommonJS module. (See SessionDataHelpers.jsm)
|
||||
return url.endsWith(".js") || url.endsWith(".jsm") ? url : url + ".js";
|
||||
return url.endsWith(".js") ? url : url + ".js";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ DevToolsModules(
|
|||
"system.js",
|
||||
"ThreadSafeDevToolsUtils.js",
|
||||
"throttle.js",
|
||||
"validate-breakpoint.jsm",
|
||||
"validate-breakpoint.sys.mjs",
|
||||
)
|
||||
|
||||
with Files("**"):
|
||||
|
|
|
|||
|
|
@ -2,17 +2,15 @@
|
|||
* 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";
|
||||
|
||||
// Because this function is used from SessionDataHelpers.jsm,
|
||||
// this has to be a JSM.
|
||||
|
||||
var EXPORTED_SYMBOLS = ["validateBreakpointLocation"];
|
||||
|
||||
/**
|
||||
* Given a breakpoint location object, throws if the breakpoint look invalid
|
||||
*/
|
||||
function validateBreakpointLocation({ sourceUrl, sourceId, line, column }) {
|
||||
export function validateBreakpointLocation({
|
||||
sourceUrl,
|
||||
sourceId,
|
||||
line,
|
||||
column,
|
||||
}) {
|
||||
if (!sourceUrl && !sourceId) {
|
||||
throw new Error(
|
||||
`Breakpoints expect to have either a sourceUrl or a sourceId.`
|
||||
|
|
@ -40,10 +38,3 @@ function validateBreakpointLocation({ sourceUrl, sourceId, line, column }) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Allow this JSM to also be loaded as a CommonJS module
|
||||
// Because this module is used from the worker thread,
|
||||
// and workers can't load JSMs.
|
||||
if (typeof module == "object") {
|
||||
module.exports.validateBreakpointLocation = validateBreakpointLocation;
|
||||
}
|
||||
Loading…
Reference in a new issue