Skip to content

Commit

Permalink
fix the existing test cases for miss-types #1676
Browse files Browse the repository at this point in the history
  • Loading branch information
shunguoy committed Oct 6, 2023
1 parent 6b202a6 commit 01dd83e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<title>RPT Test Suite</title>
</head>

<body">
<body>

<a href="#navskip">skip to main content</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<title>RPT Test Suite</title>
</head>

<body">
<body>

<a href="#navskip">skip to main content</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<title>RPT Test Suite</title>
</head>

<body">
<body>

<a href="#navskip">skip to main content</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@
padding:2rem;
position:relative;
width:calc(100vw - 1rem);
z-index: 1
}

@media (min-width:70rem), (min-height:60rem) {
.fixed-position-banner {
margin-block-end:0;
position:fixed;
z-index: 1
}
}

Expand All @@ -67,6 +69,7 @@
background-color: lightgray;
color: black;
text-align: center;
z-index: 10
}
</style>
</head>
Expand Down

0 comments on commit 01dd83e

Please sign in to comment.