/* 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 different HTML elements for their roles and subroles
*/ function testRoleAndSubRole(accDoc, id, axRole, axSubRole, axRoleDescription) {
let el = getNativeInterface(accDoc, id); if (axRole) {
is(
el.getAttributeValue("AXRole"),
axRole, "AXRole for " + id + " is " + axRole
);
} if (axSubRole) {
is(
el.getAttributeValue("AXSubrole"),
axSubRole, "Subrole for " + id + " is " + axSubRole
);
} if (axRoleDescription) {
is(
el.getAttributeValue("AXRoleDescription"),
axRoleDescription, "Subrole for " + id + " is " + axRoleDescription
);
}
}
// DPub roles map into two categories, sample one of each
testRoleAndSubRole(
accDoc, "dPubNavigation", "AXGroup", "AXLandmarkNavigation"
);
testRoleAndSubRole(accDoc, "dPubRegion", "AXGroup", "AXLandmarkRegion");
// ARIA widget roles
testRoleAndSubRole(accDoc, "alert", null, "AXApplicationAlert");
testRoleAndSubRole(
accDoc, "alertdialog", "AXGroup", "AXApplicationAlertDialog", "alert dialog"
);
testRoleAndSubRole(accDoc, "article", null, "AXDocumentArticle");
testRoleAndSubRole(accDoc, "code", "AXGroup", "AXCodeStyleGroup");
testRoleAndSubRole(accDoc, "dialog", null, "AXApplicationDialog", "dialog");
testRoleAndSubRole(accDoc, "ariaDocument", null, "AXDocument");
testRoleAndSubRole(accDoc, "log", null, "AXApplicationLog");
testRoleAndSubRole(accDoc, "marquee", null, "AXApplicationMarquee");
testRoleAndSubRole(accDoc, "ariaMath", null, "AXDocumentMath");
testRoleAndSubRole(accDoc, "note", null, "AXDocumentNote");
testRoleAndSubRole(accDoc, "ariaRegion", null, "AXLandmarkRegion");
testRoleAndSubRole(accDoc, "ariaStatus", "AXGroup", "AXApplicationStatus");
testRoleAndSubRole(accDoc, "switch", "AXCheckBox", "AXSwitch");
testRoleAndSubRole(accDoc, "timer", null, "AXApplicationTimer");
testRoleAndSubRole(accDoc, "tooltip", "AXGroup", "AXUserInterfaceTooltip");
testRoleAndSubRole(accDoc, "menuitemradio", "AXMenuItem", null);
testRoleAndSubRole(accDoc, "menuitemcheckbox", "AXMenuItem", null);
testRoleAndSubRole(accDoc, "datetime", "AXGroup", null); // XXX for datetime elements, we spoof the role via the title, since // providing the correct role results in the internal elements being // unreachable by VO
is(
getNativeInterface(accDoc, "datetime").getAttributeValue("AXTitle"), "date field"
);
addAccessibleTask(
`
<figure id="figure">
<img id="img" src="http://example.com/a11y/accessible/tests/mochitest/moz.png" alt="Logo">
<p>Non-image figure content</p>
<figcaption id="figcaption">Old Mozilla logo</figcaption>
</figure>`,
(browser, accDoc) => {
let figure = getNativeInterface(accDoc, "figure");
ok(!figure.getAttributeValue("AXTitle"), "Figure should not have a title");
is(
figure.getAttributeValue("AXDescription"), "Old Mozilla logo", "Correct figure label"
);
is(figure.getAttributeValue("AXRole"), "AXGroup", "Correct figure role");
is(
figure.getAttributeValue("AXRoleDescription"), "figure", "Correct figure role description"
);
let img = getNativeInterface(accDoc, "img");
ok(!img.getAttributeValue("AXTitle"), "img should not have a title");
is(img.getAttributeValue("AXDescription"), "Logo", "Correct img label");
is(img.getAttributeValue("AXRole"), "AXImage", "Correct img role");
is(
img.getAttributeValue("AXRoleDescription"), "image", "Correct img role description"
);
let figcaption = getNativeInterface(accDoc, "figcaption");
ok(
!figcaption.getAttributeValue("AXTitle"), "figcaption should not have a title"
);
ok(
!figcaption.getAttributeValue("AXDescription"), "figcaption should not have a label"
);
is(
figcaption.getAttributeValue("AXRole"), "AXGroup", "Correct figcaption role"
);
is(
figcaption.getAttributeValue("AXRoleDescription"), "group", "Correct figcaption role description"
);
}
);
is(
webArea.getAttributeValue("AXRole"), "AXWebArea", "web area should be an AXWebArea"
);
ok(
!webArea.attributeNames.includes("AXSubrole"), "AXWebArea should not have a subrole"
);
is(
webArea.getAttributeValue("AXRole"), "AXWebArea", "web area should retain AXWebArea role"
);
ok(
!webArea.attributeNames.includes("AXSubrole"), "AXWebArea should not have a subrole"
);
let rootGroup = webArea.getAttributeValue("AXChildren")[0];
is(rootGroup.getAttributeValue("AXRole"), "AXGroup");
is(rootGroup.getAttributeValue("AXSubrole"), "AXLandmarkApplication");
});
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
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.