Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1578)

Side by Side Diff: content/browser/accessibility/accessibility_win_browsertest.cc

Issue 329863003: Fix accessibility in Windows x64 build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typecase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/legacy_render_widget_host_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/win/scoped_bstr.h" 9 #include "base/win/scoped_bstr.h"
10 #include "base/win/scoped_comptr.h" 10 #include "base/win/scoped_comptr.h"
11 #include "base/win/scoped_variant.h" 11 #include "base/win/scoped_variant.h"
12 #include "content/browser/accessibility/accessibility_tree_formatter_utils_win.h " 12 #include "content/browser/accessibility/accessibility_tree_formatter_utils_win.h "
13 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/render_frame_host.h" 16 #include "content/public/browser/render_frame_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 17 #include "content/public/browser/render_widget_host_view.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/url_constants.h" 19 #include "content/public/common/url_constants.h"
20 #include "content/public/test/content_browser_test.h" 20 #include "content/public/test/content_browser_test.h"
21 #include "content/public/test/content_browser_test_utils.h" 21 #include "content/public/test/content_browser_test_utils.h"
22 #include "content/shell/browser/shell.h" 22 #include "content/shell/browser/shell.h"
23 #include "content/test/accessibility_browser_test_utils.h" 23 #include "content/test/accessibility_browser_test_utils.h"
24 #include "third_party/iaccessible2/ia2_api_all.h" 24 #include "third_party/iaccessible2/ia2_api_all.h"
25 #include "third_party/isimpledom/ISimpleDOMNode.h" 25 #include "third_party/isimpledom/ISimpleDOMNode.h"
26 26 #include "ui/aura/window.h"
27 // TODO(dmazzoni): Disabled accessibility tests on Win64. crbug.com/179717 27 #include "ui/aura/window_tree_host.h"
28 #if defined(ARCH_CPU_X86_64)
29 #define MAYBE(x) DISABLED_##x
30 #else
31 #define MAYBE(x) x
32 #endif
33 28
34 namespace content { 29 namespace content {
35 30
36 namespace { 31 namespace {
37 32
38
39 // Helpers -------------------------------------------------------------------- 33 // Helpers --------------------------------------------------------------------
40 34
41 base::win::ScopedComPtr<IAccessible> GetAccessibleFromResultVariant( 35 base::win::ScopedComPtr<IAccessible> GetAccessibleFromResultVariant(
42 IAccessible* parent, 36 IAccessible* parent,
43 VARIANT* var) { 37 VARIANT* var) {
44 base::win::ScopedComPtr<IAccessible> ptr; 38 base::win::ScopedComPtr<IAccessible> ptr;
45 switch (V_VT(var)) { 39 switch (V_VT(var)) {
46 case VT_DISPATCH: { 40 case VT_DISPATCH: {
47 IDispatch* dispatch = V_DISPATCH(var); 41 IDispatch* dispatch = V_DISPATCH(var);
48 if (dispatch) 42 if (dispatch)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 node->get_accName(childid_self, name_bstr.Receive()); 78 node->get_accName(childid_self, name_bstr.Receive());
85 std::wstring name(name_bstr, name_bstr.Length()); 79 std::wstring name(name_bstr, name_bstr.Length());
86 base::win::ScopedVariant role; 80 base::win::ScopedVariant role;
87 node->get_accRole(childid_self, role.Receive()); 81 node->get_accRole(childid_self, role.Receive());
88 ASSERT_EQ(VT_I4, role.type()); 82 ASSERT_EQ(VT_I4, role.type());
89 83
90 // Print the accessibility tree as we go, because if this test fails 84 // Print the accessibility tree as we go, because if this test fails
91 // on the bots, this is really helpful in figuring out why. 85 // on the bots, this is really helpful in figuring out why.
92 for (int i = 0; i < depth; i++) 86 for (int i = 0; i < depth; i++)
93 printf(" "); 87 printf(" ");
94 printf("role=%d name=%s\n", V_I4(&role), base::WideToUTF8(name).c_str()); 88 printf("role=%s name=%s\n",
89 base::WideToUTF8(IAccessibleRoleToString(V_I4(&role))).c_str(),
90 base::WideToUTF8(name).c_str());
95 91
96 if (expected_role == V_I4(&role) && expected_name == name) { 92 if (expected_role == V_I4(&role) && expected_name == name) {
97 *found = true; 93 *found = true;
98 return; 94 return;
99 } 95 }
100 96
101 LONG child_count = 0; 97 LONG child_count = 0;
102 HRESULT hr = node->get_accChildCount(&child_count); 98 HRESULT hr = node->get_accChildCount(&child_count);
103 ASSERT_EQ(S_OK, hr); 99 ASSERT_EQ(S_OK, hr);
104 100
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 shell(), AccessibilityModeComplete, 147 shell(), AccessibilityModeComplete,
152 ui::AX_EVENT_LOAD_COMPLETE); 148 ui::AX_EVENT_LOAD_COMPLETE);
153 GURL html_data_url("data:text/html," + html); 149 GURL html_data_url("data:text/html," + html);
154 NavigateToURL(shell(), html_data_url); 150 NavigateToURL(shell(), html_data_url);
155 waiter.WaitForNotification(); 151 waiter.WaitForNotification();
156 } 152 }
157 153
158 // Retrieve the MSAA client accessibility object for the Render Widget Host View 154 // Retrieve the MSAA client accessibility object for the Render Widget Host View
159 // of the selected tab. 155 // of the selected tab.
160 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { 156 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() {
161 HWND hwnd_render_widget_host_view = 157 content::WebContents* web_contents = shell()->web_contents();
162 shell()->web_contents()->GetRenderWidgetHostView()->GetNativeView(); 158 return web_contents->GetRenderWidgetHostView()->GetNativeViewAccessible();
163
164 // Invoke windows screen reader detection by sending the WM_GETOBJECT message
165 // with kIdCustom as the LPARAM.
166 const int32 kIdCustom = 1;
167 SendMessage(
168 hwnd_render_widget_host_view, WM_GETOBJECT, OBJID_CLIENT, kIdCustom);
169
170 IAccessible* accessible;
171 HRESULT hr = AccessibleObjectFromWindow(
172 hwnd_render_widget_host_view, OBJID_CLIENT,
173 IID_IAccessible, reinterpret_cast<void**>(&accessible));
174
175 EXPECT_EQ(S_OK, hr);
176 EXPECT_NE(accessible, reinterpret_cast<IAccessible*>(NULL));
177
178 return accessible;
179 } 159 }
180 160
181 void AccessibilityWinBrowserTest::ExecuteScript(const std::wstring& script) { 161 void AccessibilityWinBrowserTest::ExecuteScript(const std::wstring& script) {
182 shell()->web_contents()->GetMainFrame()->ExecuteJavaScript(script); 162 shell()->web_contents()->GetMainFrame()->ExecuteJavaScript(script);
183 } 163 }
184 164
185 165
186 // AccessibleChecker ---------------------------------------------------------- 166 // AccessibleChecker ----------------------------------------------------------
187 167
188 class AccessibleChecker { 168 class AccessibleChecker {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return base::string16(V_BSTR(&role), SysStringLen(V_BSTR(&role))); 391 return base::string16(V_BSTR(&role), SysStringLen(V_BSTR(&role)));
412 return base::string16(); 392 return base::string16();
413 } 393 }
414 394
415 } // namespace 395 } // namespace
416 396
417 397
418 // Tests ---------------------------------------------------------------------- 398 // Tests ----------------------------------------------------------------------
419 399
420 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 400 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
421 MAYBE(TestBusyAccessibilityTree)) { 401 TestBusyAccessibilityTree) {
422 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); 402 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
423 403
424 // The initial accessible returned should have state STATE_SYSTEM_BUSY while 404 // The initial accessible returned should have state STATE_SYSTEM_BUSY while
425 // the accessibility tree is being requested from the renderer. 405 // the accessibility tree is being requested from the renderer.
426 AccessibleChecker document1_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 406 AccessibleChecker document1_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
427 std::wstring()); 407 std::wstring());
428 document1_checker.SetExpectedState( 408 document1_checker.SetExpectedState(
429 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED | 409 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED |
430 STATE_SYSTEM_BUSY); 410 STATE_SYSTEM_BUSY);
431 document1_checker.CheckAccessible(GetRendererAccessible()); 411 document1_checker.CheckAccessible(GetRendererAccessible());
432 } 412 }
433 413
434 // Flaky, http://crbug.com/167320 .
435 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
436 DISABLED_TestRendererAccessibilityTree) {
437 LoadInitialAccessibilityTreeFromHtml(
438 "<html><head><title>Accessibility Win Test</title></head>"
439 "<body><input type='button' value='push' /><input type='checkbox' />"
440 "</body></html>");
441
442 // Check the browser's copy of the renderer accessibility tree.
443 AccessibleChecker button_checker(L"push", ROLE_SYSTEM_PUSHBUTTON,
444 std::wstring());
445 AccessibleChecker checkbox_checker(std::wstring(), ROLE_SYSTEM_CHECKBUTTON,
446 std::wstring());
447 AccessibleChecker body_checker(std::wstring(), L"body", IA2_ROLE_SECTION,
448 std::wstring());
449 AccessibleChecker document2_checker(L"Accessibility Win Test",
450 ROLE_SYSTEM_DOCUMENT, std::wstring());
451 body_checker.AppendExpectedChild(&button_checker);
452 body_checker.AppendExpectedChild(&checkbox_checker);
453 document2_checker.AppendExpectedChild(&body_checker);
454 document2_checker.CheckAccessible(GetRendererAccessible());
455
456 // Check that document accessible has a parent accessible.
457 base::win::ScopedComPtr<IAccessible> document_accessible(
458 GetRendererAccessible());
459 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
460 base::win::ScopedComPtr<IDispatch> parent_dispatch;
461 HRESULT hr = document_accessible->get_accParent(parent_dispatch.Receive());
462 EXPECT_EQ(S_OK, hr);
463 EXPECT_NE(parent_dispatch, reinterpret_cast<IDispatch*>(NULL));
464
465 // Navigate to another page.
466 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
467
468 // Verify that the IAccessible reference still points to a valid object and
469 // that calls to its methods fail since the tree is no longer valid after
470 // the page navagation.
471 base::win::ScopedBstr name;
472 base::win::ScopedVariant childid_self(CHILDID_SELF);
473 hr = document_accessible->get_accName(childid_self, name.Receive());
474 ASSERT_EQ(E_FAIL, hr);
475 }
476
477 // Periodically failing. See crbug.com/145537 414 // Periodically failing. See crbug.com/145537
478 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 415 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
479 DISABLED_TestNotificationActiveDescendantChanged) { 416 DISABLED_TestNotificationActiveDescendantChanged) {
480 LoadInitialAccessibilityTreeFromHtml( 417 LoadInitialAccessibilityTreeFromHtml(
481 "<ul tabindex='-1' role='radiogroup' aria-label='ul'>" 418 "<ul tabindex='-1' role='radiogroup' aria-label='ul'>"
482 "<li id='li'>li</li></ul>"); 419 "<li id='li'>li</li></ul>");
483 420
484 // Check the browser's copy of the renderer accessibility tree. 421 // Check the browser's copy of the renderer accessibility tree.
485 AccessibleChecker list_marker_checker(L"\x2022", ROLE_SYSTEM_TEXT, 422 AccessibleChecker list_marker_checker(L"\x2022", ROLE_SYSTEM_TEXT,
486 std::wstring()); 423 std::wstring());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 waiter->WaitForNotification(); 459 waiter->WaitForNotification();
523 460
524 // Check that the accessibility tree of the browser has been updated. 461 // Check that the accessibility tree of the browser has been updated.
525 list_item_checker.SetExpectedState( 462 list_item_checker.SetExpectedState(
526 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); 463 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
527 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 464 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
528 document_checker.CheckAccessible(GetRendererAccessible()); 465 document_checker.CheckAccessible(GetRendererAccessible());
529 } 466 }
530 467
531 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 468 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
532 MAYBE(TestNotificationCheckedStateChanged)) { 469 TestNotificationCheckedStateChanged) {
533 LoadInitialAccessibilityTreeFromHtml( 470 LoadInitialAccessibilityTreeFromHtml(
534 "<body><input type='checkbox' /></body>"); 471 "<body><input type='checkbox' /></body>");
535 472
536 // Check the browser's copy of the renderer accessibility tree. 473 // Check the browser's copy of the renderer accessibility tree.
537 AccessibleChecker checkbox_checker(std::wstring(), ROLE_SYSTEM_CHECKBUTTON, 474 AccessibleChecker checkbox_checker(std::wstring(), ROLE_SYSTEM_CHECKBUTTON,
538 std::wstring()); 475 std::wstring());
539 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 476 checkbox_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
540 AccessibleChecker body_checker(std::wstring(), L"body", IA2_ROLE_SECTION, 477 AccessibleChecker body_checker(std::wstring(), L"body", IA2_ROLE_SECTION,
541 std::wstring()); 478 std::wstring());
542 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 479 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
(...skipping 10 matching lines...) Expand all
553 ExecuteScript(L"document.body.children[0].checked=true"); 490 ExecuteScript(L"document.body.children[0].checked=true");
554 waiter->WaitForNotification(); 491 waiter->WaitForNotification();
555 492
556 // Check that the accessibility tree of the browser has been updated. 493 // Check that the accessibility tree of the browser has been updated.
557 checkbox_checker.SetExpectedState( 494 checkbox_checker.SetExpectedState(
558 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); 495 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE);
559 document_checker.CheckAccessible(GetRendererAccessible()); 496 document_checker.CheckAccessible(GetRendererAccessible());
560 } 497 }
561 498
562 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 499 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
563 MAYBE(TestNotificationChildrenChanged)) { 500 TestNotificationChildrenChanged) {
564 // The role attribute causes the node to be in the accessibility tree. 501 // The role attribute causes the node to be in the accessibility tree.
565 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); 502 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>");
566 503
567 // Check the browser's copy of the renderer accessibility tree. 504 // Check the browser's copy of the renderer accessibility tree.
568 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 505 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
569 std::wstring()); 506 std::wstring());
570 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 507 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
571 std::wstring()); 508 std::wstring());
572 document_checker.AppendExpectedChild(&group_checker); 509 document_checker.AppendExpectedChild(&group_checker);
573 document_checker.CheckAccessible(GetRendererAccessible()); 510 document_checker.CheckAccessible(GetRendererAccessible());
574 511
575 // Change the children of the document body. 512 // Change the children of the document body.
576 scoped_ptr<AccessibilityNotificationWaiter> waiter( 513 scoped_ptr<AccessibilityNotificationWaiter> waiter(
577 new AccessibilityNotificationWaiter( 514 new AccessibilityNotificationWaiter(
578 shell(), 515 shell(),
579 AccessibilityModeComplete, 516 AccessibilityModeComplete,
580 ui::AX_EVENT_CHILDREN_CHANGED)); 517 ui::AX_EVENT_CHILDREN_CHANGED));
581 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); 518 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'");
582 waiter->WaitForNotification(); 519 waiter->WaitForNotification();
583 520
584 // Check that the accessibility tree of the browser has been updated. 521 // Check that the accessibility tree of the browser has been updated.
585 AccessibleChecker text_checker(L"new text", ROLE_SYSTEM_TEXT, std::wstring()); 522 AccessibleChecker text_checker(
523 L"new text", ROLE_SYSTEM_STATICTEXT, std::wstring());
586 group_checker.AppendExpectedChild(&text_checker); 524 group_checker.AppendExpectedChild(&text_checker);
587 document_checker.CheckAccessible(GetRendererAccessible()); 525 document_checker.CheckAccessible(GetRendererAccessible());
588 } 526 }
589 527
590 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 528 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
591 MAYBE(TestNotificationChildrenChanged2)) { 529 TestNotificationChildrenChanged2) {
592 // The role attribute causes the node to be in the accessibility tree. 530 // The role attribute causes the node to be in the accessibility tree.
593 LoadInitialAccessibilityTreeFromHtml( 531 LoadInitialAccessibilityTreeFromHtml(
594 "<div role=group style='visibility: hidden'>text</div>"); 532 "<div role=group style='visibility: hidden'>text</div>");
595 533
596 // Check the accessible tree of the browser. 534 // Check the accessible tree of the browser.
597 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 535 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
598 std::wstring()); 536 std::wstring());
599 document_checker.CheckAccessible(GetRendererAccessible()); 537 document_checker.CheckAccessible(GetRendererAccessible());
600 538
601 // Change the children of the document body. 539 // Change the children of the document body.
602 scoped_ptr<AccessibilityNotificationWaiter> waiter( 540 scoped_ptr<AccessibilityNotificationWaiter> waiter(
603 new AccessibilityNotificationWaiter( 541 new AccessibilityNotificationWaiter(
604 shell(), AccessibilityModeComplete, 542 shell(), AccessibilityModeComplete,
605 ui::AX_EVENT_CHILDREN_CHANGED)); 543 ui::AX_EVENT_CHILDREN_CHANGED));
606 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); 544 ExecuteScript(L"document.body.children[0].style.visibility='visible'");
607 waiter->WaitForNotification(); 545 waiter->WaitForNotification();
608 546
609 // Check that the accessibility tree of the browser has been updated. 547 // Check that the accessibility tree of the browser has been updated.
610 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_TEXT, 548 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_STATICTEXT,
611 std::wstring()); 549 std::wstring());
612 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 550 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
613 std::wstring()); 551 std::wstring());
614 document_checker.AppendExpectedChild(&group_checker); 552 document_checker.AppendExpectedChild(&group_checker);
615 group_checker.AppendExpectedChild(&static_text_checker); 553 group_checker.AppendExpectedChild(&static_text_checker);
616 document_checker.CheckAccessible(GetRendererAccessible()); 554 document_checker.CheckAccessible(GetRendererAccessible());
617 } 555 }
618 556
619 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 557 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
620 MAYBE(TestNotificationFocusChanged)) { 558 TestNotificationFocusChanged) {
621 // The role attribute causes the node to be in the accessibility tree. 559 // The role attribute causes the node to be in the accessibility tree.
622 LoadInitialAccessibilityTreeFromHtml("<div role=group tabindex='-1'></div>"); 560 LoadInitialAccessibilityTreeFromHtml("<div role=group tabindex='-1'></div>");
623 561
624 // Check the browser's copy of the renderer accessibility tree. 562 // Check the browser's copy of the renderer accessibility tree.
625 SCOPED_TRACE("Check initial tree"); 563 SCOPED_TRACE("Check initial tree");
626 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 564 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
627 std::wstring()); 565 std::wstring());
628 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 566 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
629 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 567 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
630 std::wstring()); 568 std::wstring());
(...skipping 27 matching lines...) Expand all
658 ASSERT_EQ(S_OK, hr); 596 ASSERT_EQ(S_OK, hr);
659 waiter->WaitForNotification(); 597 waiter->WaitForNotification();
660 598
661 // Check that the accessibility tree of the browser has been updated. 599 // Check that the accessibility tree of the browser has been updated.
662 SCOPED_TRACE("Check updated tree after focusing document again"); 600 SCOPED_TRACE("Check updated tree after focusing document again");
663 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 601 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
664 document_checker.CheckAccessible(GetRendererAccessible()); 602 document_checker.CheckAccessible(GetRendererAccessible());
665 } 603 }
666 604
667 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 605 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
668 MAYBE(TestNotificationValueChanged)) { 606 TestNotificationValueChanged) {
669 LoadInitialAccessibilityTreeFromHtml( 607 LoadInitialAccessibilityTreeFromHtml(
670 "<body><input type='text' value='old value'/></body>"); 608 "<body><input type='text' value='old value'/></body>");
671 609
672 // Check the browser's copy of the renderer accessibility tree. 610 // Check the browser's copy of the renderer accessibility tree.
673 AccessibleChecker text_field_checker(std::wstring(), ROLE_SYSTEM_TEXT, 611 AccessibleChecker text_field_checker(std::wstring(), ROLE_SYSTEM_TEXT,
674 L"old value"); 612 L"old value");
675 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); 613 text_field_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE);
676 AccessibleChecker body_checker(std::wstring(), L"body", IA2_ROLE_SECTION, 614 AccessibleChecker body_checker(std::wstring(), L"body", IA2_ROLE_SECTION,
677 std::wstring()); 615 std::wstring());
678 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 616 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
679 std::wstring()); 617 std::wstring());
680 body_checker.AppendExpectedChild(&text_field_checker); 618 body_checker.AppendExpectedChild(&text_field_checker);
681 document_checker.AppendExpectedChild(&body_checker); 619 document_checker.AppendExpectedChild(&body_checker);
682 document_checker.CheckAccessible(GetRendererAccessible()); 620 document_checker.CheckAccessible(GetRendererAccessible());
683 621
684 // Set the value of the text control 622 // Set the value of the text control
685 scoped_ptr<AccessibilityNotificationWaiter> waiter( 623 scoped_ptr<AccessibilityNotificationWaiter> waiter(
686 new AccessibilityNotificationWaiter( 624 new AccessibilityNotificationWaiter(
687 shell(), AccessibilityModeComplete, 625 shell(), AccessibilityModeComplete,
688 ui::AX_EVENT_VALUE_CHANGE)); 626 ui::AX_EVENT_VALUE_CHANGED));
689 ExecuteScript(L"document.body.children[0].value='new value'"); 627 ExecuteScript(L"document.body.children[0].value='new value'");
690 waiter->WaitForNotification(); 628 waiter->WaitForNotification();
691 629
692 // Check that the accessibility tree of the browser has been updated. 630 // Check that the accessibility tree of the browser has been updated.
693 text_field_checker.SetExpectedValue(L"new value"); 631 text_field_checker.SetExpectedValue(L"new value");
694 document_checker.CheckAccessible(GetRendererAccessible()); 632 document_checker.CheckAccessible(GetRendererAccessible());
695 } 633 }
696 634
697 // This test verifies that the web content's accessibility tree is a 635 // This test verifies that the web content's accessibility tree is a
698 // descendant of the main browser window's accessibility tree, so that 636 // descendant of the main browser window's accessibility tree, so that
699 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's 637 // tools like AccExplorer32 or AccProbe can be used to examine Chrome's
700 // accessibility support. 638 // accessibility support.
701 // 639 //
702 // If you made a change and this test now fails, check that the NativeViewHost 640 // If you made a change and this test now fails, check that the NativeViewHost
703 // that wraps the tab contents returns the IAccessible implementation 641 // that wraps the tab contents returns the IAccessible implementation
704 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible(). 642 // provided by RenderWidgetHostViewWin in GetNativeViewAccessible().
705 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 643 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
706 MAYBE(ContainsRendererAccessibilityTree)) { 644 ContainsRendererAccessibilityTree) {
707 LoadInitialAccessibilityTreeFromHtml( 645 LoadInitialAccessibilityTreeFromHtml(
708 "<html><head><title>MyDocument</title></head>" 646 "<html><head><title>MyDocument</title></head>"
709 "<body>Content</body></html>"); 647 "<body>Content</body></html>");
710 648
711 // Get the accessibility object for the browser window. 649 // Get the accessibility object for the window tree host.
712 HWND browser_hwnd = shell()->window(); 650 aura::Window* window = shell()->window();
651 CHECK(window);
652 aura::WindowTreeHost* window_tree_host = window->GetHost();
653 CHECK(window_tree_host);
654 HWND hwnd = window_tree_host->GetAcceleratedWidget();
655 CHECK(hwnd);
713 base::win::ScopedComPtr<IAccessible> browser_accessible; 656 base::win::ScopedComPtr<IAccessible> browser_accessible;
714 HRESULT hr = AccessibleObjectFromWindow( 657 HRESULT hr = AccessibleObjectFromWindow(
715 browser_hwnd, 658 hwnd,
716 OBJID_WINDOW, 659 OBJID_WINDOW,
717 IID_IAccessible, 660 IID_IAccessible,
718 reinterpret_cast<void**>(browser_accessible.Receive())); 661 reinterpret_cast<void**>(browser_accessible.Receive()));
719 ASSERT_EQ(S_OK, hr); 662 ASSERT_EQ(S_OK, hr);
720 663
721 bool found = false; 664 bool found = false;
722 RecursiveFindNodeInAccessibilityTree( 665 RecursiveFindNodeInAccessibilityTree(
723 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found); 666 browser_accessible.get(), ROLE_SYSTEM_DOCUMENT, L"MyDocument", 0, &found);
724 ASSERT_EQ(found, true); 667 ASSERT_EQ(found, true);
725 } 668 }
726 669
727 // Disabled because of http://crbug.com/144390.
728 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, 670 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
729 DISABLED_TestToggleButtonRoleAndStates) { 671 SupportsISimpleDOM) {
730 AccessibleChecker* button_checker;
731 std::string button_html("data:text/html,");
732 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
733 std::wstring());
734 AccessibleChecker body_checker(std::wstring(), L"body", IA2_ROLE_SECTION,
735 std::wstring());
736 document_checker.AppendExpectedChild(&body_checker);
737
738 // Temporary macro
739 #define ADD_BUTTON(html, ia2_role, state) \
740 button_html += html; \
741 button_checker = new AccessibleChecker(L"x", ROLE_SYSTEM_PUSHBUTTON, \
742 ia2_role, std::wstring()); \
743 button_checker->SetExpectedState(state); \
744 body_checker.AppendExpectedChild(button_checker)
745
746 // If aria-pressed is 'undefined', empty or not present, use PUSHBUTTON
747 // Otherwise use TOGGLE_BUTTON, even if the value is invalid.
748 // The spec does this in an attempt future-proof in case new values are added.
749 ADD_BUTTON("<span role='button' aria-pressed='false'>x</span>",
750 IA2_ROLE_TOGGLE_BUTTON, 0);
751 ADD_BUTTON("<span role='button' aria-pressed='true'>x</span>",
752 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_PRESSED);
753 ADD_BUTTON("<span role='button' aria-pressed='mixed'>x</span>",
754 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_MIXED);
755 ADD_BUTTON("<span role='button' aria-pressed='xyz'>x</span>",
756 IA2_ROLE_TOGGLE_BUTTON, 0);
757 ADD_BUTTON("<span role='button' aria-pressed=''>x</span>",
758 ROLE_SYSTEM_PUSHBUTTON, 0);
759 ADD_BUTTON("<span role='button' aria-pressed>x</span>",
760 ROLE_SYSTEM_PUSHBUTTON, 0);
761 ADD_BUTTON("<span role='button' aria-pressed='undefined'>x</span>",
762 ROLE_SYSTEM_PUSHBUTTON, 0);
763 ADD_BUTTON("<span role='button'>x</span>", ROLE_SYSTEM_PUSHBUTTON, 0);
764 ADD_BUTTON("<input type='button' aria-pressed='true' value='x'/>",
765 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_PRESSED);
766 ADD_BUTTON("<input type='button' aria-pressed='false' value='x'/>",
767 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_FOCUSABLE);
768 ADD_BUTTON("<input type='button' aria-pressed='mixed' value='x'>",
769 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_MIXED);
770 ADD_BUTTON("<input type='button' aria-pressed='xyz' value='x'/>",
771 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_FOCUSABLE);
772 ADD_BUTTON("<input type='button' aria-pressed='' value='x'/>",
773 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
774 ADD_BUTTON("<input type='button' aria-pressed value='x'>",
775 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
776 ADD_BUTTON("<input type='button' aria-pressed='undefined' value='x'>",
777 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
778 ADD_BUTTON("<input type='button' value='x'>",
779 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
780 ADD_BUTTON("<button aria-pressed='true'>x</button>",
781 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_PRESSED);
782 ADD_BUTTON("<button aria-pressed='false'>x</button>",
783 IA2_ROLE_TOGGLE_BUTTON, STATE_SYSTEM_FOCUSABLE);
784 ADD_BUTTON("<button aria-pressed='mixed'>x</button>", IA2_ROLE_TOGGLE_BUTTON,
785 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_MIXED);
786 ADD_BUTTON("<button aria-pressed='xyz'>x</button>", IA2_ROLE_TOGGLE_BUTTON,
787 STATE_SYSTEM_FOCUSABLE);
788 ADD_BUTTON("<button aria-pressed=''>x</button>",
789 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
790 ADD_BUTTON("<button aria-pressed>x</button>",
791 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
792 ADD_BUTTON("<button aria-pressed='undefined'>x</button>",
793 ROLE_SYSTEM_PUSHBUTTON, STATE_SYSTEM_FOCUSABLE);
794 ADD_BUTTON("<button>x</button>", ROLE_SYSTEM_PUSHBUTTON,
795 STATE_SYSTEM_FOCUSABLE);
796 #undef ADD_BUTTON // Temporary macro
797
798 LoadInitialAccessibilityTreeFromHtml(button_html);
799 document_checker.CheckAccessible(GetRendererAccessible());
800 }
801
802 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
803 MAYBE(SupportsISimpleDOM)) {
804 LoadInitialAccessibilityTreeFromHtml( 672 LoadInitialAccessibilityTreeFromHtml(
805 "<body><input type='checkbox' /></body>"); 673 "<body><input type='checkbox' /></body>");
806 674
807 // Get the IAccessible object for the document. 675 // Get the IAccessible object for the document.
808 base::win::ScopedComPtr<IAccessible> document_accessible( 676 base::win::ScopedComPtr<IAccessible> document_accessible(
809 GetRendererAccessible()); 677 GetRendererAccessible());
810 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); 678 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL));
811 679
812 // Get the ISimpleDOM object for the document. 680 // Get the ISimpleDOM object for the document.
813 base::win::ScopedComPtr<IServiceProvider> service_provider; 681 base::win::ScopedComPtr<IServiceProvider> service_provider;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 ASSERT_EQ(S_OK, hr); 725 ASSERT_EQ(S_OK, hr);
858 hr = checkbox_isimpledomnode->get_nodeInfo( 726 hr = checkbox_isimpledomnode->get_nodeInfo(
859 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children, 727 node_name.Receive(), &name_space_id, node_value.Receive(), &num_children,
860 &unique_id, &node_type); 728 &unique_id, &node_type);
861 ASSERT_EQ(S_OK, hr); 729 ASSERT_EQ(S_OK, hr);
862 EXPECT_EQ(L"input", std::wstring(node_name, node_name.Length())); 730 EXPECT_EQ(L"input", std::wstring(node_name, node_name.Length()));
863 EXPECT_EQ(NODETYPE_ELEMENT, node_type); 731 EXPECT_EQ(NODETYPE_ELEMENT, node_type);
864 EXPECT_EQ(0, num_children); 732 EXPECT_EQ(0, num_children);
865 } 733 }
866 734
867 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, MAYBE(TestRoleGroup)) { 735 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestRoleGroup) {
868 LoadInitialAccessibilityTreeFromHtml( 736 LoadInitialAccessibilityTreeFromHtml(
869 "<fieldset></fieldset><div role=group></div>"); 737 "<fieldset></fieldset><div role=group></div>");
870 738
871 // Check the browser's copy of the renderer accessibility tree. 739 // Check the browser's copy of the renderer accessibility tree.
872 AccessibleChecker grouping1_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 740 AccessibleChecker grouping1_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
873 std::wstring()); 741 std::wstring());
874 AccessibleChecker grouping2_checker(std::wstring(), ROLE_SYSTEM_GROUPING, 742 AccessibleChecker grouping2_checker(std::wstring(), ROLE_SYSTEM_GROUPING,
875 std::wstring()); 743 std::wstring());
876 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, 744 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT,
877 std::wstring()); 745 std::wstring());
878 document_checker.AppendExpectedChild(&grouping1_checker); 746 document_checker.AppendExpectedChild(&grouping1_checker);
879 document_checker.AppendExpectedChild(&grouping2_checker); 747 document_checker.AppendExpectedChild(&grouping2_checker);
880 document_checker.CheckAccessible(GetRendererAccessible()); 748 document_checker.CheckAccessible(GetRendererAccessible());
881 } 749 }
882 750
883 } // namespace content 751 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/legacy_render_widget_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698