commit 42a0e13bf50e7874b86bb6942a176c8f59aef447
parent 5eb494e0efb4382b9f53d1d2b2437a8785711022
Author: James Teh <jteh@mozilla.com>
Date: Mon, 3 Nov 2025 22:30:53 +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
@@ -81,6 +81,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()) {