Bug 1602075 - display Inspect Accessibility Properties menu item in inspector if devtools.accessibility.auto-init.enabled pref is set to true. r=gl
Differential Revision: https://phabricator.services.mozilla.com/D71587
This commit is contained in:
@@ -393,8 +393,15 @@ class MarkupContextMenu {
|
||||
});
|
||||
|
||||
// Only attempt to determine if a11y props menu item needs to be enabled if
|
||||
// AccessibilityFront is enabled.
|
||||
if (this.inspector.accessibilityFront.enabled) {
|
||||
// AccessibilityFront is enabled or a11y panel auto init option is set to
|
||||
// true.
|
||||
if (
|
||||
this.inspector.accessibilityFront.enabled ||
|
||||
Services.prefs.getBoolPref(
|
||||
"devtools.accessibility.auto-init.enabled",
|
||||
false
|
||||
)
|
||||
) {
|
||||
this._updateA11YMenuItem(showA11YPropsItem);
|
||||
}
|
||||
|
||||
@@ -952,9 +959,25 @@ class MarkupContextMenu {
|
||||
}
|
||||
|
||||
async _updateA11YMenuItem(menuItem) {
|
||||
const hasA11YProps = await this.walker.hasAccessibilityProperties(
|
||||
this.selection.nodeFront
|
||||
);
|
||||
if (!this.walker?.actorID) {
|
||||
return;
|
||||
}
|
||||
|
||||
let hasA11YProps = false;
|
||||
try {
|
||||
hasA11YProps = await this.walker.hasAccessibilityProperties(
|
||||
this.selection.nodeFront
|
||||
);
|
||||
} catch (e) {
|
||||
// The walker might already be destroyed at this point. Only throw an
|
||||
// exception when it is still alive and well.
|
||||
if (this.walker?.actorID) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasA11YProps) {
|
||||
const menuItemEl = Menu.getMenuElementById(menuItem.id, this.toolbox.doc);
|
||||
menuItemEl.disabled = menuItem.disabled = false;
|
||||
|
||||
Reference in New Issue
Block a user