Skip to content

Commit 402e1f9

Browse files
committed
Bug 1878457 - Part 2: ESMify consumers of performance-new modules. r=julienw,profiler-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D200559
1 parent ac9978d commit 402e1f9

File tree

24 files changed

+65
-72
lines changed

24 files changed

+65
-72
lines changed

browser/components/BrowserGlue.sys.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,8 +3884,8 @@ BrowserGlue.prototype = {
38843884
);
38853885

38863886
if (wasAddonActive) {
3887-
const { ProfilerMenuButton } = ChromeUtils.import(
3888-
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
3887+
const { ProfilerMenuButton } = ChromeUtils.importESModule(
3888+
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
38893889
);
38903890
if (!ProfilerMenuButton.isInNavbar()) {
38913891
// The profiler menu button is not enabled. Turn it on now.

browser/locales/en-US/browser/appmenu.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ profiler-popup-capture-shortcut =
193193
## They are shown in the popup's select box.
194194

195195
# Presets and their l10n IDs are defined in the file
196-
# devtools/client/performance-new/shared/background.jsm.js
196+
# devtools/client/performance-new/shared/background.sys.mjs
197197
# Please take care that the same values are also defined in devtools' perftools.ftl.
198198

199199
profiler-popup-presets-web-developer-description = Recommended preset for most web app debugging, with low overhead.

devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_profiler_dialog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Services.scriptloader.loadSubScript(
88
this
99
);
1010

11-
const BackgroundJSM = ChromeUtils.import(
12-
"resource://devtools/client/performance-new/shared/background.jsm.js"
11+
const BackgroundJSM = ChromeUtils.importESModule(
12+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
1313
);
1414

1515
registerCleanupFunction(() => {

devtools/client/framework/toolbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ loader.lazyRequireGetter(
211211
true
212212
);
213213
loader.lazyGetter(this, "ProfilerBackground", () => {
214-
return ChromeUtils.import(
215-
"resource://devtools/client/performance-new/shared/background.jsm.js"
214+
return ChromeUtils.importESModule(
215+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
216216
);
217217
});
218218

devtools/client/locales/en-US/perftools.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ perftools-onboarding-close-button =
128128
## Profiler presets
129129

130130
# Presets and their l10n IDs are defined in the file
131-
# devtools/client/performance-new/shared/background.jsm.js
131+
# devtools/client/performance-new/shared/background.sys.mjs
132132
# The same labels and descriptions are also defined in appmenu.ftl.
133133

134134
perftools-presets-web-developer-label = Web Developer

devtools/client/performance-new/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ Some code about the popup is also present in `devtools/startup/DevToolsStartup.s
4141
## Injecting profiles into [profiler.firefox.com]
4242

4343
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.
44-
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.
44+
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.
4545

4646
[profiler.firefox.com]: https://profiler.firefox.com

devtools/client/performance-new/aboutprofiling/initializer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
}
3838

3939
/**
40-
* The background.jsm.js manages the profiler state, and can be loaded multiple time
40+
* The background.sys.mjs manages the profiler state, and can be loaded multiple time
4141
* for various components. This page needs a copy, and it is also used by the
4242
* profiler shortcuts. In order to do this, the background code needs to live in a
4343
* JSM module, that can be shared with the DevTools keyboard shortcut manager.
4444
*/
45-
const { presets } = ChromeUtils.import(
46-
"resource://devtools/client/performance-new/shared/background.jsm.js"
45+
const { presets } = ChromeUtils.importESModule(
46+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
4747
);
4848

4949
const ReactDOM = require("resource://devtools/client/shared/vendor/react-dom.js");

devtools/client/performance-new/components/shared/ProfilerPreferenceObserver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const {
3838
setRecordingSettings,
3939
addPrefObserver,
4040
removePrefObserver,
41-
} = ChromeUtils.import(
42-
"resource://devtools/client/performance-new/shared/background.jsm.js"
41+
} = ChromeUtils.importESModule(
42+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
4343
);
4444
const {
4545
PureComponent,

devtools/client/performance-new/panel/initializer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ const {
6969
openProfilerTab,
7070
sharedLibrariesFromProfile,
7171
} = require("resource://devtools/client/performance-new/shared/browser.js");
72-
const { createLocalSymbolicationService } = ChromeUtils.import(
73-
"resource://devtools/client/performance-new/shared/symbolication.jsm.js"
72+
const { createLocalSymbolicationService } = ChromeUtils.importESModule(
73+
"resource://devtools/client/performance-new/shared/symbolication.sys.mjs"
7474
);
7575
const {
7676
presets,
7777
getProfilerViewModeForCurrentPreset,
7878
registerProfileCaptureForBrowser,
79-
} = ChromeUtils.import(
80-
"resource://devtools/client/performance-new/shared/background.jsm.js"
79+
} = ChromeUtils.importESModule(
80+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
8181
);
8282

8383
/**

devtools/client/performance-new/popup/logic.sys.mjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
* @property {boolean} isInfoCollapsed
1919
*/
2020

21-
const { createLazyLoaders } = ChromeUtils.import(
22-
"resource://devtools/client/performance-new/shared/typescript-lazy-load.jsm.js"
23-
);
21+
import { createLazyLoaders } from "resource://devtools/client/performance-new/shared/typescript-lazy-load.sys.mjs";
2422

2523
const lazy = createLazyLoaders({
2624
PanelMultiView: () =>
2725
ChromeUtils.importESModule("resource:///modules/PanelMultiView.sys.mjs"),
2826
Background: () =>
29-
ChromeUtils.import(
30-
"resource://devtools/client/performance-new/shared/background.jsm.js"
27+
ChromeUtils.importESModule(
28+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
3129
),
3230
});
3331

devtools/client/performance-new/popup/menu-button.sys.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
* Care should be taken to keep it minimal as it can be run with browser initialization.
99
*/
1010

11-
const { createLazyLoaders } = ChromeUtils.import(
12-
"resource://devtools/client/performance-new/shared/typescript-lazy-load.jsm.js"
13-
);
11+
import { createLazyLoaders } from "resource://devtools/client/performance-new/shared/typescript-lazy-load.sys.mjs";
1412

1513
const lazy = createLazyLoaders({
1614
CustomizableUI: () =>
@@ -20,12 +18,12 @@ const lazy = createLazyLoaders({
2018
"resource:///modules/CustomizableWidgets.sys.mjs"
2119
),
2220
PopupLogic: () =>
23-
ChromeUtils.import(
24-
"resource://devtools/client/performance-new/popup/logic.jsm.js"
21+
ChromeUtils.importESModule(
22+
"resource://devtools/client/performance-new/popup/logic.sys.mjs"
2523
),
2624
Background: () =>
27-
ChromeUtils.import(
28-
"resource://devtools/client/performance-new/shared/background.jsm.js"
25+
ChromeUtils.importESModule(
26+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
2927
),
3028
});
3129

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
This directory contains files that are common to all UIs (popup, devtools panel,
22
about:profiling) interacting with the profiler.
33
Other UIs external to the profiler (one example is about:logging) can also use
4-
these files, especially background.jsm.js, to interact with the profiler with
4+
these files, especially background.sys.mjs, to interact with the profiler with
55
more capabilities than Services.profiler.

devtools/client/performance-new/shared/background.sys.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212

1313
// The following are not lazily loaded as they are needed during initialization.
1414

15-
const { createLazyLoaders } = ChromeUtils.import(
16-
"resource://devtools/client/performance-new/shared/typescript-lazy-load.jsm.js"
17-
);
15+
import { createLazyLoaders } from "resource://devtools/client/performance-new/shared/typescript-lazy-load.sys.mjs";
16+
1817
// For some reason TypeScript was giving me an error when de-structuring AppConstants. I
1918
// suspect a bug in TypeScript was at play.
2019
const AppConstants = ChromeUtils.importESModule(
@@ -95,12 +94,12 @@ const lazy = createLazyLoaders({
9594
CustomizableUI: () =>
9695
ChromeUtils.importESModule("resource:///modules/CustomizableUI.sys.mjs"),
9796
PerfSymbolication: () =>
98-
ChromeUtils.import(
99-
"resource://devtools/client/performance-new/shared/symbolication.jsm.js"
97+
ChromeUtils.importESModule(
98+
"resource://devtools/client/performance-new/shared/symbolication.sys.mjs"
10099
),
101100
ProfilerMenuButton: () =>
102-
ChromeUtils.import(
103-
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
101+
ChromeUtils.importESModule(
102+
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
104103
),
105104
});
106105

devtools/client/performance-new/test/browser/browser_devtools-interrupted.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
add_task(async function test() {
77
info("Test what happens when a recording is interrupted by another tool.");
88

9-
const { stopProfiler: stopProfilerByAnotherTool } = ChromeUtils.import(
10-
"resource://devtools/client/performance-new/shared/background.jsm.js"
11-
);
9+
const { stopProfiler: stopProfilerByAnotherTool } =
10+
ChromeUtils.importESModule(
11+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
12+
);
1213

1314
await withDevToolsPanel(async document => {
1415
const getRecordingState = setupGetRecordingState(document);

devtools/client/performance-new/test/browser/browser_devtools-previously-started.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ add_task(async function test() {
99
"Test what happens if the profiler was previously started by another tool."
1010
);
1111

12-
const { startProfiler } = ChromeUtils.import(
13-
"resource://devtools/client/performance-new/shared/background.jsm.js"
12+
const { startProfiler } = ChromeUtils.importESModule(
13+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
1414
);
1515

1616
info("Start the profiler before DevTools is loaded.");

devtools/client/performance-new/test/browser/browser_popup-profiler-states.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ add_task(async function test() {
1414
);
1515
await makeSureProfilerPopupIsEnabled();
1616

17-
const { toggleProfiler, captureProfile } = ChromeUtils.import(
18-
"resource://devtools/client/performance-new/shared/background.jsm.js"
17+
const { toggleProfiler, captureProfile } = ChromeUtils.importESModule(
18+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
1919
);
2020

2121
const button = document.getElementById("profiler-button-button");

devtools/client/performance-new/test/browser/head.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
"use strict";
55

6-
const BackgroundJSM = ChromeUtils.import(
7-
"resource://devtools/client/performance-new/shared/background.jsm.js"
6+
const BackgroundJSM = ChromeUtils.importESModule(
7+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
88
);
99

1010
registerCleanupFunction(() => {

devtools/client/performance-new/test/browser/helpers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ async function makeSureProfilerPopupIsEnabled() {
155155
info("Make sure the profiler popup is enabled.");
156156

157157
info("> Load the profiler menu button.");
158-
const { ProfilerMenuButton } = ChromeUtils.import(
159-
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
158+
const { ProfilerMenuButton } = ChromeUtils.importESModule(
159+
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
160160
);
161161

162162
if (!ProfilerMenuButton.isInNavbar()) {
@@ -524,8 +524,8 @@ async function withDevToolsPanel(url, callback, aWindow = window) {
524524
* @returns {Object}
525525
*/
526526
function getActiveConfiguration() {
527-
const BackgroundJSM = ChromeUtils.import(
528-
"resource://devtools/client/performance-new/shared/background.jsm.js"
527+
const BackgroundJSM = ChromeUtils.importESModule(
528+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
529529
);
530530

531531
const { startProfiler, stopProfiler } = BackgroundJSM;
@@ -737,8 +737,8 @@ async function makeSureProfilerPopupIsDisabled() {
737737
info("Make sure the profiler popup is dsiabled.");
738738

739739
info("> Load the profiler menu button module.");
740-
const { ProfilerMenuButton } = ChromeUtils.import(
741-
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
740+
const { ProfilerMenuButton } = ChromeUtils.importESModule(
741+
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
742742
);
743743

744744
const isOriginallyInNavBar = ProfilerMenuButton.isInNavbar();

devtools/client/performance-new/test/xpcshell/head.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

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

devtools/client/performance-new/test/xpcshell/test_popup_initial_state.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99

1010
function setupBackgroundJsm() {
11-
return ChromeUtils.import(
12-
"resource://devtools/client/performance-new/shared/background.jsm.js"
11+
return ChromeUtils.importESModule(
12+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
1313
);
1414
}
1515

devtools/startup/DevToolsStartup.sys.mjs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
3535
CustomizableWidgets: "resource:///modules/CustomizableWidgets.sys.mjs",
3636
PanelMultiView: "resource:///modules/PanelMultiView.sys.mjs",
3737
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
38+
ProfilerMenuButton:
39+
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs",
3840
WebChannel: "resource://gre/modules/WebChannel.sys.mjs",
3941
});
40-
ChromeUtils.defineModuleGetter(
41-
lazy,
42-
"ProfilerMenuButton",
43-
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
44-
);
4542

4643
// We don't want to spend time initializing the full loader here so we create
4744
// our own lazy require.
@@ -304,8 +301,8 @@ export function validateProfilerWebChannelUrl(targetUrl) {
304301
}
305302

306303
ChromeUtils.defineLazyGetter(lazy, "ProfilerPopupBackground", function () {
307-
return ChromeUtils.import(
308-
"resource://devtools/client/performance-new/shared/background.jsm.js"
304+
return ChromeUtils.importESModule(
305+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
309306
);
310307
});
311308

toolkit/components/aboutprocesses/content/aboutProcesses.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ ChromeUtils.defineESModuleGetters(this, {
4040
});
4141

4242
ChromeUtils.defineLazyGetter(this, "ProfilerPopupBackground", function () {
43-
return ChromeUtils.import(
44-
"resource://devtools/client/performance-new/shared/background.jsm.js"
43+
return ChromeUtils.importESModule(
44+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
4545
);
4646
});
4747

toolkit/components/extensions/parent/ext-geckoProfiler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const ASYNC_STACKS_ENABLED = Services.prefs.getBoolPref(
1616
var { ExtensionError } = ExtensionUtils;
1717

1818
ChromeUtils.defineLazyGetter(this, "symbolicationService", () => {
19-
let { createLocalSymbolicationService } = ChromeUtils.import(
20-
"resource://devtools/client/performance-new/shared/symbolication.jsm.js"
19+
let { createLocalSymbolicationService } = ChromeUtils.importESModule(
20+
"resource://devtools/client/performance-new/shared/symbolication.sys.mjs"
2121
);
2222
return createLocalSymbolicationService(Services.profiler.sharedLibraries, []);
2323
});

toolkit/content/aboutLogging.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ const gDirServ = Cc["@mozilla.org/file/directory_service;1"].getService(
1313
Ci.nsIDirectoryServiceProvider
1414
);
1515

16-
const { ProfilerMenuButton } = ChromeUtils.import(
17-
"resource://devtools/client/performance-new/popup/menu-button.jsm.js"
16+
const { ProfilerMenuButton } = ChromeUtils.importESModule(
17+
"resource://devtools/client/performance-new/popup/menu-button.sys.mjs"
1818
);
1919
const { CustomizableUI } = ChromeUtils.importESModule(
2020
"resource:///modules/CustomizableUI.sys.mjs"
2121
);
2222

2323
ChromeUtils.defineLazyGetter(this, "ProfilerPopupBackground", function () {
24-
return ChromeUtils.import(
25-
"resource://devtools/client/performance-new/shared/background.jsm.js"
24+
return ChromeUtils.importESModule(
25+
"resource://devtools/client/performance-new/shared/background.sys.mjs"
2626
);
2727
});
2828

0 commit comments

Comments
 (0)