REGRESSION(r184899): Crash when focusing an input element styled with a web font
[WebKit-https.git] / LayoutTests / accessibility / mac / aria-tree.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
8 <ul id="tree" role="tree" aria-labelledby="treelabel" aria-activedescendant="tree0_item0_2_0_1" tabindex="0">
9     <li id="treeitem1" role="treeitem" aria-level="1" aria-expanded="true">
10         <span>
11             <span class="expander"></span>
12             Animals
13             </span>
14             <ul role="group">
15                 <div id="treeitem2" role="treeitem" aria-level="2"><span>Birds</span></div>
16                 <li id="treeitem3" role="treeitem" aria-level="2" aria-expanded="true">
17                     <span>
18                         <span class="expander"></span>
19                         Cats
20                     </span>
21                     <ul role="group">
22                         <li id="tree0_item0_1_0" role="treeitem"aria-level="3"><span>Siamese</span></li>
23                         <li id="tree0_item0_1_1" role="treeitem" aria-level="3"><span>Tabby</span></li>
24                     </ul>
25                 </li>
26             </ul>
27         </span>
28     </li>
29
30     <li id="treeitem4" role="treeitem" aria-expanded="true">
31         <span>
32             <span class="expander"></span>
33             Vegetables
34             </span>
35             <ul role="group">
36                 <div id="treeitem5" role="treeitem"><span>Carrots</span></div>
37                 <div id="treeitem6" role="treeitem"><span>Broccoli</span></div>
38             </ul>
39         </span>
40     </li>
41 </ul>
42
43 <p id="description"></p>
44 <div id="console"></div>
45
46 <script>
47
48     description("This tests that aria trees and tree items are converted into AXOutlines and AXRows, with all the right attributes.");
49
50     if (window.accessibilityController) {
51
52           var tree = document.getElementById("tree");
53           tree.focus();
54
55           // Test tree attributes.
56           tree = accessibilityController.focusedElement;
57           shouldBe("tree.role", "'AXRole: AXOutline'");
58           var canSetRows = tree.isAttributeSettable('AXSelectedRows');
59           shouldBe("canSetRows", "true");
60           shouldBe("tree.childrenCount", "8");
61       
62           // Test tree item attributes.
63           var treeitem1 = tree.childAtIndex(0);
64           shouldBe("treeitem1.role", "'AXRole: AXRow'");
65           shouldBe("treeitem1.subrole", "'AXSubrole: AXOutlineRow'");
66           shouldBe("treeitem1.isExpanded", "true");
67           shouldBe("treeitem1.hierarchicalLevel", "0");
68           var canSetDisclosing = treeitem1.isAttributeSettable('AXDisclosing');
69           shouldBe("canSetDisclosing", "true");
70           
71           // Test more tree item attributes as we dive i,
72           var treeitem2 = treeitem1.disclosedRowAtIndex(0);
73           shouldBe("treeitem2.role", "'AXRole: AXRow'");
74           shouldBe("treeitem2.subrole", "'AXSubrole: AXOutlineRow'");
75           shouldBe("treeitem2.isExpanded", "false");
76           shouldBe("treeitem2.hierarchicalLevel", "1");
77           shouldBe("treeitem2.disclosedByRow().isEqual(treeitem1)", "true");
78           canSetDisclosing = treeitem2.isAttributeSettable('AXDisclosing');
79           shouldBe("canSetDisclosing", "false");
80
81           var treeitem3 = treeitem2.childAtIndex(0);
82           shouldBe("treeitem3.stringValue", "'AXValue: Birds'");
83           canSetDisclosing = treeitem3.isAttributeSettable('AXDisclosing');
84           shouldBe("canSetDisclosing", "false");
85
86           // Test more AXRow attributes and values as we dive further in.
87           treeitem3 = treeitem1.disclosedRowAtIndex(1);
88           shouldBe("treeitem3.role", "'AXRole: AXRow'");
89           shouldBe("treeitem3.subrole", "'AXSubrole: AXOutlineRow'");
90           shouldBe("treeitem3.isExpanded", "true");
91   
92           // test that the row can be selected correctly.
93           shouldBe("treeitem3.isSelected", "false");
94           document.getElementById("treeitem3").setAttribute("aria-selected", true);
95           shouldBe("treeitem3.isSelected", "true");
96
97           // Test that the tree reports the right selected row (treeitem3)
98           var selectedRow = tree.selectedRowAtIndex(0);
99           shouldBe("selectedRow.isEqual(treeitem3)", "true");          
100
101           // Test that hierarchicalLevel can be computed automatically, also,
102           // and that it's consistent with the ARIA level.
103           var treeitem4 = accessibilityController.accessibleElementById("treeitem4");
104           shouldBe("treeitem4.hierarchicalLevel", "0");
105
106           var treeitem5 = accessibilityController.accessibleElementById("treeitem5");
107           shouldBe("treeitem5.hierarchicalLevel", "1");
108
109           var treeitem6 = accessibilityController.accessibleElementById("treeitem6");
110           shouldBe("treeitem6.hierarchicalLevel", "1");
111     }
112
113 </script>
114
115 <script src="../../resources/js-test-post.js"></script>
116 </body>
117 </html>