/* 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/. */ "use strict"; requestLongerTimeout(2); /** * A test specification that has the following format: * [ * attr relevant aria attribute * hostRelation corresponding host relation type * dependantRelation corresponding dependant relation type * ] */ const attrRelationsSpec = [ ["aria-labelledby", RELATION_LABELLED_BY, RELATION_LABEL_FOR], ["aria-describedby", RELATION_DESCRIBED_BY, RELATION_DESCRIPTION_FOR], ["aria-controls", RELATION_CONTROLLER_FOR, RELATION_CONTROLLED_BY], ["aria-flowto", RELATION_FLOWS_TO, RELATION_FLOWS_FROM], ["aria-details", RELATION_DETAILS, RELATION_DETAILS_FOR], ["aria-errormessage", RELATION_ERRORMSG, RELATION_ERRORMSG_FOR], ["aria-actions", RELATION_ACTION, RELATION_ACTION_FOR], ]; /** * Test caching of relations between accessible objects. */ addAccessibleTask( `
label
label2
`, async function (browser, accDoc) { for (let spec of attrRelationsSpec) { await testRelated(browser, accDoc, ...spec); } }, { iframe: true, remoteIframe: true } ); /** * Test caching of relations with respect to label objects and their "for" attr. */ addAccessibleTask( ` `, async function (browser, accDoc) { const host = findAccessibleChildByID(accDoc, "host"); const dependant = findAccessibleChildByID(accDoc, "dependant"); async function testLabel(hasLabel) { await testCachedRelation( host, RELATION_LABEL_FOR, hasLabel ? dependant : [] ); await testCachedRelation( dependant, RELATION_LABELLED_BY, hasLabel ? host : [] ); } await testLabel(false); await invokeSetAttribute(browser, "host", "for", "dependant"); await testLabel(true); await invokeSetAttribute(browser, "dependant", "id", "invalid"); await testLabel(false); }, { chrome: true, iframe: true, remoteIframe: true } ); /** * Test rel caching for element with existing relation attribute. */ addAccessibleTask( `
label