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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Dijit manager unit test</title>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"></script>
<script type="text/javascript" src="../_testCommon.js"></script>
<script type="text/javascript">
dojo.require("doh.runner");
dojo.require("dijit.dijit");
dojo.declare("foo", dijit._Widget, {
name: "",
attr1: 0,
attr2: 0
});
dojo.declare("bar", dijit._Widget, {
name: "",
attr1: 0,
attr2: 0
});
dojo.addOnLoad(function(){
doh.register("dijit._base.manager",
[
function forEachTest(t){
var names=[];
dijit.registry.forEach(function(widget){ names.push(widget.name); });
t.is(names.join(" "), "bob is your uncle");
},
function filterTest(t){
var names=[];
dijit.registry.
filter(function(widget){ return widget.attr1==10; }).
forEach(function(widget){ names.push(widget.name); });
t.is(names.join(" "), "bob uncle");
},
function byId(t){
t.is(dijit.byId("three").name, "your");
},
function byClass(t){
var names=[];
dijit.registry.
byClass("bar").
forEach(function(widget){ names.push(widget.name); });
t.is(names.join(" "), "your uncle");
},
function deleteTest(t){
var names=[];
dijit.byId("two").destroy();
dijit.byId("four").destroy();
var names=[];
dijit.registry.forEach(function(widget){ names.push(widget.name); });
t.is(names.join(" "), "bob your");
},
function getEnclosingWidgetTest(t){
t.is(dijit.getEnclosingWidget(dojo.byId("not-a-widget")), null);
t.is(dijit.getEnclosingWidget(dojo.byId("three")).name, "your");
t.is(dijit.getEnclosingWidget(dojo.byId("three.one")).name, "your");
t.is(dijit.getEnclosingWidget(dojo.byId("three.one.one")).name, "your");
},
function isTabNavigable(t){
t.t(dijit.isTabNavigable(dojo.byId("a-with-href")));
t.f(dijit.isTabNavigable(dojo.byId("a-without-href")));
t.t(dijit.isTabNavigable(dojo.byId("area")));
t.t(dijit.isTabNavigable(dojo.byId("button")));
t.t(dijit.isTabNavigable(dojo.byId("input")));
t.t(dijit.isTabNavigable(dojo.byId("object")));
t.t(dijit.isTabNavigable(dojo.byId("select")));
t.t(dijit.isTabNavigable(dojo.byId("textarea")));
t.f(dijit.isTabNavigable(dojo.byId("empty")));
t.t(dijit.isTabNavigable(dojo.byId("zero-tabindex-div")));
},
function findTabNullOnEmpty(t){
t.is(null, dijit.getFirstInTabbingOrder("empty"));
t.is(null, dijit.getLastInTabbingOrder("empty"));
},
function findTabElements(t){
t.is(null, dijit.getFirstInTabbingOrder("div-container"));
t.is(null, dijit.getFirstInTabbingOrder("a-without-href-container"));
t.is("a-with-href", dijit.getFirstInTabbingOrder("a-with-href-container").id);
// in Safari area elements are not in the tab order
// and their display style property is "none";
// therefore it is expected that this test will fail
if(!dojo.isSafari){
t.is("area", dijit.getFirstInTabbingOrder("area-map").id);
}
t.is("button", dijit.getFirstInTabbingOrder("button-container").id);
t.is("input", dijit.getFirstInTabbingOrder("input-container").id);
t.is("object", dijit.getFirstInTabbingOrder("object-container").id);
t.is("select", dijit.getFirstInTabbingOrder("select-container").id);
t.is("textarea", dijit.getFirstInTabbingOrder("textarea-container").id);
t.is(null, dijit.getLastInTabbingOrder("div-container"));
t.is(null, dijit.getLastInTabbingOrder("a-without-href-container"));
t.is("a-with-href", dijit.getLastInTabbingOrder("a-with-href-container").id);
// in Safari area elements are not in the tab order
// and their display style property is "none";
// therefore it is expected that this test will fail
if(!dojo.isSafari){
t.is("area", dijit.getLastInTabbingOrder("area-map").id);
}
t.is("button", dijit.getLastInTabbingOrder("button-container").id);
t.is("input", dijit.getLastInTabbingOrder("input-container").id);
t.is("object", dijit.getLastInTabbingOrder("object-container").id);
t.is("select", dijit.getLastInTabbingOrder("select-container").id);
t.is("textarea", dijit.getLastInTabbingOrder("textarea-container").id);
},
function findTabOnElementRatherThanString(t){
t.is("a-with-href", dijit.getFirstInTabbingOrder(dojo.byId("a-with-href-container")).id);
t.is("a-with-href", dijit.getLastInTabbingOrder(dojo.byId("a-with-href-container")).id);
},
function findTabSkipDisabled(t){
t.is("not-disabled-input", dijit.getFirstInTabbingOrder("skip-disabled").id);
t.is("not-disabled-input", dijit.getLastInTabbingOrder("skip-disabled").id);
},
function findTabZeroTabindex(t){
t.is("zero-tabindex-div", dijit.getFirstInTabbingOrder("zero-tabindex-div-container").id);
t.is("zero-tabindex-input", dijit.getFirstInTabbingOrder("zero-tabindex-input-container").id);
t.is("zero-tabindex-div", dijit.getLastInTabbingOrder("zero-tabindex-div-container").id);
t.is("zero-tabindex-input", dijit.getLastInTabbingOrder("zero-tabindex-input-container").id);
},
function findTabPositiveTabindex(t){
t.is("positive-tabindex-input1a", dijit.getFirstInTabbingOrder("positive-tabindex-mixed-with-no-tabindex").id);
t.is("positive-tabindex-input3a", dijit.getFirstInTabbingOrder("positive-tabindex").id);
t.is("no-tabindex-input2", dijit.getLastInTabbingOrder("positive-tabindex-mixed-with-no-tabindex").id);
t.is("positive-tabindex-input4b", dijit.getLastInTabbingOrder("positive-tabindex").id);
},
function findTabSkipMinusOneTabindex(t){
t.is("not-minus-one-input", dijit.getFirstInTabbingOrder("skip-minus-one").id);
t.is("not-minus-one-input", dijit.getLastInTabbingOrder("skip-minus-one").id);
},
function findTabDescend(t){
t.is("child-input1", dijit.getFirstInTabbingOrder("descend").id);
t.is("child-input2", dijit.getLastInTabbingOrder("descend").id);
},
function findTabOuterInner(t){
t.is("outer1", dijit.getFirstInTabbingOrder("outer-inner-container").id);
t.is("inner2", dijit.getLastInTabbingOrder("outer-inner-container").id);
},
function skipNotShown(t){
t.is(null, dijit.getFirstInTabbingOrder("hidden-element-container"));
t.is(null, dijit.getFirstInTabbingOrder("hidden-container-tabindex-zero"));
t.is(null, dijit.getFirstInTabbingOrder("hidden-container-no-tabindex"));
t.is(null, dijit.getFirstInTabbingOrder("container-with-hidden-containers"));
t.is(null, dijit.getFirstInTabbingOrder("display-none-element-container"));
t.is(null, dijit.getFirstInTabbingOrder("display-none-container-tabindex-zero"));
t.is(null, dijit.getFirstInTabbingOrder("display-none-container-no-tabindex"));
t.is(null, dijit.getFirstInTabbingOrder("container-with-display-none-containers"));
}
]
);
doh.run();
});
</script>
</head>
<body>
<h1>Dijit Manager Unit Test</h1>
<div dojoType="foo" id="one" name="bob" attr1="10" attr2="10"></div>
<div dojoType="foo" id="two" name="is" attr1="5" attr2="10"></div>
<div dojoType="bar" id="three" name="your" attr1="5" attr2="5">
<div id="three.one">
<div id="three.one.one"></div>
</div>
</div>
<div dojoType="bar" id="four" name="uncle" attr1="10" attr2="5"></div>
<div id="not-a-widget"></div>
<div id="empty"></div>
<div id="div-container">
<div id="div"></div>
</div>
<div id="a-without-href-container">
<a id="a-without-href" name="named-link-anchor"></a>
</div>
<div id="a-with-href-container">
<a id="a-with-href" href="#named-link-anchor"></a>
</div>
<div><img src="../images/flatScreen.gif" alt="picture of a flat-screen monitor" usemap="#area-map"></div>
<map id="area-map" name="area-map">
<area id="area" href="#" alt="example area" shape="rect" coords="0,0,8,8">
</map>
<div id="button-container">
<button id="button"></button>
</div>
<div id="input-container">
<input id="input">
</div>
<div id="object-container">
<object id="object"></object>
</div>
<div id="select-container">
<select id="select"></select>
</div>
<div id="textarea-container">
<textarea id="textarea"></textarea>
</div>
<div id="skip-disabled">
<input id="disabled-input1" disabled="disabled">
<input id="not-disabled-input">
<input id="disabled-input2" disabled="disabled">
</div>
<div id="zero-tabindex-div-container">
<div id="zero-tabindex-div" tabindex="0"></div>
</div>
<div id="zero-tabindex-input-container">
<input id="zero-tabindex-input" tabindex="0">
</div>
<div id="positive-tabindex-mixed-with-no-tabindex">
<input id="no-tabindex-input1">
<input id="no-tabindex-input2">
<input id="positive-tabindex-input1a" tabindex="1">
<input id="positive-tabindex-input1b" tabindex="1">
<input id="positive-tabindex-input2a" tabindex="2">
<input id="positive-tabindex-input2b" tabindex="2">
</div>
<div id="positive-tabindex">
<input id="positive-tabindex-input3a" tabindex="3">
<input id="positive-tabindex-input3b" tabindex="3">
<input id="positive-tabindex-input4a" tabindex="4">
<input id="positive-tabindex-input4b" tabindex="4">
</div>
<div id="skip-minus-one">
<input id="minus-one-input1" tabindex="-1">
<input id="not-minus-one-input">
<input id="minus-one-input2" tabindex="-1">
</div>
<div id="descend">
<input disabled="disabled">
<div>
<input disabled="disabled">
<div>
<input disabled="disabled">
</div>
</div>
<div>
<input disabled="disabled">
<div>
<input disabled="disabled">
</div>
<div>
<input id="child-input1">
</div>
<div>
<input id="child-input2">
</div>
</div>
<div>
<div>
<input disabled="disabled">
</div>
<input disabled="disabled">
</div>
<input disabled="disabled">
</div>
<div id="outer-inner-container">
<div id="outer1" tabindex="0">
<div id="inner1" tabindex="0"></div>
</div>
<div id="outer2" tabindex="0">
<div id="inner2" tabindex="0"></div>
</div>
</div>
<div id="hidden-element-container">
<div id="hidden-element" tabindex="0" style="visibility: hidden;">
</div>
</div>
<div id="container-with-hidden-containers">
<div id="hidden-container-tabindex-zero" tabindex="0" style="visibility: hidden;">
<div id="inside-hidden-container-tabindex-zero" tabindex="0">
</div>
</div>
<div id="hidden-container-no-tabindex" style="visibility: hidden;">
<div id="inside-hidden-container-no-tabindex" tabindex="0">
</div>
</div>
</div>
<div id="display-none-element-container">
<div id="display-none-element" tabindex="0" style="display: none;">
</div>
</div>
<div id="container-with-display-none-containers">
<div id="display-none-container-tabindex-zero" tabindex="0" style="display: none;">
<div id="inside-display-none-container-tabindex-zero" tabindex="0">
</div>
</div>
<div id="display-none-container-no-tabindex" style="display: none;">
<div id="inside-display-none-container-no-tabindex" tabindex="0">
</div>
</div>
</div>
</body>
</html>
|