browser_aria_current.js (1635B)
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 /* import-globals-from ../../mochitest/role.js */ 8 /* import-globals-from ../../mochitest/states.js */ 9 loadScripts( 10 { name: "role.js", dir: MOCHITESTS_DIR }, 11 { name: "states.js", dir: MOCHITESTS_DIR } 12 ); 13 14 /** 15 * Test aria-current 16 */ 17 addAccessibleTask( 18 `<a id="one" href="%23" aria-current="page">One</a><a id="two" href="%23">Two</a>`, 19 async (browser, accDoc) => { 20 let one = getNativeInterface(accDoc, "one"); 21 let two = getNativeInterface(accDoc, "two"); 22 23 is( 24 one.getAttributeValue("AXARIACurrent"), 25 "page", 26 "Correct aria-current for #one" 27 ); 28 is( 29 two.getAttributeValue("AXARIACurrent"), 30 null, 31 "Correct aria-current for #two" 32 ); 33 34 let attrChanged = waitForEvent(EVENT_OBJECT_ATTRIBUTE_CHANGED, "one"); 35 await SpecialPowers.spawn(browser, [], () => { 36 content.document 37 .getElementById("one") 38 .setAttribute("aria-current", "step"); 39 }); 40 await attrChanged; 41 42 is( 43 one.getAttributeValue("AXARIACurrent"), 44 "step", 45 "Correct aria-current for #one" 46 ); 47 48 let stateChanged = waitForEvent(EVENT_STATE_CHANGE, "one"); 49 await SpecialPowers.spawn(browser, [], () => { 50 content.document.getElementById("one").removeAttribute("aria-current"); 51 }); 52 await stateChanged; 53 54 is( 55 one.getAttributeValue("AXARIACurrent"), 56 null, 57 "Correct aria-current for #one" 58 ); 59 } 60 );