browser_aria_expanded.js (1483B)
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/states.js */ 8 loadScripts({ name: "states.js", dir: MOCHITESTS_DIR }); 9 10 // Test aria-expanded on a button 11 addAccessibleTask( 12 `hello world<br> 13 <button aria-expanded="false" id="b">I am a button</button><br> 14 goodbye`, 15 async (browser, accDoc) => { 16 let button = getNativeInterface(accDoc, "b"); 17 is(button.getAttributeValue("AXExpanded"), 0, "button is not expanded"); 18 19 let stateChanged = Promise.all([ 20 waitForStateChange("b", STATE_EXPANDED, true), 21 waitForStateChange("b", STATE_COLLAPSED, false), 22 ]); 23 await SpecialPowers.spawn(browser, [], () => { 24 content.document 25 .getElementById("b") 26 .setAttribute("aria-expanded", "true"); 27 }); 28 await stateChanged; 29 is(button.getAttributeValue("AXExpanded"), 1, "button is expanded"); 30 31 stateChanged = Promise.all([ 32 waitForStateChange("b", STATE_EXPANDED, false), 33 waitForStateChange("b", EXT_STATE_EXPANDABLE, false, true), 34 ]); 35 await SpecialPowers.spawn(browser, [], () => { 36 content.document.getElementById("b").removeAttribute("aria-expanded"); 37 }); 38 await stateChanged; 39 40 ok( 41 !button.attributeNames.includes("AXExpanded"), 42 "button has no expanded attr" 43 ); 44 } 45 );