Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / accessibility / focusable-div.html
bloba04be0a4dfc800339358552b43e6dc945823365f
1 <!DOCTYPE HTML>
2 <html>
3 <body>
4 <script src="../resources/js-test.js"></script>
6 <!-- A link always gets its accessible text from contents. -->
7 <a id="link" href="#">A</a>
9 <!-- A generic focusable div should also get its accessible text from contents. -->
10 <div id="div" tabindex="0">B</div>
11 <div id="div2" tabindex="0"><div></div>C</div>
12 <div id="div3" tabindex="0" aria-label="D"></div>
14 <!-- A generic focusable div should not get accessible text from children that are focusable or containers. -->
15 <div id="div4" tabindex="0"><a href="#">Link</a></div>
16 <div id="div5" tabindex="0">Initial text before link<a href="#">Link</a></div>
17 <div id="div6" tabindex="0"><ul><li>List item</li></ul></div>
18 <div id="div7" tabindex="0">Initial text before list<ul><li>List item</li></ul></div>
20 <div id="console"></div>
21 <script>
22 description("This test makes sure that a generic focusable div can get accessibility focus and gets its accessible text from contents..");
24 if (window.testRunner && window.accessibilityController) {
25 window.testRunner.dumpAsText();
27 function lastChar(str) {
28 return str.substr(str.length - 1);
31 var link = document.getElementById('link');
32 link.focus();
33 shouldBe("document.activeElement == link", "true");
34 window.axLink = accessibilityController.focusedElement;
35 shouldBe("lastChar(axLink.deprecatedTitle)", "\"A\"");
37 var div = document.getElementById('div');
38 div.focus();
39 shouldBe("document.activeElement == div", "true");
40 window.axDiv = accessibilityController.focusedElement;
41 shouldBe("lastChar(axDiv.deprecatedTitle)", "\"B\"");
43 var div2 = document.getElementById('div2');
44 div2.focus();
45 shouldBe("document.activeElement == div2", "true");
46 window.axDiv2 = accessibilityController.focusedElement;
47 shouldBe("lastChar(axDiv2.deprecatedTitle)", "\"C\"");
49 var div3 = document.getElementById('div3');
50 div3.focus();
51 shouldBe("document.activeElement == div3", "true");
52 window.axDiv3 = accessibilityController.focusedElement;
53 shouldBe("lastChar(axDiv3.deprecatedDescription)", "\"D\"");
55 var div4 = document.getElementById('div4');
56 div4.focus();
57 shouldBe("document.activeElement == div4", "true");
58 window.axDiv4 = accessibilityController.focusedElement;
59 shouldBe("axDiv4.deprecatedTitle.indexOf('Link')", "-1");
61 var div5 = document.getElementById('div5');
62 div5.focus();
63 shouldBe("document.activeElement == div5", "true");
64 window.axDiv5 = accessibilityController.focusedElement;
65 shouldBe("axDiv5.deprecatedTitle.indexOf('Link')", "-1");
66 shouldBe("axDiv5.deprecatedTitle.indexOf('Initial text before link') >= 0", "true");
68 var div6 = document.getElementById('div6');
69 div6.focus();
70 shouldBe("document.activeElement == div6", "true");
71 window.axDiv6 = accessibilityController.focusedElement;
72 shouldBe("axDiv6.deprecatedTitle.indexOf('List item')", "-1");
74 var div7 = document.getElementById('div7');
75 div7.focus();
76 shouldBe("document.activeElement == div7", "true");
77 window.axDiv7 = accessibilityController.focusedElement;
78 shouldBe("axDiv7.deprecatedTitle.indexOf('List item')", "-1");
79 shouldBe("axDiv7.deprecatedTitle.indexOf('Initial text before list') >= 0", "true");
82 </script>
84 </body>
85 </html>