commit 84f8b56d85d0e2b88f84896d55e0bea391ce54d9
parent 287985a9b3a966ba8eb0fd69299d56c1e746818b
Author: James Teh <jteh@mozilla.com>
Date: Wed, 12 Nov 2025 05:14:27 +0000
Bug 1635774 part 4: Ensure that DevTools is initialized when about:keyboard is opened. r=devtools-reviewers,mossop,ochameau
This is necessary in order to ensure that DevTools items such as Browser Console are added to the menu bar menus and thus picked up by about:keyboard.
Differential Revision: https://phabricator.services.mozilla.com/D266793
Diffstat:
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/browser/components/customkeys/CustomKeysParent.sys.mjs b/browser/components/customkeys/CustomKeysParent.sys.mjs
@@ -26,7 +26,10 @@ export class CustomKeysParent extends JSWindowActorParent {
// { <categoryTitle>: { <keyId>: { title: <title>, shortcut: <String>, isCustomized: <Boolean> } }
// If categoryTitle or keyTitle begins with "customkeys-", it is a Fluent id.
getKeys() {
+ // Make Dev Tools populate the Browser Tools menu so we can gather those
+ // shortcuts here.
const topWin = this.browsingContext.topChromeWindow;
+ Services.obs.notifyObservers(topWin, "customkeys-ui-showing");
const add = (category, id, title) => {
const data = this.getKeyData(id);
diff --git a/browser/components/customkeys/tests/browser/browser_aboutKeyboard.js b/browser/components/customkeys/tests/browser/browser_aboutKeyboard.js
@@ -83,6 +83,11 @@ addAboutKbTask(async function testInit(tab) {
0,
"No keys are being edited"
);
+ // Make sure that lazy DevTools items have been added.
+ ok(
+ content.document.querySelector('.key[data-id="key_browserConsole"]'),
+ "key_browserConsole is present"
+ );
});
});
diff --git a/devtools/startup/DevToolsStartup.sys.mjs b/devtools/startup/DevToolsStartup.sys.mjs
@@ -379,6 +379,12 @@ DevToolsStartup.prototype = {
this.onMoreToolsViewShowing,
"web-developer-tools-view-showing"
);
+ // Add DevTools menu items so they can be picked up by the customize
+ // keyboard shortcuts UI.
+ Services.obs.addObserver(() => {
+ // Initialize DevTools to create all menuitems in the system menu.
+ this.initDevTools("CustomKeysUI");
+ }, "customkeys-ui-showing");
/* eslint-enable mozilla/balanced-observers */
if (!this.isDisabledByPolicy()) {