/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Test dropdown select element
addAccessibleTask(
`<select id="select" aria-label="Choose a number">
<option id="one" selected>One</option>
<option id="two">Two</option>
<option id="three">Three</option>
<option id="four" disabled>Four</option>
</select>`,
async (browser, accDoc) => { // Test combobox
let select = getNativeInterface(accDoc, "select");
is(
select.getAttributeValue("AXRole"), "AXPopUpButton", "select has AXPopupButton role"
);
ok(select.attributeNames.includes("AXValue"), "select advertises AXValue");
is(
select.getAttributeValue("AXValue"), "One", "select has correctt initial value"
);
ok(
!select.attributeNames.includes("AXHasPopup"), "select does not advertise AXHasPopup"
);
is(
select.getAttributeValue("AXHasPopup"), null, "select does not provide value for AXHasPopup"
);
ok(select.actionNames.includes("AXPress"), "Selectt has press action"); // These four events happen in quick succession when select is pressed
let events = Promise.all([
waitForMacEvent("AXMenuOpened"),
waitForMacEvent("AXSelectedChildrenChanged"),
waitForMacEvent( "AXFocusedUIElementChanged",
e => e.getAttributeValue("AXRole") == "AXPopUpButton"
),
waitForMacEvent( "AXFocusedUIElementChanged",
e => e.getAttributeValue("AXRole") == "AXMenuItem"
),
]);
select.performAction("AXPress"); // Only capture the target of AXMenuOpened (first element)
let [menu] = await events;
is(menu.getAttributeValue("AXRole"), "AXMenu", "dropdown has AXMenu role");
is(
menu.getAttributeValue("AXSelectedChildren").length, 1, "dropdown has single selected child"
);
let selectedChildren = menu.getAttributeValue("AXSelectedChildren");
is(selectedChildren.length, 1, "Only one child is selected");
is(selectedChildren[0].getAttributeValue("AXRole"), "AXMenuItem");
is(selectedChildren[0].getAttributeValue("AXTitle"), "One");
let menuParent = menu.getAttributeValue("AXParent");
is(
menuParent.getAttributeValue("AXRole"), "AXPopUpButton", "dropdown parent is a popup button"
);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.