browser_description.js (2644B)
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 aria-describedby 9 */ 10 addAccessibleTask( 11 `<div id="hint">This is a hint</div><button id="btn" aria-describedby="hint">Hello</button>`, 12 async (browser, accDoc) => { 13 let btn = getNativeInterface(accDoc, "btn"); 14 let customContent = btn.getAttributeValue("AXCustomContent"); 15 is(customContent[0].description, "This is a hint"); 16 ok(!btn.getAttributeValue("AXHelp"), "No AXHelp expected"); 17 }, 18 { chrome: true, topLevel: true } 19 ); 20 21 /** 22 * Test aria-description 23 */ 24 addAccessibleTask( 25 `<button id="btn" aria-description="This is a hint too">Hello</button>`, 26 async (browser, accDoc) => { 27 let btn = getNativeInterface(accDoc, "btn"); 28 let customContent = btn.getAttributeValue("AXCustomContent"); 29 is(customContent[0].description, "This is a hint too"); 30 ok(!btn.getAttributeValue("AXHelp"), "No AXHelp expected"); 31 }, 32 { chrome: true, topLevel: true } 33 ); 34 35 /** 36 * Test link title 37 */ 38 addAccessibleTask( 39 `<a href="#" id="lnk" title="This is a link title">Hello</button>`, 40 async (browser, accDoc) => { 41 let lnk = getNativeInterface(accDoc, "lnk"); 42 is(lnk.getAttributeValue("AXHelp"), "This is a link title"); 43 ok(!lnk.getAttributeValue("AXCustomContent"), "No custom content expected"); 44 }, 45 { chrome: true, topLevel: true } 46 ); 47 48 /** 49 * Test AXHelp on fieldset and radio group 50 */ 51 addAccessibleTask( 52 ` 53 <fieldset id="fieldset" aria-describedby="testHint"> 54 <button>Button</button> 55 </fieldset> 56 57 <div id="radiogroup" role="radiogroup" aria-describedby="testHint"> 58 <input type="radio" id="radio1" name="group" value="1"> 59 <label for="radio1">Radio 1</label> 60 <input type="radio" id="radio2" name="group" value="2"> 61 <label for="radio2">Radio 2</label> 62 </div> 63 64 <div id="testHint"> 65 This is a hinto 66 </div> 67 `, 68 async (browser, accDoc) => { 69 let getHelp = id => 70 getNativeInterface(accDoc, id).getAttributeValue("AXHelp"); 71 let getCustomDescription = id => 72 getNativeInterface(accDoc, id).getAttributeValue("AXCustomContent")[0] 73 .description; 74 75 is(getHelp("fieldset"), "This is a hinto", "AXHelp for fieldset"); 76 is( 77 getCustomDescription("fieldset"), 78 "This is a hinto", 79 "Custom description for fieldset" 80 ); 81 82 is(getHelp("radiogroup"), "This is a hinto", "AXHelp for radiogroup"); 83 is( 84 getCustomDescription("radiogroup"), 85 "This is a hinto", 86 "Custom description for radiogroup" 87 ); 88 } 89 );