2012-08-29 07:56:45 +00:00
<!DOCTYPE HTML>
< html >
< body >
2013-09-08 01:18:24 +00:00
< script src = "../resources/js-test-pre.js" > < / script >
2016-05-20 18:34:14 +00:00
< script src = "../resources/accessibility-helper.js" > < / script >
< div id = "content" >
2012-08-29 07:56:45 +00:00
2012-12-17 22:24:03 +00:00
<!-- A link always gets its accessible text from contents. -->
2012-08-29 07:56:45 +00:00
< a id = "link" href = "#" > A< / a >
2012-12-17 22:24:03 +00:00
2014-01-23 02:01:39 +00:00
<!-- A generic focusable div should not get its accessible text from contents. -->
2012-08-29 07:56:45 +00:00
< div id = "div" tabindex = "0" > B< / div >
< div id = "div2" tabindex = "0" > < div > < / div > C< / div >
< div id = "div3" tabindex = "0" aria-label = "D" > < / div >
2012-12-17 22:24:03 +00:00
<!-- A generic focusable div should not get accessible text from children that are focusable or containers. -->
< div id = "div4" tabindex = "0" > < a href = "#" > Link< / a > < / div >
< div id = "div5" tabindex = "0" > Initial text before link< a href = "#" > Link< / a > < / div >
< div id = "div6" tabindex = "0" > < ul > < li > List item< / li > < / ul > < / div >
< div id = "div7" tabindex = "0" > Initial text before list< ul > < li > List item< / li > < / ul > < / div >
2016-05-20 18:34:14 +00:00
< / div >
2012-08-29 07:56:45 +00:00
< div id = "console" > < / div >
< script >
2014-01-23 02:01:39 +00:00
description("This test makes sure that a generic focusable div can get accessibility focus. It should not get accessible text from its children automatically though.");
2012-08-29 07:56:45 +00:00
if (window.testRunner & & window.accessibilityController) {
window.testRunner.dumpAsText();
function lastChar(str) {
return str.substr(str.length - 1);
}
var link = document.getElementById('link');
link.focus();
shouldBe("document.activeElement == link", "true");
window.axLink = accessibilityController.focusedElement;
shouldBe("lastChar(axLink.title)", "\"A\"");
var div = document.getElementById('div');
div.focus();
shouldBe("document.activeElement == div", "true");
window.axDiv = accessibilityController.focusedElement;
2014-01-23 02:01:39 +00:00
shouldBe("lastChar(axDiv.title)", "' '");
2012-08-29 07:56:45 +00:00
var div2 = document.getElementById('div2');
div2.focus();
shouldBe("document.activeElement == div2", "true");
window.axDiv2 = accessibilityController.focusedElement;
2014-01-23 02:01:39 +00:00
shouldBe("lastChar(axDiv2.title)", "' '");
2012-08-29 07:56:45 +00:00
var div3 = document.getElementById('div3');
div3.focus();
shouldBe("document.activeElement == div3", "true");
window.axDiv3 = accessibilityController.focusedElement;
2016-05-20 18:34:14 +00:00
var accNameForDiv3 = platformValueForW3CName(axDiv3);
shouldBe("lastChar(accNameForDiv3)", "\"D\"");
2012-12-17 22:24:03 +00:00
var div4 = document.getElementById('div4');
div4.focus();
shouldBe("document.activeElement == div4", "true");
window.axDiv4 = accessibilityController.focusedElement;
shouldBe("axDiv4.title.indexOf('Link')", "-1");
var div5 = document.getElementById('div5');
div5.focus();
shouldBe("document.activeElement == div5", "true");
window.axDiv5 = accessibilityController.focusedElement;
shouldBe("axDiv5.title.indexOf('Link')", "-1");
2014-01-23 02:01:39 +00:00
shouldBe("axDiv5.title.indexOf('Initial text before link') >= 0", "false");
2012-12-17 22:24:03 +00:00
var div6 = document.getElementById('div6');
div6.focus();
shouldBe("document.activeElement == div6", "true");
window.axDiv6 = accessibilityController.focusedElement;
shouldBe("axDiv6.title.indexOf('List item')", "-1");
var div7 = document.getElementById('div7');
div7.focus();
shouldBe("document.activeElement == div7", "true");
window.axDiv7 = accessibilityController.focusedElement;
shouldBe("axDiv7.title.indexOf('List item')", "-1");
2014-01-23 02:01:39 +00:00
shouldBe("axDiv7.title.indexOf('Initial text before list') >= 0", "false");
2016-05-20 18:34:14 +00:00
document.getElementById("content").style.visibility = "hidden";
2012-08-29 07:56:45 +00:00
}
< / script >
2013-09-08 01:18:24 +00:00
< script src = "../resources/js-test-post.js" > < / script >
2012-08-29 07:56:45 +00:00
< / body >
< / html >