browser_combobox.js (2951B)
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 async function testComboBox(browser, accDoc) { 8 const box = getNativeInterface(accDoc, "box"); 9 is(box.getAttributeValue("AXRole"), "AXComboBox"); 10 is(box.getAttributeValue("AXValue"), "peach", "Initial value correct"); 11 12 let expandedChanged = waitForMacEvent("AXExpandedChanged", "box"); 13 let didBoxValueChange = false; 14 waitForMacEvent("AXValueChanged", "box").then(() => { 15 didBoxValueChange = true; 16 }); 17 await invokeContentTask(browser, [], () => { 18 const b = content.document.getElementById("box"); 19 b.ariaExpanded = true; 20 }); 21 22 await expandedChanged; 23 24 ok(!didBoxValueChange, "Value of combobox did not change when it was opened"); 25 is(box.getAttributeValue("AXValue"), "peach", "After popup value correct"); 26 } 27 28 addAccessibleTask( 29 ` 30 <style> 31 #box[aria-expanded=false] > ul { 32 visibility: hidden; 33 } 34 </style> 35 <div role="combobox" id="box" aria-expanded="false" aria-haspopup="listbox"> 36 <input id="input" value="peach" aria-autocomplete="list" aria-controls="controlled_listbox"> 37 <ul role="listbox" id="controlled_listbox"> 38 <li role="option">apple</li> 39 <li role="option">peach</li> 40 </ul> 41 </div>`, 42 async (browser, accDoc) => { 43 info("Test ARIA 1.1 style combobox (role on container of entry and list)"); 44 await testComboBox(browser, accDoc); 45 } 46 ); 47 48 addAccessibleTask( 49 ` 50 <style> 51 #box[aria-expanded=false] + ul { 52 visibility: hidden; 53 } 54 </style> 55 <input type="text" id="box" role="combobox" value="peach" 56 aria-owns="owned_listbox" 57 aria-expanded="false" 58 aria-haspopup="listbox" 59 aria-autocomplete="list" > 60 <ul role="listbox" id="owned_listbox"> 61 <li role="option">apple</li> 62 <li role="option">peach</li> 63 </ul> 64 `, 65 async (browser, accDoc) => { 66 info("Test ARIA 1.0 style combobox (entry aria-owns list)"); 67 68 const box = getNativeInterface(accDoc, "box"); 69 is( 70 box.getAttributeValue("AXChildren").length, 71 1, 72 "owned list is not relocated" 73 ); 74 75 await testComboBox(browser, accDoc); 76 77 is(box.getAttributeValue("AXARIAControls").length, 1, "box controls list"); 78 } 79 ); 80 81 addAccessibleTask( 82 ` 83 <style> 84 #box[aria-expanded=false] + ul { 85 visibility: hidden; 86 } 87 </style> 88 <input type="text" id="box" role="combobox" value="peach" 89 aria-controls="controlled_listbox" 90 aria-expanded="false" 91 aria-haspopup="listbox" 92 aria-autocomplete="list" > 93 <ul role="listbox" id="controlled_listbox"> 94 <li role="option">apple</li> 95 <li role="option">peach</li> 96 </ul> 97 `, 98 async (browser, accDoc) => { 99 info("Test ARIA 1.2 style combobox (entry aria-controls list)"); 100 await testComboBox(browser, accDoc); 101 } 102 );