diff --git a/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts b/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts index 05ecdd60d..2c22e9add 100644 --- a/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts +++ b/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts @@ -1378,7 +1378,8 @@ export class RPTUtil { let ancestors = []; let walkNode = DOMWalker.parentNode(element); while (walkNode !== null) { - ancestors.push(walkNode.nodeName.toLowerCase()); + if (walkNode.nodeType === 1) + ancestors.push(walkNode.nodeName.toLowerCase()); walkNode = DOMWalker.parentNode(walkNode); } return ancestors; diff --git a/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts b/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts index 135489f98..3203428f5 100644 --- a/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts +++ b/accessibility-checker-engine/src/v4/rules/element_tabbable_unobscured.ts @@ -63,14 +63,32 @@ export let element_tabbable_unobscured: Rule = { if (bounds['height'] === 0 || bounds['width'] === 0 ) return null; + var doc = ruleContext.ownerDocument; + if (!doc) { + return null; + } + var win = doc.defaultView; + if (!win) { + return null; + } + + var cStyle = win.getComputedStyle(ruleContext); + if (cStyle === null) + return null; + + let zindex = cStyle.zIndex; + if (!zindex || zindex === 'auto') + zindex = "0"; + const ancestors = RPTUtil.getAncestorNames(ruleContext); let ignoreList = nodeName +' *, ' + nodeName +', script'; if (ancestors) { ancestors.forEach(ancestor=> { - ignoreList += ", " + ancestor; + if (!["html", "body"].includes(ancestor)) + ignoreList += ", " + ancestor; }); } - var elems = ruleContext.ownerDocument.querySelectorAll('body *:not(' + ignoreList +')'); console.log("select target=" + nodeName + ", elems="+elems.length); + var elems = doc.querySelectorAll('body *:not(' + ignoreList +')'); if (!elems || elems.length == 0) return; @@ -79,12 +97,18 @@ export let element_tabbable_unobscured: Rule = { elems.forEach(elem => { // Skip hidden if (VisUtil.isNodeVisible(elem)) { - const bnds = mapper.getBounds(elem); console.log("target=" + nodeName + ", current=" + elem.nodeName + ", bounds=" + JSON.stringify(bounds) +", bnds=" + JSON.stringify(bnds)); + const bnds = mapper.getBounds(elem); + var zStyle = win.getComputedStyle(elem); + let z_index = "0"; + if (zStyle !== null) { + z_index = zStyle.zIndex; + if (!z_index || z_index === 'auto') + z_index = "0"; + } if (bnds.height !== 0 && bnds.width !== 0 && bnds.top <= bounds.top && bnds.left <= bounds.left && bnds.top + bnds.height >= bounds.top + bounds.height - && bnds.left + bnds.height >= bounds.left + bounds.width) { - violations.push(elem); console.log("hit target=" + nodeName + ", current=" + elem.nodeName + ", bounds=" + JSON.stringify(bounds) +", bnds=" + JSON.stringify(bnds)); - } + && bnds.left + bnds.height >= bounds.left + bounds.width && parseInt(zindex) <= parseInt(z_index)) + violations.push(elem); } }); diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_attribute_value_valid_ruleunit/validAriaPropertyValue.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_attribute_value_valid_ruleunit/validAriaPropertyValue.html index 564f50cfa..d0862236e 100755 --- a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_attribute_value_valid_ruleunit/validAriaPropertyValue.html +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_attribute_value_valid_ruleunit/validAriaPropertyValue.html @@ -22,7 +22,7 @@