2150 |
mathias |
1 |
<html>
|
|
|
2 |
<head>
|
|
|
3 |
<title>Dijit wai unit test</title>
|
|
|
4 |
<script type="text/javascript" src="../../../dojo/dojo.js"
|
|
|
5 |
djConfig="isDebug: true"></script>
|
|
|
6 |
<script type="text/javascript">
|
|
|
7 |
dojo.require("doh.runner");
|
|
|
8 |
dojo.require("dijit.dijit");
|
|
|
9 |
|
|
|
10 |
dojo.addOnLoad(function(){
|
|
|
11 |
doh.register("dijit.tests._base.wai",
|
|
|
12 |
[
|
|
|
13 |
function getWaiRoleOnElementWithNoRole(){
|
|
|
14 |
var elem = dojo.byId("no-role-or-states");
|
|
|
15 |
doh.assertFalse(dijit.hasWaiRole(elem));
|
|
|
16 |
doh.assertEqual("", dijit.getWaiRole(elem));
|
|
|
17 |
},
|
|
|
18 |
|
|
|
19 |
function getEmptyWairoleRole(){
|
|
|
20 |
var elem = dojo.byId("empty-wairole");
|
|
|
21 |
doh.assertTrue(dijit.hasWaiRole(elem));
|
|
|
22 |
doh.assertEqual("", dijit.getWaiRole(elem));
|
|
|
23 |
},
|
|
|
24 |
|
|
|
25 |
function getWairoleRole(){
|
|
|
26 |
var elem = dojo.byId("wairole");
|
|
|
27 |
doh.assertTrue(dijit.hasWaiRole(elem));
|
|
|
28 |
doh.assertEqual("menuitem", dijit.getWaiRole(elem));
|
|
|
29 |
},
|
|
|
30 |
|
|
|
31 |
function getUnprefixedRole(){
|
|
|
32 |
var elem = dojo.byId("unprefixed-role");
|
|
|
33 |
doh.assertTrue(dijit.hasWaiRole(elem));
|
|
|
34 |
doh.assertEqual("menuitem", dijit.getWaiRole(elem));
|
|
|
35 |
},
|
|
|
36 |
|
|
|
37 |
function setWaiRole(){
|
|
|
38 |
var div = document.createElement("div");
|
|
|
39 |
dijit.setWaiRole(div, "menuitem");
|
|
|
40 |
if(dojo.isFF && dojo.isFF < 3){
|
|
|
41 |
doh.assertEqual("wairole:menuitem",
|
|
|
42 |
div.getAttribute("role"));
|
|
|
43 |
}else{
|
|
|
44 |
doh.assertEqual("menuitem",
|
|
|
45 |
div.getAttribute("role"));
|
|
|
46 |
}
|
|
|
47 |
},
|
|
|
48 |
|
|
|
49 |
function removeWaiRole(){
|
|
|
50 |
var div = document.createElement("div");
|
|
|
51 |
dijit.setWaiRole(div, "menuitem");
|
|
|
52 |
dijit.removeWaiRole(div);
|
|
|
53 |
if(div.hasAttribute){
|
|
|
54 |
doh.assertFalse(div.hasAttribute("role"));
|
|
|
55 |
}else{
|
|
|
56 |
doh.assertTrue(div.getAttribute("role") == null
|
|
|
57 |
|| div.getAttribute("role") == "");
|
|
|
58 |
}
|
|
|
59 |
},
|
|
|
60 |
|
|
|
61 |
function getWaiStateOnElementWithNoState(){
|
|
|
62 |
var elem = dojo.byId("no-role-or-states");
|
|
|
63 |
doh.assertFalse(dijit.hasWaiState(elem, "checked"));
|
|
|
64 |
doh.assertEqual("", dijit.getWaiState(elem, "checked"));
|
|
|
65 |
},
|
|
|
66 |
|
|
|
67 |
function getWaiState(){
|
|
|
68 |
if(dojo.isFF && dojo.isFF < 3){
|
|
|
69 |
var div = document.createElement("div");
|
|
|
70 |
div.setAttributeNS("http://www.w3.org/2005/07/aaa",
|
|
|
71 |
"aaa:checked", "true");
|
|
|
72 |
doh.assertTrue(dijit.hasWaiState(div, "checked"));
|
|
|
73 |
doh.assertEqual("true",
|
|
|
74 |
dijit.getWaiState(div, "checked"));
|
|
|
75 |
}else{
|
|
|
76 |
var elem = dojo.byId("checked");
|
|
|
77 |
doh.assertTrue(dijit.hasWaiState(elem, "checked"));
|
|
|
78 |
doh.assertEqual("true",
|
|
|
79 |
dijit.getWaiState(elem, "checked"));
|
|
|
80 |
}
|
|
|
81 |
},
|
|
|
82 |
|
|
|
83 |
function setWaiState(){
|
|
|
84 |
var div = document.createElement("div");
|
|
|
85 |
dijit.setWaiState(div, "checked", "true");
|
|
|
86 |
if(dojo.isFF && dojo.isFF < 3){
|
|
|
87 |
doh.assertEqual("true",
|
|
|
88 |
div.getAttributeNS("http://www.w3.org/2005/07/aaa",
|
|
|
89 |
"checked"));
|
|
|
90 |
}else{
|
|
|
91 |
doh.assertEqual("true",
|
|
|
92 |
div.getAttribute("aria-checked"));
|
|
|
93 |
}
|
|
|
94 |
},
|
|
|
95 |
|
|
|
96 |
function removeWaiState(){
|
|
|
97 |
var div = document.createElement("div");
|
|
|
98 |
dijit.setWaiState(div, "checked", "true");
|
|
|
99 |
dijit.removeWaiState(div, "checked");
|
|
|
100 |
doh.assertEqual("", dijit.getWaiState(div, "checked"));
|
|
|
101 |
}
|
|
|
102 |
]
|
|
|
103 |
);
|
|
|
104 |
doh.run();
|
|
|
105 |
});
|
|
|
106 |
</script>
|
|
|
107 |
</head>
|
|
|
108 |
<body>
|
|
|
109 |
<div id="no-role-or-states"></div>
|
|
|
110 |
<div id="empty-wairole" role="wairole:"></div>
|
|
|
111 |
<div id="wairole" role="wairole:menuitem"></div>
|
|
|
112 |
<div id="unprefixed-role" role="menuitem"></div>
|
|
|
113 |
<div id="checked" aria-checked="true"></div>
|
|
|
114 |
</body>
|
|
|
115 |
</html>
|