95N/A<!
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 95N/A <
meta http-
equiv="Content-Type" content="text/html; charset=utf-8">
95N/A <
title>YUI FocusManager Node Plugin Tests</
title>
95N/A background-color: #ccc;
95N/A border: solid 1px #333;
95N/A border: solid 1px #ffcc00;
95N/A background-color: yellow;
95N/A<
body class="yui3-skin-sam">
95N/A <
a href="#" class="focusable"><
em>One</
em></
a>
95N/A <
li><
a href="#" class="focusable">One</
a></
li>
95N/A <
li><
a href="#" class="focusable">Two</
a></
li>
95N/A <
li><
a href="#" class="focusable">Three</
a></
li>
95N/A <
li><
a href="#" class="focusable">Four</
a></
li>
95N/A <
li><
a href="#" class="focusable" tabindex="0">Two</
a></
li>
95N/A <
li><
a href="#" class="focusable">Three</
a></
li>
95N/A <
li><
a href="#" class="focusable">Four</
a></
li>
95N/A <
li><
input type="button" name="button-1" value="Five" class="focusable" disabled></
li>
95N/A <
li><
input type="button" name="button-2" value="Six" class="focusable"></
li>
95N/A <
li><
button type="button" class="focusable" disabled><
em>Seven</
em></
button></
li>
95N/A <
li><
button type="button" class="focusable"><
em><
em>Eight</
em></
em></
button></
li>
95N/A <
a href="#" class="focusable"><
em>One</
em></
a>
95N/A <
li><
a id="anchor-1" href="#" class="focusable">One</
a></
li>
95N/A <
li><
a href="#" class="focusable">Two</
a></
li>
95N/A <
li><
a href="#" class="focusable">Three</
a></
li>
95N/A <
li><
a href="#" class="focusable">Four</
a></
li>
95N/A <
li><
a href="#" class="focusable">Two</
a></
li>
95N/A <
li><
a href="#" class="focusable">Three</
a></
li>
95N/A <
li><
a href="#" class="focusable">Four</
a></
li>
95N/A <
li><
input type="button" name="button-1" value="Five" class="focusable" disabled></
li>
95N/A <
li><
input type="button" name="button-2" value="Six" class="focusable"></
li>
95N/A <
li><
button type="button" class="focusable" disabled><
em>Seven</
em></
button></
li>
95N/A <
li><
button type="button" class="focusable"><
em><
em>Eight</
em></
em></
button></
li>
95N/A<
ul id="list-3"></
ul>
95N/A YUI({timeout: 10000}).use("node-event-simulate", "node-focusmanager", "test", "console", function(Y) {
95N/A name: "FocusManager Tests",
95N/A testActiveDescendant: function() {
95N/A // If no value is specified for the "activeDescendant"
95N/A // attribute, the value is interpreted from the markup
95N/A // by using the first descendant whose tabIndex attribute
95N/A descendants: ">li>.focusable",
95N/A keys: { next: "down:40", previous: "down:38" },
// If no value is specified for the "activeDescendant"
// attribute, the value is interpreted from the markup
// by using the first descendant whose tabIndex attribute
var oList2 =
Y.one("#list-2");
descendants: ">li>.focusable",
keys: { next: "down:40", previous: "down:38" },
// Clean up for next set of tests
// The value specified for the activeDescendant attribute
// via the configuration object, should supercede the
// value interpreted via the markup
descendants: ">li>.focusable",
keys: { next: "down:40", previous: "down:38" },
// Setting the "activeDescendant" attribute to -1 should
// result in none of the descendants being focusable via
// Test to make sure that the "tabIndex" attribute of all
// descendants is set to "-1"
// Calling "focus" with no arguments should result in none
// of the descendants being focused
// With the "activeDescendant" attribute set to "-1",
// the user can still focus a descendant by mousing
// The "activeDescendant" attribute should return the
// index of the currently focused descendant
// With the "activeDescendant" attribute set to "-1",
// the user can focus a descendant programmically by
// calling the "focus" method and passing in the index
// of the descendant to be focused
// The "activeDescendant" attribute should return the
// index of the currently focused descendant
// The "activeDescendant" attribute can also be set to a
// The "activeDescendant" attribute should return the
// index of the currently focused descendant
// The "activeDescendant" attribute cannot be set to the
// index of a disabled Node...
//
...Or a disabled Node reference
// There should be one element with the CSS class of
// There should be no elements with the CSS class of
// Clean up for next set of tests
testDescendants: function() {
// Check to make sure that the "descendants" attribute
// returns a NodeList of the correct size
var oList1 =
Y.one("#list-1");
descendants: ">li>.focusable",
keys: { next: "down:40", previous: "down:38" },
// Can update the "descendants" attribute on the fly
// Can modify the child nodes of the current owner Node
// of the FocusManager and call "refresh" to sync the
var oSublist =
Y.one("#list-1-2"),
// Clean up for next set of tests
// Start by plugging the Focus Manager into an empty
// container, then update the descendants and call
// the "refresh" method to update the managed descendants.
var oList3 =
Y.one("#list-3");
descendants: ">li>.focusable",
keys: { next: "down:40", previous: "down:38" }
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>');
testFocusedAttribute: function() {
// The "focused" attribute should be false by default
var oList2 =
Y.one("#list-2");
descendants: ">li>.focusable",
keys: { next: "down:40", previous: "down:38" },
// Calling the "focus" method with no arguments should
// result in the "focused" attribute being set to true
// and the "activeDescendant" attribute being 0
// Calling the "blur" method should result in the
// "focused" attribute being set to false, the
// removal of the the "focused" CSS class,
// and the "activeDescendant" attribute being still 0
// Focusing another element in the DOM will result in the
// "focused" attribute being set to false, the
// removal of the "focused" CSS class,
// and the "activeDescendant" attribute being still 0
Y.one("#anchor-1").focus();
// Clean up for next set of tests
testFocusClassAttribute: function() {
var oList1 =
Y.one("#list-1");
descendants: ">li>.focusable",
keys: { next: "down:40", previous: "down:38" },
// TEST #1: Make sure that the "focused" class is
// applied to the first descendant
// TEST #2: Make sure that the "focused" class is not
// not applied to any of the descendants
// TEST #3: Make sure that the "focused" class is
// applied to the parent node of the first descendant
// TEST #4: Make sure that the "focused" class is not
// not applied to any of the descendants