browser_focus.js (1170B)
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 * Test focusability 9 */ 10 addAccessibleTask( 11 ` 12 <div role="button" id="ariabutton">hello</div> <button id="button">world</button> 13 `, 14 async (browser, accDoc) => { 15 let ariabutton = getNativeInterface(accDoc, "ariabutton"); 16 let button = getNativeInterface(accDoc, "button"); 17 18 is( 19 ariabutton.getAttributeValue("AXFocused"), 20 0, 21 "aria button is not focused" 22 ); 23 24 is(button.getAttributeValue("AXFocused"), 0, "button is not focused"); 25 26 ok( 27 !ariabutton.isAttributeSettable("AXFocused"), 28 "aria button should not be focusable" 29 ); 30 31 ok(button.isAttributeSettable("AXFocused"), "button is focusable"); 32 33 let evt = waitForMacEvent( 34 "AXFocusedUIElementChanged", 35 iface => iface.getAttributeValue("AXDOMIdentifier") == "button" 36 ); 37 38 button.setAttributeValue("AXFocused", true); 39 40 await evt; 41 42 is(button.getAttributeValue("AXFocused"), 1, "button is focused"); 43 } 44 );