browser_searchbar.js (2136B)
1 "use strict"; 2 3 /* import-globals-from ../../mochitest/role.js */ 4 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); 5 6 const { CustomizableUITestUtils } = ChromeUtils.importESModule( 7 "resource://testing-common/CustomizableUITestUtils.sys.mjs" 8 ); 9 let gCUITestUtils = new CustomizableUITestUtils(window); 10 11 add_setup(async function () { 12 await SpecialPowers.pushPrefEnv({ 13 set: [["browser.search.widget.new", false]], 14 }); 15 }); 16 17 // eslint-disable-next-line camelcase 18 add_task(async function test_searchbar_a11y_tree() { 19 let searchbar = await gCUITestUtils.addSearchBar(); 20 21 // Make sure the popup has been rendered so it shows up in the a11y tree. 22 let popup = document.getElementById("PopupSearchAutoComplete"); 23 let promise = Promise.all([ 24 BrowserTestUtils.waitForEvent(popup, "popupshown", false), 25 waitForEvent(EVENT_SHOW, popup), 26 ]); 27 searchbar.textbox.openPopup(); 28 await promise; 29 30 let TREE = { 31 role: ROLE_EDITCOMBOBOX, 32 33 children: [ 34 // image button toggling the results list 35 { 36 role: ROLE_BUTTONMENU, 37 children: [], 38 }, 39 40 // input element 41 { 42 role: ROLE_SEARCHBOX, 43 children: [], 44 }, 45 46 // context menu 47 { 48 role: ROLE_COMBOBOX_LIST, 49 children: [], 50 }, 51 52 // result list 53 { 54 role: ROLE_GROUPING, 55 // not testing the structure inside the result list 56 }, 57 ], 58 }; 59 60 testAccessibleTree(searchbar, TREE); 61 62 promise = Promise.all([ 63 BrowserTestUtils.waitForEvent(popup, "popuphidden", false), 64 waitForEvent(EVENT_HIDE, popup), 65 ]); 66 searchbar.textbox.closePopup(); 67 await promise; 68 69 TREE = { 70 role: ROLE_EDITCOMBOBOX, 71 72 children: [ 73 // image button toggling the results list 74 { 75 role: ROLE_BUTTONMENU, 76 children: [], 77 }, 78 79 // input element 80 { 81 role: ROLE_SEARCHBOX, 82 children: [], 83 }, 84 85 // context menu 86 { 87 role: ROLE_COMBOBOX_LIST, 88 children: [], 89 }, 90 91 // the result list should be removed from the tree on popuphidden 92 ], 93 }; 94 95 testAccessibleTree(searchbar, TREE); 96 });