Bug 1878457 - Part 2: ESMify consumers of performance-new modules. r=julienw,profiler-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D200559
This commit is contained in:
Tooru Fujisawa 2024-02-05 23:23:32 +00:00
parent ac9978df07
commit 402e1f9063
24 changed files with 65 additions and 72 deletions

View file

@ -3884,8 +3884,8 @@ BrowserGlue.prototype = {
);
if (wasAddonActive) {
const { ProfilerMenuButton } = ChromeUtils.import(
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
const { ProfilerMenuButton } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
);
if (!ProfilerMenuButton.isInNavbar()) {
// The profiler menu button is not enabled. Turn it on now.

View file

@ -193,7 +193,7 @@ profiler-popup-capture-shortcut =
## They are shown in the popup's select box.
# Presets and their l10n IDs are defined in the file
# devtools/client/performance-new/shared/background.jsm.js
# devtools/client/performance-new/shared/background.sys.mjs
# Please take care that the same values are also defined in devtools' perftools.ftl.
profiler-popup-presets-web-developer-description = Recommended preset for most web app debugging, with low overhead.

View file

@ -8,8 +8,8 @@ Services.scriptloader.loadSubScript(
this
);
const BackgroundJSM = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const BackgroundJSM = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
registerCleanupFunction(() => {

View file

@ -211,8 +211,8 @@ loader.lazyRequireGetter(
true
);
loader.lazyGetter(this, "ProfilerBackground", () => {
return ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
return ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
});

View file

@ -128,7 +128,7 @@ perftools-onboarding-close-button =
## Profiler presets
# Presets and their l10n IDs are defined in the file
# devtools/client/performance-new/shared/background.jsm.js
# devtools/client/performance-new/shared/background.sys.mjs
# The same labels and descriptions are also defined in appmenu.ftl.
perftools-presets-web-developer-label = Web Developer

View file

@ -41,6 +41,6 @@ Some code about the popup is also present in `devtools/startup/DevToolsStartup.s
## Injecting profiles into [profiler.firefox.com]
After a profile has been collected, it needs to be sent to [profiler.firefox.com] for analysis. This is done by using browser APIs to open a new tab, and then setting up a web channel for the communication between the unprivileged page and the privileged chrome code. The page requests the profile data (as well as symbolication requests in some cases) through this Web Channel.
See `handleWebChannelMessage` in `background.jsm.js` as well as related code in `devtools/startup/DevToolsStartup.sys.mjs` for implementation details. Both the DevTools Panel and the Popup use this channel.
See `handleWebChannelMessage` in `background.sys.mjs` as well as related code in `devtools/startup/DevToolsStartup.sys.mjs` for implementation details. Both the DevTools Panel and the Popup use this channel.
[profiler.firefox.com]: https://profiler.firefox.com

View file

@ -37,13 +37,13 @@
}
/**
* The background.jsm.js manages the profiler state, and can be loaded multiple time
* The background.sys.mjs manages the profiler state, and can be loaded multiple time
* for various components. This page needs a copy, and it is also used by the
* profiler shortcuts. In order to do this, the background code needs to live in a
* JSM module, that can be shared with the DevTools keyboard shortcut manager.
*/
const { presets } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const { presets } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
const ReactDOM = require("resource://devtools/client/shared/vendor/react-dom.js");

View file

@ -38,8 +38,8 @@ const {
setRecordingSettings,
addPrefObserver,
removePrefObserver,
} = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
} = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
const {
PureComponent,

View file

@ -69,15 +69,15 @@ const {
openProfilerTab,
sharedLibrariesFromProfile,
} = require("resource://devtools/client/performance-new/shared/browser.js");
const { createLocalSymbolicationService } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/symbolication.jsm.js"
const { createLocalSymbolicationService } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/symbolication.sys.mjs"
);
const {
presets,
getProfilerViewModeForCurrentPreset,
registerProfileCaptureForBrowser,
} = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
} = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
/**

View file

@ -18,16 +18,14 @@
* @property {boolean} isInfoCollapsed
*/
const { createLazyLoaders } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/typescript-lazy-load.jsm.js"
);
import { createLazyLoaders } from "resource://devtools/client/performance-new/shared/typescript-lazy-load.sys.mjs";
const lazy = createLazyLoaders({
PanelMultiView: () =>
ChromeUtils.importESModule("resource:///modules/PanelMultiView.sys.mjs"),
Background: () =>
ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
),
});

View file

@ -8,9 +8,7 @@
* Care should be taken to keep it minimal as it can be run with browser initialization.
*/
const { createLazyLoaders } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/typescript-lazy-load.jsm.js"
);
import { createLazyLoaders } from "resource://devtools/client/performance-new/shared/typescript-lazy-load.sys.mjs";
const lazy = createLazyLoaders({
CustomizableUI: () =>
@ -20,12 +18,12 @@ const lazy = createLazyLoaders({
"resource:///modules/CustomizableWidgets.sys.mjs"
),
PopupLogic: () =>
ChromeUtils.import(
"resource://devtools/client/performance-new/popup/logic.jsm.js"
ChromeUtils.importESModule(
"resource://devtools/client/performance-new/popup/logic.sys.mjs"
),
Background: () =>
ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
),
});

View file

@ -1,5 +1,5 @@
This directory contains files that are common to all UIs (popup, devtools panel,
about:profiling) interacting with the profiler.
Other UIs external to the profiler (one example is about:logging) can also use
these files, especially background.jsm.js, to interact with the profiler with
these files, especially background.sys.mjs, to interact with the profiler with
more capabilities than Services.profiler.

View file

@ -12,9 +12,8 @@
// The following are not lazily loaded as they are needed during initialization.
const { createLazyLoaders } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/typescript-lazy-load.jsm.js"
);
import { createLazyLoaders } from "resource://devtools/client/performance-new/shared/typescript-lazy-load.sys.mjs";
// For some reason TypeScript was giving me an error when de-structuring AppConstants. I
// suspect a bug in TypeScript was at play.
const AppConstants = ChromeUtils.importESModule(
@ -95,12 +94,12 @@ const lazy = createLazyLoaders({
CustomizableUI: () =>
ChromeUtils.importESModule("resource:///modules/CustomizableUI.sys.mjs"),
PerfSymbolication: () =>
ChromeUtils.import(
"resource://devtools/client/performance-new/shared/symbolication.jsm.js"
ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/symbolication.sys.mjs"
),
ProfilerMenuButton: () =>
ChromeUtils.import(
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
ChromeUtils.importESModule(
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
),
});

View file

@ -6,9 +6,10 @@
add_task(async function test() {
info("Test what happens when a recording is interrupted by another tool.");
const { stopProfiler: stopProfilerByAnotherTool } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
);
const { stopProfiler: stopProfilerByAnotherTool } =
ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
await withDevToolsPanel(async document => {
const getRecordingState = setupGetRecordingState(document);

View file

@ -9,8 +9,8 @@ add_task(async function test() {
"Test what happens if the profiler was previously started by another tool."
);
const { startProfiler } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const { startProfiler } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
info("Start the profiler before DevTools is loaded.");

View file

@ -14,8 +14,8 @@ add_task(async function test() {
);
await makeSureProfilerPopupIsEnabled();
const { toggleProfiler, captureProfile } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const { toggleProfiler, captureProfile } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
const button = document.getElementById("profiler-button-button");

View file

@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const BackgroundJSM = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const BackgroundJSM = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
registerCleanupFunction(() => {

View file

@ -155,8 +155,8 @@ async function makeSureProfilerPopupIsEnabled() {
info("Make sure the profiler popup is enabled.");
info("> Load the profiler menu button.");
const { ProfilerMenuButton } = ChromeUtils.import(
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
const { ProfilerMenuButton } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
);
if (!ProfilerMenuButton.isInNavbar()) {
@ -524,8 +524,8 @@ async function withDevToolsPanel(url, callback, aWindow = window) {
* @returns {Object}
*/
function getActiveConfiguration() {
const BackgroundJSM = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const BackgroundJSM = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
const { startProfiler, stopProfiler } = BackgroundJSM;
@ -737,8 +737,8 @@ async function makeSureProfilerPopupIsDisabled() {
info("Make sure the profiler popup is dsiabled.");
info("> Load the profiler menu button module.");
const { ProfilerMenuButton } = ChromeUtils.import(
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
const { ProfilerMenuButton } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
);
const isOriginallyInNavBar = ProfilerMenuButton.isInNavbar();

View file

@ -5,8 +5,8 @@
registerCleanupFunction(() => {
// Always clean up the prefs after every test.
const { revertRecordingSettings } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
const { revertRecordingSettings } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
revertRecordingSettings();
});

View file

@ -8,8 +8,8 @@
*/
function setupBackgroundJsm() {
return ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
return ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
}

View file

@ -35,13 +35,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
CustomizableWidgets: "resource:///modules/CustomizableWidgets.sys.mjs",
PanelMultiView: "resource:///modules/PanelMultiView.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
ProfilerMenuButton:
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs",
WebChannel: "resource://gre/modules/WebChannel.sys.mjs",
});
ChromeUtils.defineModuleGetter(
lazy,
"ProfilerMenuButton",
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
);
// We don't want to spend time initializing the full loader here so we create
// our own lazy require.
@ -304,8 +301,8 @@ export function validateProfilerWebChannelUrl(targetUrl) {
}
ChromeUtils.defineLazyGetter(lazy, "ProfilerPopupBackground", function () {
return ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
return ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
});

View file

@ -40,8 +40,8 @@ ChromeUtils.defineESModuleGetters(this, {
});
ChromeUtils.defineLazyGetter(this, "ProfilerPopupBackground", function () {
return ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
return ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
});

View file

@ -16,8 +16,8 @@ const ASYNC_STACKS_ENABLED = Services.prefs.getBoolPref(
var { ExtensionError } = ExtensionUtils;
ChromeUtils.defineLazyGetter(this, "symbolicationService", () => {
let { createLocalSymbolicationService } = ChromeUtils.import(
"resource://devtools/client/performance-new/shared/symbolication.jsm.js"
let { createLocalSymbolicationService } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/symbolication.sys.mjs"
);
return createLocalSymbolicationService(Services.profiler.sharedLibraries, []);
});

View file

@ -13,16 +13,16 @@ const gDirServ = Cc["@mozilla.org/file/directory_service;1"].getService(
Ci.nsIDirectoryServiceProvider
);
const { ProfilerMenuButton } = ChromeUtils.import(
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
const { ProfilerMenuButton } = ChromeUtils.importESModule(
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
);
const { CustomizableUI } = ChromeUtils.importESModule(
"resource:///modules/CustomizableUI.sys.mjs"
);
ChromeUtils.defineLazyGetter(this, "ProfilerPopupBackground", function () {
return ChromeUtils.import(
"resource://devtools/client/performance-new/shared/background.jsm.js"
return ChromeUtils.importESModule(
"resource://devtools/client/performance-new/shared/background.sys.mjs"
);
});