Skip to content

Commit

Permalink
add test cases #1675
Browse files Browse the repository at this point in the history
  • Loading branch information
shunguoy committed Nov 3, 2023
1 parent c4cfab9 commit 92bcaff
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export let draggable_alternative_exists: Rule = {
},
messages: {
"en-US": {
"group": "When an element receives focus, it is not entirely covered by other content",
"pass": "The element is not entirely covered by other content",
"potential_obscured": "Confirm that when the element receives focus, it is not covered or, if covered by user action, can be uncovered without moving focus"
"group": "A draggable element must have a \"single pointer\" alternative",
"pass_alternative": "The draggable element \"{0}\" has a \"single pointer\" alternative",
"pass_undraggable": "The element \"{0}\" is not draggable",
"potential_alternative": "Ensure the draggable element \"{0}\" has a \"single pointer\" alternative"
}
},
rulesets: [{
Expand All @@ -57,14 +58,9 @@ export let draggable_alternative_exists: Rule = {

//in case the bounds not available
if (ruleContext.getAttribute("draggable") === 'true')
if (ruleContext.hasAttribute("ondragstart"))
return RulePotential("potential_alternative", [nodeName]);
else
return RulePotential("potential_draggable", [nodeName]);

return RulePotential("potential_alternative", [nodeName]);
else if (ruleContext.getAttribute("draggable") === 'false')
return RulePass("pass_undraggable", [nodeName]);

else
return null;
}
Expand Down
1 change: 1 addition & 0 deletions accessibility-checker-engine/src/v4/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export * from "./debug_paths"
export * from "./detector_tabbable"
export * from "./dir_attribute_valid"
export * from "./download_keyboard_controllable"
export * from "./draggable_alternative_exists"
export * from "./element_accesskey_labelled"
export * from "./element_accesskey_unique"
export * from "./element_attribute_deprecated"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,53 @@

<body>

<p draggable="true">This text <strong>may</strong> be dragged.</p>
<p>no draggable defined: This text <strong>may</strong> be dragged by selection.</p>

<p draggable="false">draggable false: This text <strong>may</strong> be selected and dragged.</p>

<p draggable="">draggable undefined:This text <strong>may</strong> be selected and dragged.</p>

<p draggable="true">draggable true: This text <strong>may</strong> be dragged.</p>

<img id="drag1" src="https://ibm.com/able/favicon-32x32.png" alt=""/>

<script>
UnitTest = {
ruleIds: ["draggable_alternative_exists"],
results: [
{
"ruleId": "element_tabbable_unobscured",
"ruleId": "draggable_alternative_exists",
"value": [
"INFORMATION",
"POTENTIAL"
"PASS"
],
"path": {
"dom": "/html[1]/body[1]/div[1]",
"aria": "/document[1]"
"dom": "/html[1]/body[1]/p[2]",
"aria": "/document[1]/paragraph[2]"
},
"reasonId": "potential_obscured",
"message": "Confirm that when the element receives focus, it is not covered or, if covered by user action, can be uncovered without moving focus",
"messageArgs": [],
"reasonId": "pass_undraggable",
"message": "The element \"p\" is not draggable",
"messageArgs": [
"p"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "element_tabbable_unobscured",
"ruleId": "draggable_alternative_exists",
"value": [
"INFORMATION",
"PASS"
"POTENTIAL"
],
"path": {
"dom": "/html[1]/body[1]/div[2]",
"aria": "/document[1]"
"dom": "/html[1]/body[1]/p[4]",
"aria": "/document[1]/paragraph[4]"
},
"reasonId": "pass",
"message": "The element is not entirely covered by other content",
"messageArgs": [],
"reasonId": "potential_alternative",
"message": "Ensure the draggable element \"p\" has a \"single pointer\" alternative",
"messageArgs": [
"p"
],
"apiArgs": [],
"category": "Accessibility"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--
/******************************************************************************
Copyright:: 2020- IBM, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*****************************************************************************/
-->

<html lang="en">

<head>
<title>RPT Test Suite</title>
<style>
.div {
width: 55px;
height: 35px;
padding: 10px;
border: 1px solid #aaaaaa;
display: inline-block;
text-align: center;
}
</style>
<script>
function dragover(ev) {
ev.preventDefault();
}

function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}

function move(ev) {
ev.preventDefault();
document.getElementById('div1').innerHTML = '';

let div2 = document.getElementById('div2');
let img = document.createElement('img');
img.src = 'https://ibm.com/able/favicon-32x32.png';
img.width = 32;
img.height = 32;
div2.innerHTML = '';
div2.appendChild(img);


}

</script>
</head>

<body>

<p>Drag or move the image into the rectangle:</p>

<div id='div2' class="div" ondrop="drop(event)" ondragover="dragover(event)"></div>
<div class="div" style="border: 0px;"><button id="button1" onclick="move(event)" style="width:45px; height: 25px;">Move</button></div>

<br>
<div id="div1"><img id="drag1" src="https://ibm.com/able/favicon-32x32.png" draggable="true" ondragstart="drag(event)" width="32" height="32"></div>

<script>
UnitTest = {
ruleIds: ["draggable_alternative_exists"],
results: [
{
"ruleId": "draggable_alternative_exists",
"value": [
"INFORMATION",
"POTENTIAL"
],
"path": {
"dom": "/html[1]/body[1]/div[3]/img[1]",
"aria": "/document[1]/img[1]"
},
"reasonId": "potential_alternative",
"message": "Ensure the draggable element \"img\" has a \"single pointer\" alternative",
"messageArgs": [
"img"
],
"apiArgs": [],
"category": "Accessibility"
}
]
}
</script>
</body>

</html>

This file was deleted.

0 comments on commit 92bcaff

Please sign in to comment.