Cette traduction est incomplète. Aidez à traduire cet article depuis l'anglais.

L'inspecteur de l'accessibilité fournit un moyen d'accéder aux informations importantes exposées aux technologies d'assistance sur la page en cours via l'arbre d'accessibilité, vous permettant de vérifier ce qui manque ou qui nécessite une attention particulière. Cet article vous présente les principales fonctionnalités de l'inspecteur d'accessibilité et vous explique comment l'utiliser.

Un (très) bref guide sur l'accessibilité

 

L'accessibilité est la pratique qui consiste à rendre vos sites Web utilisables par le plus grand nombre de personnes possible. Cela signifie qu'il faut faire de son mieux pour ne pas empêcher quiconque d'accéder à l'information en raison d'un handicap ou de toute autre circonstance personnelle comme l'appareil qu'il utilise, la vitesse de sa connexion réseau, son emplacement géographique ou sa localisation.

 

Il s'agit ici principalement d'exposer l'information aux personnes ayant une déficience visuelle — cela se fait via les APIs d'accessibilité disponibles dans les navigateurs Web, qui exposent des informations sur le rôle que jouent les différents éléments de votre page (par exemple, sont-ils simplement du texte, ou sont-ils des boutons, liens, éléments de formulaire, etc ?

Les éléments sémantiques DOM ont des rôles qui leur sont assignés par défaut et qui suggèrent ce à quoi ils servent. Parfois, cependant, vous avez besoin d'utiliser des balises non sémantiques (par exemple,<div>s) pour construire un contrôle personnalisé complexe, et le contrôle n'aura pas un rôle par défaut qui reflète son but. Dans ce cas, vous pouvez utiliser les attributs de rôle WAI-ARIA pour fournir vos propres rôles.

Les rôles et autres informations exposés par les API d'accessibilité des navigateurs sont présentés dans une structure hiérarchique appelée l'arbre d'accessibilité. C'est un peu comme l'arbre DOM, sauf qu'il contient un ensemble plus limité d'éléments et des informations légèrement différentes à leur sujet.

Les technologies d'aide comme les lecteurs d'écran utilisent cette information pour découvrir ce qu'il y a sur une page Web, dire à leurs utilisateurs ce qui s'y trouve et leur permettre d'interagir avec la page. L'inspecteur d'accessibilité utilise également ces informations pour fournir de précieuses fonctionnalités de débogage d'accessibilité dans les DevTools.

Accès à l'inspecteur de l'accessibilité

L'inspecteur d'accessibilité (disponible depuis Firefox 61) n'est pas affiché par défaut dans DevTools. Pour l'activer, il faut aller dans les paramètres de DevTools (appuyer sur F1, ou aller dans le menu "three dots" et choisir Settings) et cocher la case Accessibilité sous la rubrique Default Developer Tools. L'onglet Accessibilité apparaîtra dans l'affichage principal de DevTools, sur lequel vous pouvez cliquer pour afficher le panneau d'accessibilité :

Accessibility tab in firefox devtools, turned off, with a button labeled Turn On Accessibility Features

Initially the DevTools accessibility features are turned off (unless you've already got them turned on in another browser tab, or got the Firefox accessibility engine started already, e.g., you might be a screenreader user or tester). This is because the accessibility engine runs in the background when the accessibility features are turned on. While it’s running, it slows performance and takes up memory; therefore it interferes with the metrics from other panels such as Memory and Performance as well as overall browser performance. For this reason you should keep it turned off when you aren't specifically using it.

You can turn the features on using the Turn On Accessibility Features button.

Once the panel content loads, you can then turn it off again using the Turn Off Accessibility Features button available in the top-left corner, unless you have the accessibility engine running previously to operate a screenreader, in which case this button will be disabed.

Note: If are using the accessibility features in multiple tabs, turning them off in one tab turns them off in all tabs.

Features of the Accessibility panel

The enabled accessibility panel looks like so:

Accessibility tab in firefox devtools, turned on, showing two information panels plus a button labeled Turn Off Accessibility Features

On the left-hand side, there is a tree diagram representing all the items in the accessibility tree for the current page. Items with nested children have arrows that can be clicked to reveal the children, so you can move deeper into the hierarchy. Each item has two properties listed:

  • Role — the role this item has on the page (e.g., pushbutton, or footer). This can be either a default role provided by the browser, or a role given to it via a WAI-ARIA role attribute.
  • Name — the name this item has on the page. Where this comes from depends on the element; for example, the name of most text elements is simply their textContent, whereas form elements' names are the contents of their associated <label>.

On the right-hand side, you can see further information about the currently selected item. The listed properties are as follows:

  • name — the item's name, as described above.
  • role — the item's role, as described above.
  • actions — a list of the actions that can be performed on the item, for example a pushbutton would have "Press" listed, while a link would have "Jump" listed.
  • value — the value of the item. This can mean different things depending on the type of item; for example, a form input (role: entry) would have a value of whatever is entered in the input, whereas a link's value would be the URL in the corresponding <a> element's href.
  • DOMNode — the type of DOM node that the item in the accessibility tree represents. You can click on the "target" icon that comes after it to select the node in the Page Inspector. Hovering over the "target" icon highlights the DOM node in the page content.
    DOMNode property in accessibility inspector with target icon highlighted
  • description — any further description provided on the element, usually by the content of a title attribute.
  • help — this is not implemented in Gecko, so it always returns an empty string. This will be removed from the inspector in Firefox 62 (bug 1467643).
  • keyboardShortcut — any keyboard shortcut that is available to activate the element, as specified in an accessKey attribute. Note that this works correctly as of Firefox 62 (bug 1467381).
  • childCount — the number of child items the current item has in the accessibility tree hierarchy.
  • indexInParent — an index value indicating what number child the item is, inside its parent. If the item is the first item inside its parent, it has a value of 0. If it is the second, it has a value of 1. And so on.
  • states — a list of the different accessibility-relevant states that can apply to the current item. For example, one of the links in one demo has states of focusable, linked, selectable text, opaque, enabled, and sensitive. For a full list of internal states, see Gecko states.
  • attributes — a list of all the accessibility-relevant attributes that are applied to the item. This can include style-related attributes such as margin-left and text-indent, and other useful states for accessibility information, such as draggable and level (e.g., what heading level is it, in the case of headings). For a full list of possible attributes, see Gecko object attributes.

Note: The exposed information is the same across all platforms — the inspector exposes Gecko's accessibility tree, rather than information from the platform accessibility layer.

Keyboard controls

The Accessibility tab is fully keyboard-accessible:

  • You can tab between the Turn Off Accessibility Features button and left and right panels.
  • When one of the panels is focused, you can move the focus up and down items using the up and down arrow keys, and use the left and right arrow keys to expand and collapse expandable rows (e.g., different hierarchy levels of the accessibility tree).

When the accessibility features are turned on, there are a number of useful additional features available in the DevTools, which are detailed below:

Context menu options

An extra context menu option is added, both for the general context menu on the web page when right/Ctrl + clicking a UI feature, and the HTML pane of the page inspector when right/Ctrl + clicking a DOM element:

context menu in the browser viewport, with a highlighted option: Inspect Accessibility Properties

context menu in the DOM inspector, with a highlighted option: Show Accessibility Properties

When you choose the Inspect Accessibility Properties/Show Accessibility Properties context menu options, the Accessibility tab is immediately opened to show the corresponding accessibility tree item and its properties.

Note: Some DOM elements do not have accessibility properties — in such a case, the Inspect Accessibility Properties/Show Accessibility Properties context menu item is grayed out.

Highlighting of UI items

In the Accessibility tab, when the mouse hovers over accessibility items, you can see a semi-transparent highlight appear over the UI items they relate to, if appropriate. The role and name of the item will be shown in a small information bar. This is useful for determining how the items in the accessibility tree relate to the UI items on the actual page.

In the following example, you can see that the image has been highlighted and its role, graphic, name, "Road, Asphalt, Sky, Clouds, Fall", and the color contrast ratio, 3.46, appears in the information bar above it.

Color Contrast

Contrast ratio information is particularly useful when you are designing the color palette for your website because if the contrast is not sufficient, readers with visual impairments such as color blindness will be unable to read the text. The Web Content Accessibility Guidelines (WCAG) 2.0 defines 4.5:1 as the minimum suggested contrast ratio between the foreground and background colors for smaller text on a web page. For example:

The color contrast in the image above is 2.77, potentially not enough contrast to make it easy to read. Notice the warning symbol that indicates that the contrast fails to meet the acceptable contrast ratio. Compare that to the following:

In this example, the contrast is 12.63. This time the number is follow by AAA and a checkmark in green, indicating that the text has a contrast ratio of 7:1 or more, meaning it meets the criteria for enchanced contrast, or Level AAA.

Accessibility picker

In a similar way to the Page Inspector HTML pane picker, when the Accessibility tab's picker button is pressed you can then hover and select UI items in the current page, and the corresponding accessible object is highlighted in the accessibility tree.

The accessibility tab picker differs in look slightly from the Page Inspector HTML pane picker, as shown below:

highlighted dom inspector picker button, with a tooltip saying Pick an element from the page

highlighted accessibility inspector button, with a tooltip saying Pick accessible object from the page

When you "perform a pick", you see the accessibility object highlighted in the accessibility tree, and the picker is then deactivated. Note, however, that if you hold the Shift key down when "performing a pick", you can "preview" the accessibility object in the tree (and its properties in the right-hand pane), but then continue picking as many times as you like (the picker does not get cancelled) until you release the Shift key.

When the picker is activated, you can also deactivate it by pressing the picker button a second time, or pressing the Esc key.

Typical use cases

The accessibility inspector is very useful for spotting accessibility problems at a glance. For a start, you can investigate items that don't have a proper text equivalent — images without alt text and form elements without proper labels have a name property of null, for example.

A form input highlighted in the UI, with information about it shown in the accessibility inspector to reveal that it has no label — it has a name property of null

It is also very handy for verifying semantics — you can use the Inspect Accessibility Properties context menu option to quickly see whether an item has the correct role set on it (e.g., whether a button is really a button, or whether a link is really a link).

A UI element that looks like a button, with information about it shown in the accessibility inspector to reveal that it isn't a button, it is a section element. It has a name property of null

See also

Étiquettes et contributeurs liés au document

Contributeurs à cette page : hellosct1
Dernière mise à jour par : hellosct1,