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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <title>YUI FocusManager Node Plugin Tests</title>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots width: 150px;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots background-color: #ccc;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots border: solid 1px #333;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots padding: 10px;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots list-style: none;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots width: auto;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots border: solid 1px #ffcc00;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots background-color: yellow;
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><a href="#" class="focusable">Three</a></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><a href="#" class="focusable" tabindex="0">Two</a></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><a href="#" class="focusable">Three</a></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><input type="button" name="button-1" value="Five" class="focusable" disabled></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><input type="button" name="button-2" value="Six" class="focusable"></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><button type="button" class="focusable" disabled><em>Seven</em></button></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><button type="button" class="focusable"><em><em>Eight</em></em></button></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><a id="anchor-1" href="#" class="focusable">One</a></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><a href="#" class="focusable">Three</a></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><a href="#" class="focusable">Three</a></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><input type="button" name="button-1" value="Five" class="focusable" disabled></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><input type="button" name="button-2" value="Six" class="focusable"></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><button type="button" class="focusable" disabled><em>Seven</em></button></li>
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots <li><button type="button" class="focusable"><em><em>Eight</em></em></button></li>
47f7380215b8e35dd4da7b1dde41e85467f13777Luke Smith<script src="/build/yui/yui.js" type="text/javascript"></script>
c48cf12a861808708c3dc0e82c5e515bede917adMatt Sweeney YUI({timeout: 10000, filter:'raw'}).use("node-event-simulate", "node-focusmanager", "test", "console", function(Y) {
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.on("contentready", function () {
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots var myConsole = new Y.Console().render();
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots var testFocusManager = new Y.Test.Case({
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots name: "FocusManager Tests",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots testActiveDescendant: function() {
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // If no value is specified for the "activeDescendant"
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // attribute, the value is interpreted from the markup
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // by using the first descendant whose tabIndex attribute
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // is set to "0"
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oList1 = Y.one("#list-1");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots descendants: ">li>.focusable",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots keys: { next: "down:40", previous: "down:38" },
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots focusClass: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots circular: true
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 1));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // If no value is specified for the "activeDescendant"
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // attribute, the value is interpreted from the markup
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // by using the first descendant whose tabIndex attribute
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // is set to "0"
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oList2 = Y.one("#list-2");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots descendants: ">li>.focusable",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots keys: { next: "down:40", previous: "down:38" },
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots focusClass: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots circular: true
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList2.focusManager.get("activeDescendant") === 0));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Clean up for next set of tests
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.unplug("focusManager");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList2.unplug("focusManager");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // The value specified for the activeDescendant attribute
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // via the configuration object, should supercede the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // value interpreted via the markup
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots descendants: ">li>.focusable",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots activeDescendant: 3,
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots keys: { next: "down:40", previous: "down:38" },
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots focusClass: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots circular: true
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 3));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Setting the "activeDescendant" attribute to -1 should
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // result in none of the descendants being focusable via
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // the keyboard
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.set("activeDescendant", -1);
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Test to make sure that the "tabIndex" attribute of all
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // descendants is set to "-1"
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.get("descendants").each(function (node) {
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue( (node.get("tabIndex") === -1) );
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Calling "focus" with no arguments should result in none
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // of the descendants being focused
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isFalse(oList1.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // With the "activeDescendant" attribute set to "-1",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // the user can still focus a descendant by mousing
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // down on it
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.get("descendants").item(0).simulate("mousedown");
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isTrue(oList1.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // The "activeDescendant" attribute should return the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // index of the currently focused descendant
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 0));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // With the "activeDescendant" attribute set to "-1",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // the user can focus a descendant programmically by
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // calling the "focus" method and passing in the index
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // of the descendant to be focused
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.set("activeDescendant", -1);
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isTrue(oList1.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // The "activeDescendant" attribute should return the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // index of the currently focused descendant
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 1));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // The "activeDescendant" attribute can also be set to a
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Node reference
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.focus(oList1.focusManager.get("descendants").item(2));
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isTrue(oList1.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // The "activeDescendant" attribute should return the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // index of the currently focused descendant
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 2));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // The "activeDescendant" attribute cannot be set to the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // index of a disabled Node...
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 2));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // ...Or a disabled Node reference
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.focus(oList1.focusManager.get("descendants").item(4));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("activeDescendant") === 2));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // TEST #10:
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // There should be one element with the CSS class of
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // "focused" applied
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((Y.all(".focused").size() === 1));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // There should be no elements with the CSS class of
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // "focused" applied
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((Y.all(".focused").size() === 0));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Clean up for next set of tests
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.unplug("focusManager");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots testDescendants: function() {
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Check to make sure that the "descendants" attribute
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // returns a NodeList of the correct size
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oList1 = Y.one("#list-1");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots descendants: ">li>.focusable",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots keys: { next: "down:40", previous: "down:38" },
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots focusClass: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots circular: true
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("descendants").size() === 8));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Can update the "descendants" attribute on the fly
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.focusManager.set("descendants", ".focusable");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("descendants").size() === 12));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Can modify the child nodes of the current owner Node
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // of the FocusManager and call "refresh" to sync the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // number of descendants
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oSublist = Y.one("#list-1-2"),
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oParentNode = oSublist.get("parentNode");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList1.focusManager.get("descendants").size() === 8));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Clean up for next set of tests
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList1.unplug("focusManager");
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots // Start by plugging the Focus Manager into an empty
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots // container, then update the descendants and call
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots // the "refresh" method to update the managed descendants.
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oList3 = Y.one("#list-3");
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots descendants: ">li>.focusable",
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots keys: { next: "down:40", previous: "down:38" }
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots Y.Assert.isTrue((oList3.focusManager.get("descendants").size() === 0));
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots oList3.append('<li><a href="#" class="focusable">One</a></li><li><a href="#" class="focusable">Two</a></li><li><a href="#" class="focusable">Three</a></li><li><a href="#" class="focusable">Four</a></li>');
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots Y.Assert.isTrue((oList3.focusManager.get("descendants").size() === 4));
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots oList3.unplug("focusManager");
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots testFocusedAttribute: function() {
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots // The "focused" attribute should be false by default
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oList2 = Y.one("#list-2");
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots descendants: ">li>.focusable",
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots keys: { next: "down:40", previous: "down:38" },
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots focusClass: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots circular: true
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isFalse(oList2.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Calling the "focus" method with no arguments should
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots // result in the "focused" attribute being set to true
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // and the "activeDescendant" attribute being 0
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isTrue(oList2.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList2.focusManager.get("activeDescendant") === 0));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Calling the "blur" method should result in the
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots // "focused" attribute being set to false, the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // removal of the the "focused" CSS class,
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // and the "activeDescendant" attribute being still 0
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((Y.all(".focused").size() === 0));
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isFalse(oList2.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList2.focusManager.get("activeDescendant") === 0));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Focusing another element in the DOM will result in the
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots // "focused" attribute being set to false, the
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // removal of the "focused" CSS class,
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // and the "activeDescendant" attribute being still 0
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots Y.one("#anchor-1").focus();
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((Y.all(".focused").size() === 0));
3d15b2280b07c5175f2af409791b701005333c4cTodd Kloots Y.Assert.isFalse(oList2.focusManager.get("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Assert.isTrue((oList2.focusManager.get("activeDescendant") === 0));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots // Clean up for next set of tests
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots oList2.unplug("focusManager");
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots testFocusClassAttribute: function() {
9cfcc88a8c12dce9f74f55d22112b299b97ac37dTodd Kloots var oList1 = Y.one("#list-1");
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots descendants: ">li>.focusable",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots keys: { next: "down:40", previous: "down:38" },
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots focusClass: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots activeDescendant: 0,
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots circular: true
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // TEST #1: Make sure that the "focused" class is
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // applied to the first descendant
b6b0c05181e24fa2354a4bea2ddc5a7cc254a202Jeff Craig var nodes = oList1.all(".focused");
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots Y.Assert.isTrue(oList1.focusManager.get("descendants").item(0).hasClass("focused"));
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // TEST #2: Make sure that the "focused" class is not
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // not applied to any of the descendants
b6b0c05181e24fa2354a4bea2ddc5a7cc254a202Jeff Craig nodes = oList1.all(".focused");
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots Y.Assert.isFalse(oList1.focusManager.get("descendants").item(0).hasClass("focused"));
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // TEST #3: Make sure that the "focused" class is
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // applied to the parent node of the first descendant
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots className: "focused",
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots fn: function (node) {
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots return node.get("parentNode");
b6b0c05181e24fa2354a4bea2ddc5a7cc254a202Jeff Craig nodes = oList1.all(".focused");
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots Y.Assert.isTrue(oList1.focusManager.get("descendants").item(0).get("parentNode").hasClass("focused"));
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // TEST #4: Make sure that the "focused" class is not
2241a33ad47b9dc8a5f8db4f2fb7ac9a7eacb65dTodd Kloots // not applied to any of the descendants
b6b0c05181e24fa2354a4bea2ddc5a7cc254a202Jeff Craig nodes = oList1.all(".focused");
79f1e6752719a37759550a790d78514b1c3302b5Todd Kloots Y.Assert.isFalse(oList1.focusManager.get("descendants").item(0).get("parentNode").hasClass("focused"));
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots Y.Test.Runner.add(testFocusManager);
b6a72da8ecd1c725f5c9432172ae02d72e09162bTodd Kloots }, "#list-2");