1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * Checks functionality around text label audit for the AccessibleActor.
13 AUDIT_TYPE: { KEYBOARD },
14 SCORES: { FAIL, WARNING },
17 FOCUSABLE_NO_SEMANTICS,
18 FOCUSABLE_POSITIVE_TABINDEX,
19 INTERACTIVE_NOT_FOCUSABLE,
20 MOUSE_INTERACTIVE_ONLY,
25 } = require("resource://devtools/shared/constants.js");
27 add_task(async function () {
28 const { target, walker, parentAccessibility, a11yWalker } =
29 await initAccessibilityFrontsForUrl(
30 `${MAIN_DOMAIN}doc_accessibility_keyboard_audit.html`
35 "Focusable element (styled button) with no semantics.",
37 { score: WARNING, issue: FOCUSABLE_NO_SEMANTICS },
39 ["Element (styled button) with no semantics.", "#button-2", null],
41 "Container element for out of order focusable element.",
46 "Interactive element with focus out of order (-1).",
50 issue: INTERACTIVE_NOT_FOCUSABLE,
54 "Interactive element with focus out of order (-1) when disabled.",
58 ["Interactive element when disabled.", "#input-3", null],
59 ["Focusable interactive element.", "#input-4", null],
61 "Interactive accesible (link with no attributes) with no accessible actions.",
65 ["Interactive accessible (link with valid href).", "#link-2", null],
66 ["Interactive accessible (link with # as href).", "#link-3", null],
68 "Interactive accessible (link with empty string as href).",
72 ["Interactive accessible with no tabindex.", "#button-3", null],
74 "Interactive accessible with -1 tabindex.",
78 issue: INTERACTIVE_NOT_FOCUSABLE,
81 ["Interactive accessible with 0 tabindex.", "#button-5", null],
83 "Interactive accessible with 1 tabindex.",
85 { score: WARNING, issue: FOCUSABLE_POSITIVE_TABINDEX },
88 "Focusable ARIA button with no focus styling.",
90 { score: WARNING, issue: NO_FOCUS_VISIBLE },
92 ["Focusable ARIA button with focus styling.", "#focusable-2", null],
93 ["Focusable ARIA button with browser styling.", "#focusable-3", null],
95 "Not focusable, non-semantic element that has a click handler.",
97 { score: FAIL, issue: MOUSE_INTERACTIVE_ONLY },
100 "Focusable, non-semantic element that has a click handler.",
102 { score: WARNING, issue: FOCUSABLE_NO_SEMANTICS },
105 "Not focusable, ARIA button that has a click handler.",
107 { score: FAIL, issue: INTERACTIVE_NOT_FOCUSABLE },
109 ["Focusable, ARIA button with a click handler.", "#button-8", null],
110 ["Regular image, no keyboard checks should flag an issue.", "#img-1", null],
112 "Image with a longdesc (accessible will have showlongdesc action).",
117 "Clickable image with a longdesc (accessible will have click and showlongdesc actions).",
119 { score: FAIL, issue: MOUSE_INTERACTIVE_ONLY },
122 "Clickable image (accessible will have click action).",
124 { score: FAIL, issue: MOUSE_INTERACTIVE_ONLY },
126 ["Focusable button with aria-haspopup.", "#buttonmenu-1", null],
128 "Not focusable aria button with aria-haspopup.",
132 issue: INTERACTIVE_NOT_FOCUSABLE,
135 ["Focusable checkbox.", "#checkbox-1", null],
136 ["Focusable select element size > 1", "#listbox-1", null],
137 ["Focusable select element with one option", "#combobox-1", null],
138 ["Focusable select element with no options", "#combobox-2", null],
139 ["Focusable select element with two options", "#combobox-3", null],
141 "Non-focusable aria combobox with one aria option.",
145 ["Non-focusable aria combobox with no options.", "#editcombobox-2", null],
146 ["Focusable aria combobox with no options.", "#editcombobox-3", null],
148 "Non-focusable aria switch",
152 issue: INTERACTIVE_NOT_FOCUSABLE,
155 ["Focusable aria switch", "#switch-2", null],
157 "Combobox list that is visible (has focusable state)",
162 "Mouse interactive, label that contains form element (linked)",
166 ["Mouse interactive label for external element (linked)", "#label-2", null],
167 ["Not interactive unlinked label", "#label-3", null],
169 "Not interactive unlinked label with folloing form element",
173 ["Image inside an anchor (href)", "#img-5", null],
174 ["Image inside an anchor (onmousedown)", "#img-6", null],
175 ["Image inside an anchor (onclick)", "#img-7", null],
176 ["Image inside an anchor (onmouseup)", "#img-8", null],
178 "Section with a collapse action from aria-expanded attribute",
182 ["Tabindex -1 should not report an element as focusable", "#main", null],
184 "Not keyboard focusable element with no focus styling.",
185 "#not-keyboard-focusable-1",
188 ["Interactive grid that is not focusable.", "#grid-1", null],
190 "Focusable interactive grid.",
192 { score: "WARNING", issue: "FOCUSABLE_NO_SEMANTICS" },
195 "Non interactive ARIA table does not need to be focusable.",
200 "Focusable ARIA table does not have interactive semantics",
202 { score: "WARNING", issue: "FOCUSABLE_NO_SEMANTICS" },
204 ["Non interactive table does not need to be focusable.", "#table-3", null],
206 "Focusable table does not have interactive semantics",
208 { score: "WARNING", issue: "FOCUSABLE_NO_SEMANTICS" },
211 "Article that is not focusable is not considered interactive",
215 ["Focusable article is considered interactive", "#article-2", null],
217 "Column header that is not focusable is not considered interactive (ARIA grid)",
222 "Column header that is not focusable is not considered interactive (ARIA table)",
227 "Column header that is not focusable is not considered interactive (table)",
232 "Column header that is focusable is considered interactive (table)",
237 "Column header that is not focusable is not considered interactive (table as ARIA grid)",
242 "Column header that is focusable is considered interactive (table as ARIA grid)",
247 "Row header that is not focusable is not considered interactive",
252 "Row header that is not focusable is not considered interactive",
257 "Row header that is not focusable is not considered interactive",
262 "Row header that is focusable is considered interactive",
267 "Row header that is not focusable is not considered interactive (table as ARIA grid)",
272 "Row header that is focusable is considered interactive (table as ARIA grid)",
277 "Gridcell that is not focusable is not considered interactive (ARIA grid)",
282 "Gridcell that is focusable is considered interactive (ARIA grid)",
287 "Gridcell that is not focusable is not considered interactive (table as ARIA grid)",
292 "Gridcell that is focusable is considered interactive (table as ARIA grid)",
297 "Tab list that is not focusable is not considered interactive",
301 ["Focusable tab list is considered interactive", "#tablist-2", null],
303 "Scrollbar that is not focusable is not considered interactive",
307 ["Focusable scrollbar is considered interactive", "#scrollbar-2", null],
309 "Separator that is not focusable is not considered interactive",
313 ["Focusable separator is considered interactive", "#separator-2", null],
315 "Toolbar that is not focusable is not considered interactive",
319 ["Focusable toolbar is considered interactive", "#toolbar-2", null],
321 "Menu popup that is not focusable is not considered interactive",
325 ["Focusable menu popup is considered interactive", "#menu-2", null],
327 "Menubar that is not focusable is not considered interactive",
331 ["Focusable menubar is considered interactive", "#menubar-2", null],
334 for (const [description, selector, expected] of tests) {
336 const node = await walker.querySelector(walker.rootNode, selector);
337 const front = await a11yWalker.getAccessibleFor(node);
338 const audit = await front.audit({ types: [KEYBOARD] });
342 `Audit result for ${selector} is correct.`
346 info("Text leaf inside a link (jump action is propagated to the text link)");
347 let node = await walker.querySelector(walker.rootNode, "#link-5");
348 let parent = await a11yWalker.getAccessibleFor(node);
349 let front = (await parent.children())[0];
350 let audit = await front.audit({ types: [KEYBOARD] });
354 "Text leafs are excluded from semantics rule."
357 info("Combobox list that is invisible");
358 node = await walker.querySelector(walker.rootNode, "#combobox-1");
359 parent = await a11yWalker.getAccessibleFor(node);
360 front = (await parent.children())[0];
361 audit = await front.audit({ types: [KEYBOARD] });
365 "Combobox lists (invisible) are excluded from semantics rule."
368 await waitForA11yShutdown(parentAccessibility);
369 await target.destroy();
370 gBrowser.removeCurrentTab();