Bug 1594743 - ensure that the keyboard audit does not interfere with other audit types. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D52378

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Yura Zenevich 2019-11-12 15:05:42 +00:00
Родитель 649925ecff
Коммит dabe0349ce
1 изменённых файлов: 31 добавлений и 6 удалений

Просмотреть файл

@ -526,12 +526,37 @@ const AccessibleActor = ActorClassWithSpec(accessibleSpec, {
auditTypes = auditTypes.filter(auditType => types.includes(auditType));
}
// More audit steps will be added here in the near future. In addition to
// colour contrast ratio we will add autits for to the missing names,
// invalid states, etc. (For example see bug 1518808).
this._auditing = Promise.all(
auditTypes.map(auditType => this._getAuditByType(auditType))
)
// For some reason keyboard checks for focus styling affect values (that are
// used by other types of checks (text names and values)) returned by
// accessible objects. This happens only when multiple checks are run at the
// same time (asynchronously) and the audit might return unexpected
// failures. We thus split the execution of the checks into two parts, first
// performing keyboard checks and only after the rest of the checks. See bug
// 1594743 for more detail.
let keyboardAuditResult;
const keyboardAuditIndex = auditTypes.indexOf(AUDIT_TYPE.KEYBOARD);
if (keyboardAuditIndex > -1) {
// If we are performing a keyboard audit, remove its value from the
// complete list and run it.
auditTypes.splice(keyboardAuditIndex, 1);
keyboardAuditResult = this._getAuditByType(AUDIT_TYPE.KEYBOARD);
}
this._auditing = Promise.resolve(keyboardAuditResult)
.then(keyboardResult => {
const audits = auditTypes.map(auditType =>
this._getAuditByType(auditType)
);
// If we are also performing a keyboard audit, add its type and its
// result back to the complete list of audits.
if (keyboardAuditIndex > -1) {
auditTypes.splice(keyboardAuditIndex, 0, AUDIT_TYPE.KEYBOARD);
audits.splice(keyboardAuditIndex, 0, keyboardResult);
}
return Promise.all(audits);
})
.then(results => {
if (this.isDefunct || this.isDestroyed) {
return null;