core tests: a few comments about failing tests, a few fixes for existing tests, mostly messages; primary remaining issue is that both $("area").is(":visible") and $("area").is(":hidden") return true, which is most likely a bug in jQuery core

This commit is contained in:
Jörn Zaefferer 2009-09-15 08:35:46 +00:00
parent b9b604936e
commit 09fd7fc1fa
2 changed files with 17 additions and 13 deletions

View File

@ -24,22 +24,22 @@
<input type="radio" id="visibleAncestor-inputTypeRadio" /> <input type="radio" id="visibleAncestor-inputTypeRadio" />
<input type="button" id="visibleAncestor-inputTypeButton" /> <input type="button" id="visibleAncestor-inputTypeButton" />
<input type="hidden" id="visibleAncestor-inputTypeHidden" /> <input type="hidden" id="visibleAncestor-inputTypeHidden" />
<button id="visibleAncestor-button"></button> <button id="visibleAncestor-button">x</button>
<select id="visibleAncestor-select"> <select id="visibleAncestor-select">
<option>option</option> <option>option</option>
</select> </select>
<textarea id="visibleAncestor-textarea"></textarea> <textarea id="visibleAncestor-textarea">x</textarea>
<object id="visibleAncestor-object"></object> <object id="visibleAncestor-object">xxx</object>
<a href="#" id="visibleAncestor-anchorWithHref">anchor</a> <a href="#" id="visibleAncestor-anchorWithHref">anchor</a>
<a id="visibleAncestor-anchorWithoutHref">anchor</a> <a id="visibleAncestor-anchorWithoutHref">anchor</a>
<map> <map>
<area href="#" id="visibleAncestor-areaWithHref" alt="" /> <area href="#" id="visibleAncestor-areaWithHref" alt="" />
<area id="visibleAncestor-areaWithoutHref" alt="" /> <area id="visibleAncestor-areaWithoutHref" alt="" />
</map> </map>
<span id="visibleAncestor-span"></span> <span id="visibleAncestor-span">x</span>
<div id="visibleAncestor-div"></div> <div id="visibleAncestor-div">x</div>
<span id="visibleAncestor-spanWithTabindex" tabindex="1"></span> <span id="visibleAncestor-spanWithTabindex" tabindex="1">x</span>
<div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1"></div> <div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1">x</div>
</div> </div>
<div> <div>

View File

@ -6,19 +6,19 @@
module("core - selectors"); module("core - selectors");
function isFocusable(selector, msg) { function isFocusable(selector, msg) {
ok($(selector).is(':focusable'), msg); ok($(selector).is(':focusable'), msg + " - selector " + selector + " is focusable");
} }
function isNotFocusable(selector, msg) { function isNotFocusable(selector, msg) {
ok($(selector).length && !$(selector).is(':focusable'), msg); ok($(selector).length && !$(selector).is(':focusable'), msg + " - selector " + selector + " is not focusable");
} }
function isTabbable(selector, msg) { function isTabbable(selector, msg) {
ok($(selector).is(':tabbable'), msg); ok($(selector).is(':tabbable'), msg + " - selector " + selector + " is tabbable");
} }
function isNotTabbable(selector, msg) { function isNotTabbable(selector, msg) {
ok($(selector).length && !$(selector).is(':tabbable'), msg); ok($(selector).length && !$(selector).is(':tabbable'), msg + " - selector " + selector + " is not tabbable");
} }
test("data", function() { test("data", function() {
@ -93,6 +93,7 @@ test("focusable - visible, enabled elements", function() {
isFocusable('#visibleAncestor-object', 'object'); isFocusable('#visibleAncestor-object', 'object');
isFocusable('#visibleAncestor-anchorWithHref', 'anchor with href'); isFocusable('#visibleAncestor-anchorWithHref', 'anchor with href');
isNotFocusable('#visibleAncestor-anchorWithoutHref', 'anchor without href'); isNotFocusable('#visibleAncestor-anchorWithoutHref', 'anchor without href');
// fails: $("map").is(":visible") and $("map").is(":hidden") both return true
isFocusable('#visibleAncestor-areaWithHref', 'area with href'); isFocusable('#visibleAncestor-areaWithHref', 'area with href');
isNotFocusable('#visibleAncestor-areaWithoutHref', 'area without href'); isNotFocusable('#visibleAncestor-areaWithoutHref', 'area without href');
isNotFocusable('#visibleAncestor-span', 'span'); isNotFocusable('#visibleAncestor-span', 'span');
@ -131,7 +132,7 @@ test("focusable - hidden styles", function() {
isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden');
}); });
test("focusable - natively tabbable with various tabindex", function() { test("focusable - natively focusable with various tabindex", function() {
expect(4); expect(4);
isFocusable('#inputTabindex0', 'input, tabindex 0'); isFocusable('#inputTabindex0', 'input, tabindex 0');
@ -140,7 +141,7 @@ test("focusable - natively tabbable with various tabindex", function() {
isFocusable('#inputTabindex-50', 'input, tabindex -50'); isFocusable('#inputTabindex-50', 'input, tabindex -50');
}); });
test("focusable - not natively tabbable with various tabindex", function() { test("focusable - not natively focusable with various tabindex", function() {
expect(4); expect(4);
isFocusable('#spanTabindex0', 'span, tabindex 0'); isFocusable('#spanTabindex0', 'span, tabindex 0');
@ -173,6 +174,7 @@ test("tabbable - visible, enabled elements", function() {
isTabbable('#visibleAncestor-object', 'object'); isTabbable('#visibleAncestor-object', 'object');
isTabbable('#visibleAncestor-anchorWithHref', 'anchor with href'); isTabbable('#visibleAncestor-anchorWithHref', 'anchor with href');
isNotTabbable('#visibleAncestor-anchorWithoutHref', 'anchor without href'); isNotTabbable('#visibleAncestor-anchorWithoutHref', 'anchor without href');
// fails: $("map").is(":visible") and $("map").is(":hidden") both return true
isTabbable('#visibleAncestor-areaWithHref', 'area with href'); isTabbable('#visibleAncestor-areaWithHref', 'area with href');
isNotTabbable('#visibleAncestor-areaWithoutHref', 'area without href'); isNotTabbable('#visibleAncestor-areaWithoutHref', 'area without href');
isNotTabbable('#visibleAncestor-span', 'span'); isNotTabbable('#visibleAncestor-span', 'span');
@ -201,10 +203,12 @@ test("Tabbable - hidden styles", function() {
isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent'); isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent');
isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent');
// fails: element hidden by parent-visibility-hidden is still visible according to :visible
isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent');
isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent');
isNotTabbable('#displayNone-input', 'input, display: none'); isNotTabbable('#displayNone-input', 'input, display: none');
// fails: element hidden by parent-visibility-hidden is still visible according to :visible
isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden'); isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden');
isNotTabbable('#displayNone-span', 'span with tabindex, display: none'); isNotTabbable('#displayNone-span', 'span with tabindex, display: none');