browser_accessibility_text_label_audit_frame.js (1418B)
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/. */ 4 5 "use strict"; 6 7 /** 8 * Checks functionality around text label audit for the AccessibleActor that is 9 * created for frame elements. 10 */ 11 12 const { 13 accessibility: { 14 AUDIT_TYPE: { TEXT_LABEL }, 15 SCORES: { FAIL }, 16 ISSUE_TYPE: { 17 [TEXT_LABEL]: { FRAME_NO_NAME }, 18 }, 19 }, 20 } = require("resource://devtools/shared/constants.js"); 21 22 add_task(async function () { 23 const { target, walker, a11yWalker, parentAccessibility } = 24 await initAccessibilityFrontsForUrl( 25 `${MAIN_DOMAIN}doc_accessibility_text_label_audit_frame.html` 26 ); 27 28 const tests = [ 29 ["Frame with no name", "#frame-1", { score: FAIL, issue: FRAME_NO_NAME }], 30 ["Frame with aria-label", "#frame-2", null], 31 ]; 32 33 for (const [description, selector, expected] of tests) { 34 info(description); 35 const node = await walker.querySelector(walker.rootNode, selector); 36 const front = await a11yWalker.getAccessibleFor(node); 37 const audit = await front.audit({ types: [TEXT_LABEL] }); 38 Assert.deepEqual( 39 audit[TEXT_LABEL], 40 expected, 41 `Audit result for ${selector} is correct.` 42 ); 43 } 44 45 await waitForA11yShutdown(parentAccessibility); 46 await target.destroy(); 47 gBrowser.removeCurrentTab(); 48 });