<!DOCTYPE HTML>
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<!-- A link always gets its accessible text from contents. -->
<a id="link" href="#">A</a>
<!-- A generic focusable div not get its accessible text from contents. -->
<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>
<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>
<script>
test((t) => {
var link = document.getElementById('link');
link.focus();
assert_equals(document.activeElement == link, true);
window.axLink = accessibilityController.focusedElement;
assert_equals(axLink.name, "A");
var div = document.getElementById('div');
div.focus();
assert_equals(document.activeElement == div, true);
window.axDiv = accessibilityController.focusedElement;
assert_equals(axDiv.name, "B");
var div2 = document.getElementById('div2');
div2.focus();
assert_equals(document.activeElement == div2, true);
window.axDiv2 = accessibilityController.focusedElement;
assert_equals(axDiv2.name, "C");
var div3 = document.getElementById('div3');
div3.focus();
assert_equals(document.activeElement == div3, true);
window.axDiv3 = accessibilityController.focusedElement;
assert_equals(axDiv3.name, "D");
var div4 = document.getElementById('div4');
div4.focus();
assert_equals(document.activeElement == div4, true);
window.axDiv4 = accessibilityController.focusedElement;
assert_equals(axDiv4.name, "Link");
var div5 = document.getElementById('div5');
div5.focus();
assert_equals(document.activeElement == div5, true);
window.axDiv5 = accessibilityController.focusedElement;
assert_equals(axDiv5.name, "Initial text before linkLink");
var div6 = document.getElementById('div6');
div6.focus();
assert_equals(document.activeElement == div6, true);
window.axDiv6 = accessibilityController.focusedElement;
assert_equals(axDiv6.name, "List item");
var div7 = document.getElementById('div7');
div7.focus();
assert_equals(document.activeElement == div7, true);
window.axDiv7 = accessibilityController.focusedElement;
assert_equals(axDiv7.name, "Initial text before list List item");
}, "This test makes sure that a generic focusable div can get accessibility focus and gets its accessible text from contents..");
</script>
</body>
</html>