Bug 1688007 - [devtools] Add localized inspectIconTitle prop in Accessible.js . r=jdescottes.

This will add proper titles to the icons we display in the accessibility
panel to select a node in the Accessibility Tree or in the inspector (if it's
a dom node).
Assertions are added in tests to ensure we don't regress.

Differential Revision: https://phabricator.services.mozilla.com/D154406
This commit is contained in:
Nicolas Chevobbe 2022-08-12 13:10:04 +00:00
Родитель 9baf41e46c
Коммит 484afc4d26
4 изменённых файлов: 37 добавлений и 1 удалений

Просмотреть файл

@ -294,6 +294,10 @@ class Accessible extends Component {
valueProps.onDOMNodeMouseOut = () => this.hideHighlighter();
valueProps.onDOMNodeMouseOver = () =>
this.showHighlighter(this.props.nodeFront);
valueProps.inspectIconTitle = L10N.getStr(
"accessibility.accessible.selectNodeInInspector.title"
);
valueProps.onInspectIconClick = () =>
this.selectNode(this.props.nodeFront);
} else if (isAccessibleFront(object)) {
@ -303,6 +307,9 @@ class Accessible extends Component {
this.hideAccessibleHighlighter(target);
valueProps.onAccessibleMouseOver = () =>
this.showAccessibleHighlighter(target);
valueProps.inspectIconTitle = L10N.getStr(
"accessibility.accessible.selectElement.title"
);
valueProps.onInspectIconClick = (obj, e) => {
e.stopPropagation();
this.selectAccessible(target);

Просмотреть файл

@ -3,6 +3,8 @@
"use strict";
const { L10N } = require("devtools/client/accessibility/utils/l10n");
const TEST_URI = `<html>
<head>
<meta charset="utf-8"/>
@ -122,9 +124,19 @@ const tests = [
// activated.
nonNegativeTabIndexRule: false,
});
const selectElementInTreeButton = containingDocRelation.querySelector(
".open-accessibility-inspector"
);
ok(!!selectElementInTreeButton, "There's a button to select the element");
is(
selectElementInTreeButton.getAttribute("title"),
L10N.getStr("accessibility.accessible.selectElement.title"),
"The button has the expected title"
);
EventUtils.sendMouseEvent(
{ type: "click" },
containingDocRelation.querySelector(".open-accessibility-inspector"),
selectElementInTreeButton,
win
);
AccessibilityUtils.resetEnv();

Просмотреть файл

@ -3,6 +3,8 @@
"use strict";
const { L10N } = require("devtools/client/accessibility/utils/l10n");
// Check that DOM nodes in the sidebar can be highlighted and that clicking on the icon
// next to them opens the inspector.
@ -38,6 +40,11 @@ addA11YPanelTask(
const openInspectorButton = domNodeEl.querySelector(".open-inspector");
ok(openInspectorButton, "The open inspector button is displayed");
is(
openInspectorButton.getAttribute("title"),
L10N.getStr("accessibility.accessible.selectNodeInInspector.title"),
"The open inspector button has expected title"
);
info("Check that hovering DOMNode triggers the highlight");
// Loading the inspector panel at first, to make it possible to listen for

Просмотреть файл

@ -30,6 +30,16 @@ accessibility.properties=Properties
# Accessibility tree (that represents accessible element name) container.
accessibility.treeName=Accessibility Tree
# LOCALIZATION NOTE (accessibility.accessible.selectElement.title): A title text
# displayed on buttons next to accessible elements in the `relations` section, allowing the
# user to select the element in the accessibility tree.
accessibility.accessible.selectElement.title=Click to select the node in the Accessibility Tree
# LOCALIZATION NOTE (accessibility.accessible.selectNodeInInspector.title): A title text
# displayed on buttons next to nodes in the sidebar, allowing the user to select the node
# in the Inspector panel.
accessibility.accessible.selectNodeInInspector.title=Click to select the node in the inspector
# LOCALIZATION NOTE (accessibility.accessible.notAvailable): A title text
# displayed when accessible sidebar panel does not have an accessible object to
# display.