tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / platform / mac / accessibility / search-predicate.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../fast/js/resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
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>
12 <form>
13 <input type="text" /><br />
14 <input type="checkbox" value="Checkbox" /> checkbox<br />
15 <input type="submit" value="Submit" />
16 </form>
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>
30 <table>
31 <thead><tr><td>first table heading level 1</td></tr></thead>
32 <tbody><tr><td>first table body level 1</td></tr></tbody>
33 </table>
34 <table>
35 <thead><tr><td>second table heading level 1</td></tr></thead>
36 <tbody><tr><td>second table body level 1</td></tr></tbody>
37 </table>
38
39 <p id="description"></p>
40 <div id="console"></div>
41
42 <script>
43     description("This tests the ability to search for accessible elements by key or text.");
44     
45     if (window.accessibilityController) {
46         document.getElementById("body").focus();
47         var containerElement = accessibilityController.focusedElement;
48         var startElement;
49         var isDirectionNext;
50         var searchKey;
51         var searchText = "";
52         var resultElement;
53         
54         // Any element.
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'");
61         
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'");
69         
70         // Blockquote.
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'");
77         
78         // Bold font.
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'");
85         
86         // Button.
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'");
92         
93         // Check box.
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'");
99         
100         // Control.
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'");
106         
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'");
114         
115         // Font change.
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'");
122         
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'");
130         
131         // Frame.
132         // FIXME: Handle this search key.
133         
134         // Graphic.
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'");
140         
141         // Heading level 1.
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'");
148         
149         // Heading level 2.
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'");
156         
157         // Heading level 3.
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'");
164         
165         // Heading level 4.
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'");
172         
173         // Heading level 5.
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'");
180         
181         // Heading level 6.
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'");
188         
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'");
196         
197         // Heading.
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'");
204         
205         // Italic font.
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'");
212         
213         // Landmark.
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'");
220         
221         // Link.
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'");
228         
229         // List.
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'");
235         
236         // Live Region.
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'");
243         
244         // Misspelled word.
245         // FIXME: Handle this search key.
246         
247         // Plain text.
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'");
254         
255         // Radio group.
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'");
261         
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'");
269         
270         // Static text.
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'");
277         
278         // Style change.
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'");
285         
286         // Same level table.
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'");
293         
294         // Table.
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'");
301         
302         // Text field.
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'");
308         
309         // Underline.
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'");
316         
317         // Unvisited link.
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'");
324         
325         // Visited link.
326         // FIXME: Handle this search key.
327         
328         // Previous text search.
329         startElement = accessibilityController.focusedElement.childAtIndex(10);
330         isDirectionNext = false;
331         searchKey = "";
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'");
336     }
337     
338 </script>
339
340 <script src="../../../fast/js/resources/js-test-post.js"></script>
341 </body>
342 </html>