aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dijit/tests/_base/wai.html
blob: 50ab8ca3171918c7b340d1a7dc50d9df3eb88936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
<head>
	<title>Dijit wai unit test</title>
	<script type="text/javascript" src="../../../dojo/dojo.js"
		djConfig="isDebug: true"></script>
	<script type="text/javascript">
		dojo.require("doh.runner");
		dojo.require("dijit.dijit");

		dojo.addOnLoad(function(){
			doh.register("dijit.tests._base.wai",
				[
					function getWaiRoleOnElementWithNoRole(){
						var elem = dojo.byId("no-role-or-states");
						doh.assertFalse(dijit.hasWaiRole(elem));
						doh.assertEqual("", dijit.getWaiRole(elem));
					},

					function getEmptyWairoleRole(){
						var elem = dojo.byId("empty-wairole");
						doh.assertTrue(dijit.hasWaiRole(elem));
						doh.assertEqual("", dijit.getWaiRole(elem));
					},

					function getWairoleRole(){
						var elem = dojo.byId("wairole");
						doh.assertTrue(dijit.hasWaiRole(elem));
						doh.assertEqual("menuitem", dijit.getWaiRole(elem));
					},

					function getUnprefixedRole(){
						var elem = dojo.byId("unprefixed-role");
						doh.assertTrue(dijit.hasWaiRole(elem));
						doh.assertEqual("menuitem", dijit.getWaiRole(elem));
					},

					function setWaiRole(){
						var div = document.createElement("div");
						dijit.setWaiRole(div, "menuitem");
						if(dojo.isFF && dojo.isFF < 3){
							doh.assertEqual("wairole:menuitem",
								div.getAttribute("role"));
						}else{
							doh.assertEqual("menuitem",
								div.getAttribute("role"));
						}
					},

					function removeWaiRole(){
						var div = document.createElement("div");
						dijit.setWaiRole(div, "menuitem");
						dijit.removeWaiRole(div);
						if(div.hasAttribute){
							doh.assertFalse(div.hasAttribute("role"));
						}else{
							doh.assertTrue(div.getAttribute("role") == null
								|| div.getAttribute("role") == "");
						}
					},

					function getWaiStateOnElementWithNoState(){
						var elem = dojo.byId("no-role-or-states");
						doh.assertFalse(dijit.hasWaiState(elem, "checked"));
						doh.assertEqual("", dijit.getWaiState(elem, "checked"));
					},

					function getWaiState(){
						if(dojo.isFF && dojo.isFF < 3){
							var div = document.createElement("div");
							div.setAttributeNS("http://www.w3.org/2005/07/aaa",
								"aaa:checked", "true");
							doh.assertTrue(dijit.hasWaiState(div, "checked"));
							doh.assertEqual("true",
								dijit.getWaiState(div, "checked"));
						}else{
							var elem = dojo.byId("checked");
							doh.assertTrue(dijit.hasWaiState(elem, "checked"));
							doh.assertEqual("true",
								dijit.getWaiState(elem, "checked"));
						}
					},

					function setWaiState(){
						var div = document.createElement("div");
						dijit.setWaiState(div, "checked", "true");
						if(dojo.isFF && dojo.isFF < 3){
							doh.assertEqual("true",
								div.getAttributeNS("http://www.w3.org/2005/07/aaa",
								"checked"));
						}else{
							doh.assertEqual("true",
								div.getAttribute("aria-checked"));
						}
					},

					function removeWaiState(){
						var div = document.createElement("div");
						dijit.setWaiState(div, "checked", "true");
						dijit.removeWaiState(div, "checked");
						doh.assertEqual("", dijit.getWaiState(div, "checked"));
					}
				]
			);
			doh.run();
		});
	</script>
</head>
<body>
	<div id="no-role-or-states"></div>
	<div id="empty-wairole" role="wairole:"></div>
	<div id="wairole" role="wairole:menuitem"></div>
	<div id="unprefixed-role" role="menuitem"></div>
	<div id="checked" aria-checked="true"></div>
</body>
</html>