OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include <string> | |
6 #include <vector> | |
7 | |
8 #include "base/utf_string_conversions.h" | |
9 #include "chrome/browser/ui/browser.h" | |
10 #include "chrome/browser/ui/browser_tabstrip.h" | |
11 #include "chrome/test/base/in_process_browser_test.h" | |
12 #include "chrome/test/base/ui_test_utils.h" | |
13 #include "content/browser/renderer_host/render_view_host_impl.h" | |
14 #include "content/common/accessibility_node_data.h" | |
15 #include "content/public/browser/notification_service.h" | |
16 #include "content/public/browser/notification_types.h" | |
17 #include "content/public/browser/render_widget_host_view.h" | |
18 #include "content/public/browser/web_contents.h" | |
19 | |
20 #if defined(OS_WIN) | |
21 #include <atlbase.h> | |
22 #include <atlcom.h> | |
23 #include "ui/base/win/atl_module.h" | |
24 #endif | |
25 | |
26 using content::AccessibilityNodeData; | |
27 using content::OpenURLParams; | |
28 using content::RenderViewHostImpl; | |
29 using content::RenderWidgetHostImpl; | |
30 using content::Referrer; | |
31 | |
32 namespace { | |
33 | |
34 class RendererAccessibilityBrowserTest : public InProcessBrowserTest { | |
35 public: | |
36 RendererAccessibilityBrowserTest() {} | |
37 | |
38 // Tell the renderer to send an accessibility tree, then wait for the | |
39 // notification that it's been received. | |
40 const AccessibilityNodeData& GetAccessibilityNodeDataTree( | |
41 AccessibilityMode accessibility_mode = AccessibilityModeComplete) { | |
42 ui_test_utils::WindowedNotificationObserver tree_updated_observer( | |
43 content::NOTIFICATION_RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED, | |
44 content::NotificationService::AllSources()); | |
45 content::RenderWidgetHostView* host_view = | |
46 chrome::GetActiveWebContents(browser())->GetRenderWidgetHostView(); | |
47 RenderWidgetHostImpl* host = | |
48 RenderWidgetHostImpl::From(host_view->GetRenderWidgetHost()); | |
49 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(host); | |
50 view_host->set_save_accessibility_tree_for_testing(true); | |
51 view_host->SetAccessibilityMode(accessibility_mode); | |
52 tree_updated_observer.Wait(); | |
53 return view_host->accessibility_tree_for_testing(); | |
54 } | |
55 | |
56 // Make sure each node in the tree has an unique id. | |
57 void RecursiveAssertUniqueIds( | |
58 const AccessibilityNodeData& node, base::hash_set<int>* ids) { | |
59 ASSERT_TRUE(ids->find(node.id) == ids->end()); | |
60 ids->insert(node.id); | |
61 for (size_t i = 0; i < node.children.size(); i++) | |
62 RecursiveAssertUniqueIds(node.children[i], ids); | |
63 } | |
64 | |
65 // InProcessBrowserTest | |
66 void SetUpInProcessBrowserTestFixture(); | |
67 void TearDownInProcessBrowserTestFixture(); | |
68 | |
69 protected: | |
70 std::string GetAttr(const AccessibilityNodeData& node, | |
71 const AccessibilityNodeData::StringAttribute attr); | |
72 int GetIntAttr(const AccessibilityNodeData& node, | |
73 const AccessibilityNodeData::IntAttribute attr); | |
74 bool GetBoolAttr(const AccessibilityNodeData& node, | |
75 const AccessibilityNodeData::BoolAttribute attr); | |
76 }; | |
77 | |
78 void RendererAccessibilityBrowserTest::SetUpInProcessBrowserTestFixture() { | |
79 #if defined(OS_WIN) | |
80 ui::win::CreateATLModuleIfNeeded(); | |
81 ::CoInitialize(NULL); | |
82 #endif | |
83 } | |
84 | |
85 void RendererAccessibilityBrowserTest::TearDownInProcessBrowserTestFixture() { | |
86 #if defined(OS_WIN) | |
87 ::CoUninitialize(); | |
88 #endif | |
89 } | |
90 | |
91 // Convenience method to get the value of a particular AccessibilityNodeData | |
92 // node attribute as a UTF-8 const char*. | |
93 std::string RendererAccessibilityBrowserTest::GetAttr( | |
94 const AccessibilityNodeData& node, | |
95 const AccessibilityNodeData::StringAttribute attr) { | |
96 std::map<AccessibilityNodeData::StringAttribute, string16>::const_iterator | |
97 iter = node.string_attributes.find(attr); | |
98 if (iter != node.string_attributes.end()) | |
99 return UTF16ToUTF8(iter->second); | |
100 else | |
101 return ""; | |
102 } | |
103 | |
104 // Convenience method to get the value of a particular AccessibilityNodeData | |
105 // node integer attribute. | |
106 int RendererAccessibilityBrowserTest::GetIntAttr( | |
107 const AccessibilityNodeData& node, | |
108 const AccessibilityNodeData::IntAttribute attr) { | |
109 std::map<AccessibilityNodeData::IntAttribute, int32>::const_iterator iter = | |
110 node.int_attributes.find(attr); | |
111 if (iter != node.int_attributes.end()) | |
112 return iter->second; | |
113 else | |
114 return -1; | |
115 } | |
116 | |
117 // Convenience method to get the value of a particular AccessibilityNodeData | |
118 // node boolean attribute. | |
119 bool RendererAccessibilityBrowserTest::GetBoolAttr( | |
120 const AccessibilityNodeData& node, | |
121 const AccessibilityNodeData::BoolAttribute attr) { | |
122 std::map<AccessibilityNodeData::BoolAttribute, bool>::const_iterator iter = | |
123 node.bool_attributes.find(attr); | |
124 if (iter != node.bool_attributes.end()) | |
125 return iter->second; | |
126 else | |
127 return false; | |
128 } | |
129 | |
130 // Marked flaky per http://crbug.com/101984 | |
131 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
132 DISABLED_CrossPlatformWebpageAccessibility) { | |
133 // Create a data url and load it. | |
134 const char url_str[] = | |
135 "data:text/html," | |
136 "<!doctype html>" | |
137 "<html><head><title>Accessibility Test</title></head>" | |
138 "<body><input type='button' value='push' /><input type='checkbox' />" | |
139 "</body></html>"; | |
140 GURL url(url_str); | |
141 browser()->OpenURL(OpenURLParams( | |
142 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
143 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
144 | |
145 // Check properties of the root element of the tree. | |
146 EXPECT_STREQ(url_str, | |
147 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_URL).c_str()); | |
148 EXPECT_STREQ( | |
149 "Accessibility Test", | |
150 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_TITLE).c_str()); | |
151 EXPECT_STREQ( | |
152 "html", GetAttr(tree, AccessibilityNodeData::ATTR_DOC_DOCTYPE).c_str()); | |
153 EXPECT_STREQ( | |
154 "text/html", | |
155 GetAttr(tree, AccessibilityNodeData::ATTR_DOC_MIMETYPE).c_str()); | |
156 EXPECT_STREQ("Accessibility Test", UTF16ToUTF8(tree.name).c_str()); | |
157 EXPECT_EQ(AccessibilityNodeData::ROLE_ROOT_WEB_AREA, tree.role); | |
158 | |
159 // Check properites of the BODY element. | |
160 ASSERT_EQ(1U, tree.children.size()); | |
161 const AccessibilityNodeData& body = tree.children[0]; | |
162 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, body.role); | |
163 EXPECT_STREQ("body", | |
164 GetAttr(body, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | |
165 EXPECT_STREQ("block", | |
166 GetAttr(body, AccessibilityNodeData::ATTR_DISPLAY).c_str()); | |
167 | |
168 // Check properties of the two children of the BODY element. | |
169 ASSERT_EQ(2U, body.children.size()); | |
170 | |
171 const AccessibilityNodeData& button = body.children[0]; | |
172 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button.role); | |
173 EXPECT_STREQ( | |
174 "input", GetAttr(button, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | |
175 EXPECT_STREQ("push", UTF16ToUTF8(button.name).c_str()); | |
176 EXPECT_STREQ( | |
177 "inline-block", | |
178 GetAttr(button, AccessibilityNodeData::ATTR_DISPLAY).c_str()); | |
179 ASSERT_EQ(2U, button.html_attributes.size()); | |
180 EXPECT_STREQ("type", UTF16ToUTF8(button.html_attributes[0].first).c_str()); | |
181 EXPECT_STREQ("button", UTF16ToUTF8(button.html_attributes[0].second).c_str()); | |
182 EXPECT_STREQ("value", UTF16ToUTF8(button.html_attributes[1].first).c_str()); | |
183 EXPECT_STREQ("push", UTF16ToUTF8(button.html_attributes[1].second).c_str()); | |
184 | |
185 const AccessibilityNodeData& checkbox = body.children[1]; | |
186 EXPECT_EQ(AccessibilityNodeData::ROLE_CHECKBOX, checkbox.role); | |
187 EXPECT_STREQ( | |
188 "input", GetAttr(checkbox, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | |
189 EXPECT_STREQ( | |
190 "inline-block", | |
191 GetAttr(checkbox, AccessibilityNodeData::ATTR_DISPLAY).c_str()); | |
192 ASSERT_EQ(1U, checkbox.html_attributes.size()); | |
193 EXPECT_STREQ( | |
194 "type", UTF16ToUTF8(checkbox.html_attributes[0].first).c_str()); | |
195 EXPECT_STREQ( | |
196 "checkbox", UTF16ToUTF8(checkbox.html_attributes[0].second).c_str()); | |
197 } | |
198 | |
199 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
200 CrossPlatformUnselectedEditableTextAccessibility) { | |
201 // Create a data url and load it. | |
202 const char url_str[] = | |
203 "data:text/html," | |
204 "<!doctype html>" | |
205 "<body>" | |
206 "<input value=\"Hello, world.\"/>" | |
207 "</body></html>"; | |
208 GURL url(url_str); | |
209 browser()->OpenURL(OpenURLParams( | |
210 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
211 | |
212 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
213 ASSERT_EQ(1U, tree.children.size()); | |
214 const AccessibilityNodeData& body = tree.children[0]; | |
215 ASSERT_EQ(1U, body.children.size()); | |
216 const AccessibilityNodeData& text = body.children[0]; | |
217 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role); | |
218 EXPECT_STREQ( | |
219 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | |
220 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); | |
221 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); | |
222 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); | |
223 | |
224 // TODO(dmazzoni): as soon as more accessibility code is cross-platform, | |
225 // this code should test that the accessible info is dynamically updated | |
226 // if the selection or value changes. | |
227 } | |
228 | |
229 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
230 CrossPlatformSelectedEditableTextAccessibility) { | |
231 // Create a data url and load it. | |
232 const char url_str[] = | |
233 "data:text/html," | |
234 "<!doctype html>" | |
235 "<body onload=\"document.body.children[0].select();\">" | |
236 "<input value=\"Hello, world.\"/>" | |
237 "</body></html>"; | |
238 GURL url(url_str); | |
239 browser()->OpenURL(OpenURLParams( | |
240 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
241 | |
242 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
243 ASSERT_EQ(1U, tree.children.size()); | |
244 const AccessibilityNodeData& body = tree.children[0]; | |
245 ASSERT_EQ(1U, body.children.size()); | |
246 const AccessibilityNodeData& text = body.children[0]; | |
247 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text.role); | |
248 EXPECT_STREQ( | |
249 "input", GetAttr(text, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | |
250 EXPECT_EQ(0, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_START)); | |
251 EXPECT_EQ(13, GetIntAttr(text, AccessibilityNodeData::ATTR_TEXT_SEL_END)); | |
252 EXPECT_STREQ("Hello, world.", UTF16ToUTF8(text.value).c_str()); | |
253 } | |
254 | |
255 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
256 CrossPlatformMultipleInheritanceAccessibility) { | |
257 // In a WebKit accessibility render tree for a table, each cell is a | |
258 // child of both a row and a column, so it appears to use multiple | |
259 // inheritance. Make sure that the AccessibilityNodeDataObject tree only | |
260 // keeps one copy of each cell, and uses an indirect child id for the | |
261 // additional reference to it. | |
262 const char url_str[] = | |
263 "data:text/html," | |
264 "<!doctype html>" | |
265 "<table border=1><tr><td>1</td><td>2</td></tr></table>"; | |
266 GURL url(url_str); | |
267 browser()->OpenURL(OpenURLParams( | |
268 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
269 | |
270 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
271 ASSERT_EQ(1U, tree.children.size()); | |
272 const AccessibilityNodeData& table = tree.children[0]; | |
273 EXPECT_EQ(AccessibilityNodeData::ROLE_TABLE, table.role); | |
274 const AccessibilityNodeData& row = table.children[0]; | |
275 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, row.role); | |
276 const AccessibilityNodeData& cell1 = row.children[0]; | |
277 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell1.role); | |
278 const AccessibilityNodeData& cell2 = row.children[1]; | |
279 EXPECT_EQ(AccessibilityNodeData::ROLE_CELL, cell2.role); | |
280 const AccessibilityNodeData& column1 = table.children[1]; | |
281 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column1.role); | |
282 EXPECT_EQ(0U, column1.children.size()); | |
283 EXPECT_EQ(1U, column1.indirect_child_ids.size()); | |
284 EXPECT_EQ(cell1.id, column1.indirect_child_ids[0]); | |
285 const AccessibilityNodeData& column2 = table.children[2]; | |
286 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, column2.role); | |
287 EXPECT_EQ(0U, column2.children.size()); | |
288 EXPECT_EQ(1U, column2.indirect_child_ids.size()); | |
289 EXPECT_EQ(cell2.id, column2.indirect_child_ids[0]); | |
290 } | |
291 | |
292 IN_PROC_BROWSER_TEST_F( | |
293 RendererAccessibilityBrowserTest, | |
294 CrossPlatformMultipleInheritanceAccessibility2) { | |
295 // Here's another html snippet where WebKit puts the same node as a child | |
296 // of two different parents. Instead of checking the exact output, just | |
297 // make sure that no id is reused in the resulting tree. | |
298 const char url_str[] = | |
299 "data:text/html," | |
300 "<!doctype html>" | |
301 "<script>\n" | |
302 " document.writeln('<q><section></section></q><q><li>');\n" | |
303 " setTimeout(function() {\n" | |
304 " document.close();\n" | |
305 " }, 1);\n" | |
306 "</script>"; | |
307 GURL url(url_str); | |
308 browser()->OpenURL(OpenURLParams( | |
309 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
310 | |
311 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
312 base::hash_set<int> ids; | |
313 RecursiveAssertUniqueIds(tree, &ids); | |
314 } | |
315 | |
316 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
317 CrossPlatformIframeAccessibility) { | |
318 // Create a data url and load it. | |
319 const char url_str[] = | |
320 "data:text/html," | |
321 "<!doctype html><html><body>" | |
322 "<button>Button 1</button>" | |
323 "<iframe src='data:text/html," | |
324 "<!doctype html><html><body><button>Button 2</button></body></html>" | |
325 "'></iframe>" | |
326 "<button>Button 3</button>" | |
327 "</body></html>"; | |
328 GURL url(url_str); | |
329 browser()->OpenURL(OpenURLParams( | |
330 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
331 | |
332 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
333 ASSERT_EQ(1U, tree.children.size()); | |
334 const AccessibilityNodeData& body = tree.children[0]; | |
335 ASSERT_EQ(3U, body.children.size()); | |
336 | |
337 const AccessibilityNodeData& button1 = body.children[0]; | |
338 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button1.role); | |
339 EXPECT_STREQ("Button 1", UTF16ToUTF8(button1.name).c_str()); | |
340 | |
341 const AccessibilityNodeData& iframe = body.children[1]; | |
342 EXPECT_STREQ("iframe", | |
343 GetAttr(iframe, AccessibilityNodeData::ATTR_HTML_TAG).c_str()); | |
344 ASSERT_EQ(1U, iframe.children.size()); | |
345 | |
346 const AccessibilityNodeData& scroll_area = iframe.children[0]; | |
347 EXPECT_EQ(AccessibilityNodeData::ROLE_SCROLLAREA, scroll_area.role); | |
348 ASSERT_EQ(1U, scroll_area.children.size()); | |
349 | |
350 const AccessibilityNodeData& sub_document = scroll_area.children[0]; | |
351 EXPECT_EQ(AccessibilityNodeData::ROLE_WEB_AREA, sub_document.role); | |
352 ASSERT_EQ(1U, sub_document.children.size()); | |
353 | |
354 const AccessibilityNodeData& sub_body = sub_document.children[0]; | |
355 ASSERT_EQ(1U, sub_body.children.size()); | |
356 | |
357 const AccessibilityNodeData& button2 = sub_body.children[0]; | |
358 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button2.role); | |
359 EXPECT_STREQ("Button 2", UTF16ToUTF8(button2.name).c_str()); | |
360 | |
361 const AccessibilityNodeData& button3 = body.children[2]; | |
362 EXPECT_EQ(AccessibilityNodeData::ROLE_BUTTON, button3.role); | |
363 EXPECT_STREQ("Button 3", UTF16ToUTF8(button3.name).c_str()); | |
364 } | |
365 | |
366 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
367 CrossPlatformDuplicateChildrenAccessibility) { | |
368 // Here's another html snippet where WebKit has a parent node containing | |
369 // two duplicate child nodes. Instead of checking the exact output, just | |
370 // make sure that no id is reused in the resulting tree. | |
371 const char url_str[] = | |
372 "data:text/html," | |
373 "<!doctype html>" | |
374 "<em><code ><h4 ></em>"; | |
375 GURL url(url_str); | |
376 browser()->OpenURL(OpenURLParams( | |
377 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
378 | |
379 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
380 base::hash_set<int> ids; | |
381 RecursiveAssertUniqueIds(tree, &ids); | |
382 } | |
383 | |
384 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
385 CrossPlatformTableSpan) { | |
386 // +---+---+---+ | |
387 // | 1 | 2 | | |
388 // +---+---+---+ | |
389 // | 3 | 4 | | |
390 // +---+---+---+ | |
391 | |
392 const char url_str[] = | |
393 "data:text/html," | |
394 "<!doctype html>" | |
395 "<table border=1>" | |
396 " <tr>" | |
397 " <td colspan=2>1</td><td>2</td>" | |
398 " </tr>" | |
399 " <tr>" | |
400 " <td>3</td><td colspan=2>4</td>" | |
401 " </tr>" | |
402 "</table>"; | |
403 GURL url(url_str); | |
404 browser()->OpenURL(OpenURLParams( | |
405 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
406 | |
407 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
408 const AccessibilityNodeData& table = tree.children[0]; | |
409 EXPECT_EQ(AccessibilityNodeData::ROLE_TABLE, table.role); | |
410 ASSERT_GE(table.children.size(), 5U); | |
411 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, table.children[0].role); | |
412 EXPECT_EQ(AccessibilityNodeData::ROLE_ROW, table.children[1].role); | |
413 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[2].role); | |
414 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[3].role); | |
415 EXPECT_EQ(AccessibilityNodeData::ROLE_COLUMN, table.children[4].role); | |
416 EXPECT_EQ(3, | |
417 GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT)); | |
418 EXPECT_EQ(2, GetIntAttr(table, AccessibilityNodeData::ATTR_TABLE_ROW_COUNT)); | |
419 | |
420 const AccessibilityNodeData& cell1 = table.children[0].children[0]; | |
421 const AccessibilityNodeData& cell2 = table.children[0].children[1]; | |
422 const AccessibilityNodeData& cell3 = table.children[1].children[0]; | |
423 const AccessibilityNodeData& cell4 = table.children[1].children[1]; | |
424 | |
425 ASSERT_EQ(6U, table.cell_ids.size()); | |
426 EXPECT_EQ(cell1.id, table.cell_ids[0]); | |
427 EXPECT_EQ(cell1.id, table.cell_ids[1]); | |
428 EXPECT_EQ(cell2.id, table.cell_ids[2]); | |
429 EXPECT_EQ(cell3.id, table.cell_ids[3]); | |
430 EXPECT_EQ(cell4.id, table.cell_ids[4]); | |
431 EXPECT_EQ(cell4.id, table.cell_ids[5]); | |
432 | |
433 EXPECT_EQ(0, GetIntAttr(cell1, | |
434 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); | |
435 EXPECT_EQ(0, GetIntAttr(cell1, | |
436 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX)); | |
437 EXPECT_EQ(2, GetIntAttr(cell1, | |
438 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); | |
439 EXPECT_EQ(1, GetIntAttr(cell1, | |
440 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN)); | |
441 EXPECT_EQ(2, GetIntAttr(cell2, | |
442 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); | |
443 EXPECT_EQ(1, GetIntAttr(cell2, | |
444 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); | |
445 EXPECT_EQ(0, GetIntAttr(cell3, | |
446 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); | |
447 EXPECT_EQ(1, GetIntAttr(cell3, | |
448 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); | |
449 EXPECT_EQ(1, GetIntAttr(cell4, | |
450 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX)); | |
451 EXPECT_EQ(2, GetIntAttr(cell4, | |
452 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN)); | |
453 } | |
454 | |
455 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
456 CrossPlatformWritableElement) { | |
457 const char url_str[] = | |
458 "data:text/html," | |
459 "<!doctype html>" | |
460 "<div role='textbox' tabindex=0>" | |
461 " Some text" | |
462 "</div>"; | |
463 GURL url(url_str); | |
464 browser()->OpenURL(OpenURLParams( | |
465 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
466 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree(); | |
467 | |
468 ASSERT_EQ(1U, tree.children.size()); | |
469 const AccessibilityNodeData& textbox = tree.children[0]; | |
470 | |
471 EXPECT_EQ( | |
472 true, GetBoolAttr(textbox, AccessibilityNodeData::ATTR_CAN_SET_VALUE)); | |
473 } | |
474 | |
475 IN_PROC_BROWSER_TEST_F(RendererAccessibilityBrowserTest, | |
476 CrossPlatformEditableTextOnlyMode) { | |
477 const char url_str[] = | |
478 "data:text/html," | |
479 "<!doctype html>" | |
480 "<h1>Heading</h1>" | |
481 "<input type=text value=text0>" | |
482 "<input disabled type=text value=skip0>" | |
483 "<textarea>text1</textarea>" | |
484 "<textarea disabled>skip1</textarea>" | |
485 "<div role=textbox>text2</div>" | |
486 "<div contentEditable>text3</div>" | |
487 "<ul>" | |
488 " <li><input type=text value=text4>" | |
489 " <li><textarea>text5</textarea>" | |
490 " <li><div role=textbox>text6</div>" | |
491 " <li><div contentEditable>text7</div>" | |
492 " <li><button>button</button>" | |
493 "</ul>"; | |
494 | |
495 GURL url(url_str); | |
496 browser()->OpenURL(OpenURLParams( | |
497 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | |
498 const AccessibilityNodeData& tree = GetAccessibilityNodeDataTree( | |
499 AccessibilityModeEditableTextOnly); | |
500 | |
501 const AccessibilityNodeData& text0 = tree.children[0]; | |
502 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text0.role); | |
503 EXPECT_STREQ("text0", UTF16ToUTF8(text0.value).c_str()); | |
504 | |
505 const AccessibilityNodeData& text1 = tree.children[1]; | |
506 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXTAREA, text1.role); | |
507 EXPECT_STREQ("text1", UTF16ToUTF8(text1.value).c_str()); | |
508 | |
509 const AccessibilityNodeData& text2 = tree.children[2]; | |
510 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text2.role); | |
511 EXPECT_STREQ("text2", UTF16ToUTF8(text2.value).c_str()); | |
512 | |
513 const AccessibilityNodeData& text3 = tree.children[3]; | |
514 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, text3.role); | |
515 | |
516 const AccessibilityNodeData& text4 = tree.children[4]; | |
517 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text4.role); | |
518 EXPECT_STREQ("text4", UTF16ToUTF8(text4.value).c_str()); | |
519 | |
520 const AccessibilityNodeData& text5 = tree.children[5]; | |
521 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXTAREA, text5.role); | |
522 EXPECT_STREQ("text5", UTF16ToUTF8(text5.value).c_str()); | |
523 | |
524 const AccessibilityNodeData& text6 = tree.children[6]; | |
525 EXPECT_EQ(AccessibilityNodeData::ROLE_TEXT_FIELD, text6.role); | |
526 EXPECT_STREQ("text6", UTF16ToUTF8(text6.value).c_str()); | |
527 | |
528 const AccessibilityNodeData& text7 = tree.children[7]; | |
529 EXPECT_EQ(AccessibilityNodeData::ROLE_GROUP, text7.role); | |
530 } | |
531 | |
532 } // namespace | |
OLD | NEW |