/* 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/. */
function getSelectedIds(selectable) { return selectable
.getAttributeValue("AXSelectedChildren")
.map(c => c.getAttributeValue("AXDOMIdentifier"));
}
/** * Test aria tabs
*/
addAccessibleTask("mac/doc_aria_tabs.html", async (browser, accDoc) => {
let tablist = getNativeInterface(accDoc, "tablist");
is(
tablist.getAttributeValue("AXRole"), "AXTabGroup", "Correct role for tablist"
);
let tabMacAccs = tablist.getAttributeValue("AXTabs");
is(tabMacAccs.length, 3, "3 items in AXTabs");
let selectedTabs = tablist.getAttributeValue("AXSelectedChildren");
is(selectedTabs.length, 1, "one selected tab");
let tab = selectedTabs[0];
is(tab.getAttributeValue("AXRole"), "AXRadioButton", "Correct role for tab");
is(
tab.getAttributeValue("AXSubrole"), "AXTabButton", "Correct subrole for tab"
);
is(tab.getAttributeValue("AXTitle"), "First Tab", "Correct title for tab");
let tabToSelect = tabMacAccs[1];
is(
tabToSelect.getAttributeValue("AXTitle"), "Second Tab", "Correct title for tab"
);
let actions = tabToSelect.actionNames;
ok(true, actions);
ok(actions.includes("AXPress"), "Has switch action");
let evt = waitForMacEvent("AXSelectedChildrenChanged");
tabToSelect.performAction("AXPress");
await evt;
selectedTabs = tablist.getAttributeValue("AXSelectedChildren");
is(selectedTabs.length, 1, "one selected tab");
is(
selectedTabs[0].getAttributeValue("AXTitle"), "Second Tab", "Correct title for tab"
);
});
addAccessibleTask('
hello
', async (browser, accDoc) => {
let p = getNativeInterface(accDoc, "p");
ok(
p.attributeNames.includes("AXSelected"), "html element includes 'AXSelected' attribute"
);
is(p.getAttributeValue("AXSelected"), 0, "AX selected is 'false'");
});
addAccessibleTask(
`<select id="select" aria-label="Choose a number" multiple>
<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) => {
let select = getNativeInterface(accDoc, "select");
let one = getNativeInterface(accDoc, "one");
let two = getNativeInterface(accDoc, "two");
let three = getNativeInterface(accDoc, "three");
let four = getNativeInterface(accDoc, "four");
is(
select.getAttributeValue("AXTitle"), "Choose a number", "Select titled correctly"
);
ok(
select.attributeNames.includes("AXOrientation"), "Have orientation attribute"
);
ok(
select.isAttributeSettable("AXSelectedChildren"), "Select can have AXSelectedChildren set"
);
is(one.getAttributeValue("AXTitle"), "", "Option should not have a title");
is(
one.getAttributeValue("AXValue"), "One", "Option should have correct value"
);
is(
one.getAttributeValue("AXRole"), "AXStaticText", "Options should have AXStaticText role"
);
ok(one.isAttributeSettable("AXSelected"), "Option can have AXSelected set");
let allspice = getNativeInterface(accDoc, "allspice");
is(
allspice.getAttributeValue("AXTitle"), "", "Option should not have a title"
);
is(
allspice.getAttributeValue("AXValue"), "Allspice", "Option should have a value"
);
is(
allspice.getAttributeValue("AXRole"), "AXStaticText", "Options should have AXStaticText role"
);
ok(
allspice.isAttributeSettable("AXSelected"), "Option can have AXSelected set"
);
is(
allspice
.getAttributeValue("AXParent")
.getAttributeValue("AXDOMIdentifier"), "select", "Select is direct parent of nested option"
);
let groupLabel = select.getAttributeValue("AXChildren")[1];
ok(
!groupLabel.isAttributeSettable("AXSelected"), "Group label should not be selectable"
);
is(
groupLabel.getAttributeValue("AXValue"), "Fruits", "Group label should have a value"
);
is(
groupLabel.getAttributeValue("AXTitle"), null, "Group label should not have a title"
);
is(
groupLabel.getAttributeValue("AXRole"), "AXStaticText", "Group label should have AXStaticText role"
);
is(
groupLabel
.getAttributeValue("AXParent")
.getAttributeValue("AXDOMIdentifier"), "select", "Select is direct parent of group label"
);
addAccessibleTask(
`<div role="listbox" id="select" aria-label="Choose a number" aria-multiselectable="true">
<div role="option" id="one" aria-selected="true">One</div>
<div role="option" id="two">Two</div>
<div role="option" id="three">Three</div>
<div role="option" id="four" aria-disabled="true">Four</div>
</div>`,
async (browser, accDoc) => {
let select = getNativeInterface(accDoc, "select");
let one = getNativeInterface(accDoc, "one");
is(
select.getAttributeValue("AXTitle"), "Choose a number", "Select titled correctly"
);
ok(
select.attributeNames.includes("AXOrientation"), "Have orientation attribute"
);
ok(
select.isAttributeSettable("AXSelectedChildren"), "Select can have AXSelectedChildren set"
);
is(one.getAttributeValue("AXTitle"), "", "Option should not have a title");
is(
one.getAttributeValue("AXValue"), "One", "Option should have correct value"
);
is(
one.getAttributeValue("AXRole"), "AXStaticText", "Options should have AXStaticText role"
);
ok(one.isAttributeSettable("AXSelected"), "Option can have AXSelected set");
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.