Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
/* Any copyright is dedicated to the Public Domain.
"use strict";
/* import-globals-from ../../mochitest/role.js */
loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
ChromeUtils.defineESModuleGetters(this, {
CustomizableUITestUtils:
});
let searchbar;
add_setup(async function () {
SearchbarTestUtils.init(this);
SearchTestUtils.init(this);
// The default engine's suggestions would require network access.
await SearchTestUtils.updateRemoteSettingsConfig([{ identifier: "engine1" }]);
let gCUITestUtils = new CustomizableUITestUtils(window);
searchbar = await gCUITestUtils.addSearchBar();
registerCleanupFunction(() => gCUITestUtils.removeSearchBar());
});
// eslint-disable-next-line camelcase
add_task(async function test_searchbar_a11y_tree() {
testAccessibleTree(searchbar, {
role: ROLE_GROUPING,
children: [
// input container
{
role: ROLE_SECTION,
children: [
// search mode switcher
{
role: ROLE_EDITCOMBOBOX,
// not testing the structure inside the switcher
},
// input element
{
role: ROLE_EDITCOMBOBOX,
children: [],
},
// context menu
{
role: ROLE_MENUPOPUP,
children: [],
},
// The go button is hidden and the result list is empty, so neither
// shows up in the tree.
],
},
],
});
});
// eslint-disable-next-line camelcase
add_task(async function test_searchbar_a11y_tree_with_results() {
await SearchbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "example",
});
Assert.equal(
SearchbarTestUtils.getResultCount(window),
1,
"Expected a single result"
);
testAccessibleTree(searchbar, {
role: ROLE_GROUPING,
children: [
// The background becomes visible while the result list is open.
{
role: ROLE_SECTION,
children: [],
},
// input container
{
role: ROLE_SECTION,
children: [
// search mode switcher
{
role: ROLE_EDITCOMBOBOX,
// not testing the structure inside the switcher
},
// input element
{
role: ROLE_EDITCOMBOBOX,
children: [
{
role: ROLE_TEXT_LEAF,
name: "example",
children: [],
},
],
},
// context menu
{
role: ROLE_MENUPOPUP,
children: [],
},
// go button
{
role: ROLE_PUSHBUTTON,
children: [],
},
],
},
// result view
{
role: ROLE_GROUPING,
children: [
// result list
{
role: ROLE_LISTBOX,
children: [
{
role: ROLE_OPTION,
// not testing the structure inside the result
},
],
},
],
},
],
});
await SearchbarTestUtils.promisePopupClose(window);
searchbar.handleRevert();
});