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:
Yura Zenevich
2020-04-23 14:40:25 +00:00
parent ebf3d66b18
commit e8a007173b
3 changed files with 48 additions and 8 deletions

View File

@@ -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;