1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <script src="../../../fast/js/resources/js-test-pre.js"></script>
8 <blockquote>first blockquote level 1</blockquote>
9 <blockquote>second blockquote level 1</blockquote>
10 <p style="color:black; font-family:sans-serif; font-weight:bold; text-decoration:underline;">sans-serif black bold text with underline</p>
11 <p style="color:blue; font-family:serif; font-style:italic;">serif blue italic text</p>
13 <input type="text" /><br />
14 <input type="checkbox" value="Checkbox" /> checkbox<br />
15 <input type="submit" value="Submit" />
17 <img id="image" src="resources/cake.png" alt="Test">
18 <h1>first heading level 1</h1>
19 <h1>second heading level 1</h1>
20 <h2>heading level 2</h2>
21 <h3>heading level 3</h3>
22 <h4>heading level 4</h4>
23 <h5>heading level 5</h5>
24 <h6>heading level 6</h6>
25 <p id="banner" role="banner">landmark</p>
26 <a href="#image">link</a>
27 <ol><li>list item</li></ol>
28 <p aria-live="polite">live region</p>
29 <ul role="radiogroup"><li role="radio">radio button</li></ul>
31 <thead><tr><td>first table heading level 1</td></tr></thead>
32 <tbody><tr><td>first table body level 1</td></tr></tbody>
35 <thead><tr><td>second table heading level 1</td></tr></thead>
36 <tbody><tr><td>second table body level 1</td></tr></tbody>
39 <p id="description"></p>
40 <div id="console"></div>
43 description("This tests the ability to search for accessible elements by key or text.");
45 if (window.accessibilityController) {
46 document.getElementById("body").focus();
47 var containerElement = accessibilityController.focusedElement;
55 startElement = accessibilityController.focusedElement.childAtIndex(0);
56 isDirectionNext = true;
57 searchKey = "AXAnyTypeSearchKey";
58 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
59 shouldBe("resultElement.role", "'AXRole: AXStaticText'");
60 shouldBe("resultElement.stringValue", "'AXValue: first blockquote level 1'");
62 // Same level blockquote.
63 startElement = accessibilityController.focusedElement.childAtIndex(0);
64 isDirectionNext = true;
65 searchKey = "AXBlockquoteSameLevelSearchKey";
66 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
67 shouldBe("resultElement.role", "'AXRole: AXGroup'");
68 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: second blockquote level 1'");
71 startElement = accessibilityController.focusedElement.childAtIndex(0);
72 isDirectionNext = true;
73 searchKey = "AXBlockquoteSearchKey";
74 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
75 shouldBe("resultElement.role", "'AXRole: AXGroup'");
76 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: second blockquote level 1'");
79 startElement = accessibilityController.focusedElement.childAtIndex(0);
80 isDirectionNext = true;
81 searchKey = "AXBoldFontSearchKey";
82 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
83 shouldBe("resultElement.role", "'AXRole: AXGroup'");
84 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: sans-serif black bold text with underline'");
87 startElement = accessibilityController.focusedElement.childAtIndex(0);
88 isDirectionNext = true;
89 searchKey = "AXButtonSearchKey";
90 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
91 shouldBe("resultElement.role", "'AXRole: AXButton'");
94 startElement = accessibilityController.focusedElement.childAtIndex(0);
95 isDirectionNext = true;
96 searchKey = "AXCheckBoxSearchKey";
97 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
98 shouldBe("resultElement.role", "'AXRole: AXCheckBox'");
101 startElement = accessibilityController.focusedElement.childAtIndex(0);
102 isDirectionNext = true;
103 searchKey = "AXCheckBoxSearchKey";
104 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
105 shouldBe("resultElement.role", "'AXRole: AXCheckBox'");
107 // Different type element.
108 startElement = accessibilityController.focusedElement.childAtIndex(0);
109 isDirectionNext = true;
110 searchKey = "AXDifferentTypeSearchKey";
111 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
112 shouldBe("resultElement.role", "'AXRole: AXStaticText'");
113 shouldBe("resultElement.stringValue", "'AXValue: first blockquote level 1'");
116 startElement = accessibilityController.focusedElement.childAtIndex(2);
117 isDirectionNext = true;
118 searchKey = "AXFontChangeSearchKey";
119 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
120 shouldBe("resultElement.role", "'AXRole: AXGroup'");
121 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: serif blue italic text'");
123 // Font color change.
124 startElement = accessibilityController.focusedElement.childAtIndex(2);
125 isDirectionNext = true;
126 searchKey = "AXFontColorChangeSearchKey";
127 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
128 shouldBe("resultElement.role", "'AXRole: AXGroup'");
129 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: serif blue italic text'");
132 // FIXME: Handle this search key.
135 startElement = accessibilityController.focusedElement.childAtIndex(0);
136 isDirectionNext = true;
137 searchKey = "AXGraphicSearchKey";
138 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
139 shouldBe("resultElement.role", "'AXRole: AXImage'");
142 startElement = accessibilityController.focusedElement.childAtIndex(0);
143 isDirectionNext = true;
144 searchKey = "AXHeadingLevel1SearchKey";
145 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
146 shouldBe("resultElement.role", "'AXRole: AXHeading'");
147 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: first heading level 1'");
150 startElement = accessibilityController.focusedElement.childAtIndex(0);
151 isDirectionNext = true;
152 searchKey = "AXHeadingLevel2SearchKey";
153 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
154 shouldBe("resultElement.role", "'AXRole: AXHeading'");
155 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
158 startElement = accessibilityController.focusedElement.childAtIndex(0);
159 isDirectionNext = true;
160 searchKey = "AXHeadingLevel3SearchKey";
161 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
162 shouldBe("resultElement.role", "'AXRole: AXHeading'");
163 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 3'");
166 startElement = accessibilityController.focusedElement.childAtIndex(0);
167 isDirectionNext = true;
168 searchKey = "AXHeadingLevel4SearchKey";
169 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
170 shouldBe("resultElement.role", "'AXRole: AXHeading'");
171 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 4'");
174 startElement = accessibilityController.focusedElement.childAtIndex(0);
175 isDirectionNext = true;
176 searchKey = "AXHeadingLevel5SearchKey";
177 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
178 shouldBe("resultElement.role", "'AXRole: AXHeading'");
179 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 5'");
182 startElement = accessibilityController.focusedElement.childAtIndex(0);
183 isDirectionNext = true;
184 searchKey = "AXHeadingLevel6SearchKey";
185 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
186 shouldBe("resultElement.role", "'AXRole: AXHeading'");
187 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 6'");
189 // Same level heading.
190 startElement = accessibilityController.focusedElement.childAtIndex(6);
191 isDirectionNext = true;
192 searchKey = "AXHeadingSameLevelSearchKey";
193 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
194 shouldBe("resultElement.role", "'AXRole: AXHeading'");
195 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: second heading level 1'");
198 startElement = accessibilityController.focusedElement.childAtIndex(0);
199 isDirectionNext = true;
200 searchKey = "AXHeadingSearchKey";
201 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
202 shouldBe("resultElement.role", "'AXRole: AXHeading'");
203 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: first heading level 1'");
206 startElement = accessibilityController.focusedElement.childAtIndex(0);
207 isDirectionNext = true;
208 searchKey = "AXItalicFontSearchKey";
209 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
210 shouldBe("resultElement.role", "'AXRole: AXGroup'");
211 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: serif blue italic text'");
214 startElement = accessibilityController.focusedElement.childAtIndex(0);
215 isDirectionNext = true;
216 searchKey = "AXLandmarkSearchKey";
217 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
218 shouldBe("resultElement.role", "'AXRole: AXGroup'");
219 shouldBe("resultElement.subrole", "'AXSubrole: AXLandmarkBanner'");
222 startElement = accessibilityController.focusedElement.childAtIndex(0);
223 isDirectionNext = true;
224 searchKey = "AXLinkSearchKey";
225 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
226 shouldBe("resultElement.role", "'AXRole: AXLink'");
227 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
230 startElement = accessibilityController.focusedElement.childAtIndex(0);
231 isDirectionNext = true;
232 searchKey = "AXListSearchKey";
233 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
234 shouldBe("resultElement.role", "'AXRole: AXList'");
237 startElement = accessibilityController.focusedElement.childAtIndex(0);
238 isDirectionNext = true;
239 searchKey = "AXLiveRegionSearchKey";
240 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
241 shouldBe("resultElement.role", "'AXRole: AXGroup'");
242 shouldBe("resultElement.stringAttributeValue('AXARIALive')", "'polite'");
245 // FIXME: Handle this search key.
248 startElement = accessibilityController.focusedElement.childAtIndex(0);
249 isDirectionNext = true;
250 searchKey = "AXPlainTextSearchKey";
251 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
252 shouldBe("resultElement.role", "'AXRole: AXStaticText'");
253 shouldBe("resultElement.stringValue", "'AXValue: first blockquote level 1'");
256 startElement = accessibilityController.focusedElement.childAtIndex(0);
257 isDirectionNext = true;
258 searchKey = "AXRadioGroupSearchKey";
259 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
260 shouldBe("resultElement.role", "'AXRole: AXRadioGroup'");
262 // Same type element.
263 startElement = accessibilityController.focusedElement.childAtIndex(0);
264 isDirectionNext = true;
265 searchKey = "AXSameTypeSearchKey";
266 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
267 shouldBe("resultElement.role", "'AXRole: AXGroup'");
268 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: second blockquote level 1'");
271 startElement = accessibilityController.focusedElement.childAtIndex(0);
272 isDirectionNext = true;
273 searchKey = "AXStaticTextSearchKey";
274 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
275 shouldBe("resultElement.role", "'AXRole: AXStaticText'");
276 shouldBe("resultElement.stringValue", "'AXValue: first blockquote level 1'");
279 startElement = accessibilityController.focusedElement.childAtIndex(2);
280 isDirectionNext = true;
281 searchKey = "AXStyleChangeSearchKey";
282 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
283 shouldBe("resultElement.role", "'AXRole: AXGroup'");
284 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: serif blue italic text'");
287 startElement = accessibilityController.focusedElement.childAtIndex(18);
288 isDirectionNext = true;
289 searchKey = "AXTableSameLevelSearchKey";
290 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
291 shouldBe("resultElement.role", "'AXRole: AXTable'");
292 shouldBe("resultElement.childAtIndex(0).childAtIndex(0).childAtIndex(0).stringValue", "'AXValue: second table heading level 1'");
295 startElement = accessibilityController.focusedElement.childAtIndex(0);
296 isDirectionNext = true;
297 searchKey = "AXTableSearchKey";
298 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
299 shouldBe("resultElement.role", "'AXRole: AXTable'");
300 shouldBe("resultElement.childAtIndex(0).childAtIndex(0).childAtIndex(0).stringValue", "'AXValue: first table heading level 1'");
303 startElement = accessibilityController.focusedElement.childAtIndex(0);
304 isDirectionNext = true;
305 searchKey = "AXTextFieldSearchKey";
306 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
307 shouldBe("resultElement.role", "'AXRole: AXTextField'");
310 startElement = accessibilityController.focusedElement.childAtIndex(0);
311 isDirectionNext = true;
312 searchKey = "AXUnderlineSearchKey";
313 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
314 shouldBe("resultElement.role", "'AXRole: AXGroup'");
315 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: sans-serif black bold text with underline'");
318 startElement = accessibilityController.focusedElement.childAtIndex(0);
319 isDirectionNext = true;
320 searchKey = "AXUnvisitedLinkSearchKey";
321 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
322 shouldBe("resultElement.role", "'AXRole: AXLink'");
323 shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
326 // FIXME: Handle this search key.
328 // Previous text search.
329 startElement = accessibilityController.focusedElement.childAtIndex(10);
330 isDirectionNext = false;
332 searchText = "sans-serif black bold text with underline";
333 resultElement = containerElement.uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText);
334 shouldBe("resultElement.role", "'AXRole: AXStaticText'");
335 shouldBe("resultElement.stringValue", "'AXValue: sans-serif black bold text with underline'");
340 <script src="../../../fast/js/resources/js-test-post.js"></script>