OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 }; | 96 }; |
97 | 97 |
98 AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() { | 98 AccessibilityWinBrowserTest::AccessibilityWinBrowserTest() { |
99 } | 99 } |
100 | 100 |
101 AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { | 101 AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { |
102 } | 102 } |
103 | 103 |
104 void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( | 104 void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( |
105 const std::string& html) { | 105 const std::string& html) { |
106 AccessibilityNotificationWaiter waiter( | 106 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
107 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 107 AccessibilityMode::kComplete, |
108 ui::AX_EVENT_LOAD_COMPLETE); | 108 ui::AX_EVENT_LOAD_COMPLETE); |
109 GURL html_data_url("data:text/html," + html); | 109 GURL html_data_url("data:text/html," + html); |
110 NavigateToURL(shell(), html_data_url); | 110 NavigateToURL(shell(), html_data_url); |
111 waiter.WaitForNotification(); | 111 waiter.WaitForNotification(); |
112 } | 112 } |
113 | 113 |
114 // Retrieve the MSAA client accessibility object for the Render Widget Host View | 114 // Retrieve the MSAA client accessibility object for the Render Widget Host View |
115 // of the selected tab. | 115 // of the selected tab. |
116 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { | 116 IAccessible* AccessibilityWinBrowserTest::GetRendererAccessible() { |
117 content::WebContents* web_contents = shell()->web_contents(); | 117 content::WebContents* web_contents = shell()->web_contents(); |
118 return web_contents->GetRenderWidgetHostView()->GetNativeViewAccessible(); | 118 return web_contents->GetRenderWidgetHostView()->GetNativeViewAccessible(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 GetAccessibleFromVariant(form.get(), form_children[1].AsInput()).get(), | 154 GetAccessibleFromVariant(form.get(), form_children[1].AsInput()).get(), |
155 input.Receive())); | 155 input.Receive())); |
156 LONG input_role = 0; | 156 LONG input_role = 0; |
157 ASSERT_HRESULT_SUCCEEDED(input->role(&input_role)); | 157 ASSERT_HRESULT_SUCCEEDED(input->role(&input_role)); |
158 ASSERT_EQ(ROLE_SYSTEM_TEXT, input_role); | 158 ASSERT_EQ(ROLE_SYSTEM_TEXT, input_role); |
159 | 159 |
160 // Retrieve the IAccessibleText interface for the field. | 160 // Retrieve the IAccessibleText interface for the field. |
161 ASSERT_HRESULT_SUCCEEDED(input.QueryInterface(input_text->Receive())); | 161 ASSERT_HRESULT_SUCCEEDED(input.QueryInterface(input_text->Receive())); |
162 | 162 |
163 // Set the caret on the last character. | 163 // Set the caret on the last character. |
164 AccessibilityNotificationWaiter waiter( | 164 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
165 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 165 AccessibilityMode::kComplete, |
166 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | 166 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
167 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( | 167 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( |
168 static_cast<int>(CONTENTS_LENGTH - 1))); | 168 static_cast<int>(CONTENTS_LENGTH - 1))); |
169 ExecuteScript(std::wstring( | 169 ExecuteScript(std::wstring( |
170 L"var textField = document.getElementById('textField');" | 170 L"var textField = document.getElementById('textField');" |
171 L"textField.focus();" | 171 L"textField.focus();" |
172 L"textField.setSelectionRange(") + | 172 L"textField.setSelectionRange(") + |
173 caret_offset + L"," + caret_offset + L");"); | 173 caret_offset + L"," + caret_offset + L");"); |
174 waiter.WaitForNotification(); | 174 waiter.WaitForNotification(); |
175 } | 175 } |
176 | 176 |
(...skipping 29 matching lines...) Expand all Loading... |
206 .get(), | 206 .get(), |
207 textarea.Receive())); | 207 textarea.Receive())); |
208 LONG textarea_role = 0; | 208 LONG textarea_role = 0; |
209 ASSERT_HRESULT_SUCCEEDED(textarea->role(&textarea_role)); | 209 ASSERT_HRESULT_SUCCEEDED(textarea->role(&textarea_role)); |
210 ASSERT_EQ(ROLE_SYSTEM_TEXT, textarea_role); | 210 ASSERT_EQ(ROLE_SYSTEM_TEXT, textarea_role); |
211 | 211 |
212 // Retrieve the IAccessibleText interface for the field. | 212 // Retrieve the IAccessibleText interface for the field. |
213 ASSERT_HRESULT_SUCCEEDED(textarea.QueryInterface(textarea_text->Receive())); | 213 ASSERT_HRESULT_SUCCEEDED(textarea.QueryInterface(textarea_text->Receive())); |
214 | 214 |
215 // Set the caret on the last character. | 215 // Set the caret on the last character. |
216 AccessibilityNotificationWaiter waiter( | 216 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
217 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 217 AccessibilityMode::kComplete, |
218 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | 218 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
219 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( | 219 std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( |
220 static_cast<int>(CONTENTS_LENGTH - 1))); | 220 static_cast<int>(CONTENTS_LENGTH - 1))); |
221 ExecuteScript(std::wstring( | 221 ExecuteScript(std::wstring( |
222 L"var textField = document.getElementById('textField');" | 222 L"var textField = document.getElementById('textField');" |
223 L"textField.focus();" | 223 L"textField.focus();" |
224 L"textField.setSelectionRange(") + | 224 L"textField.setSelectionRange(") + |
225 caret_offset + L"," + caret_offset + L");"); | 225 caret_offset + L"," + caret_offset + L");"); |
226 waiter.WaitForNotification(); | 226 waiter.WaitForNotification(); |
227 } | 227 } |
228 | 228 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 std::wstring()); | 665 std::wstring()); |
666 list_item_checker.AppendExpectedChild(&list_marker_checker); | 666 list_item_checker.AppendExpectedChild(&list_marker_checker); |
667 list_item_checker.AppendExpectedChild(&static_text_checker); | 667 list_item_checker.AppendExpectedChild(&static_text_checker); |
668 radio_group_checker.AppendExpectedChild(&list_item_checker); | 668 radio_group_checker.AppendExpectedChild(&list_item_checker); |
669 document_checker.AppendExpectedChild(&radio_group_checker); | 669 document_checker.AppendExpectedChild(&radio_group_checker); |
670 document_checker.CheckAccessible(GetRendererAccessible()); | 670 document_checker.CheckAccessible(GetRendererAccessible()); |
671 | 671 |
672 // Set focus to the radio group. | 672 // Set focus to the radio group. |
673 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 673 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
674 new AccessibilityNotificationWaiter(shell()->web_contents(), | 674 new AccessibilityNotificationWaiter(shell()->web_contents(), |
675 ACCESSIBILITY_MODE_COMPLETE, | 675 AccessibilityMode::kComplete, |
676 ui::AX_EVENT_FOCUS)); | 676 ui::AX_EVENT_FOCUS)); |
677 ExecuteScript(L"document.body.children[0].focus()"); | 677 ExecuteScript(L"document.body.children[0].focus()"); |
678 waiter->WaitForNotification(); | 678 waiter->WaitForNotification(); |
679 | 679 |
680 // Check that the accessibility tree of the browser has been updated. | 680 // Check that the accessibility tree of the browser has been updated. |
681 radio_group_checker.SetExpectedState( | 681 radio_group_checker.SetExpectedState( |
682 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); | 682 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); |
683 document_checker.CheckAccessible(GetRendererAccessible()); | 683 document_checker.CheckAccessible(GetRendererAccessible()); |
684 | 684 |
685 // Set the active descendant of the radio group | 685 // Set the active descendant of the radio group |
686 waiter.reset(new AccessibilityNotificationWaiter( | 686 waiter.reset(new AccessibilityNotificationWaiter(shell()->web_contents(), |
687 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 687 AccessibilityMode::kComplete, |
688 ui::AX_EVENT_FOCUS)); | 688 ui::AX_EVENT_FOCUS)); |
689 ExecuteScript( | 689 ExecuteScript( |
690 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); | 690 L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); |
691 waiter->WaitForNotification(); | 691 waiter->WaitForNotification(); |
692 | 692 |
693 // Check that the accessibility tree of the browser has been updated. | 693 // Check that the accessibility tree of the browser has been updated. |
694 list_item_checker.SetExpectedState( | 694 list_item_checker.SetExpectedState( |
695 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); | 695 STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED); |
696 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 696 radio_group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
697 document_checker.CheckAccessible(GetRendererAccessible()); | 697 document_checker.CheckAccessible(GetRendererAccessible()); |
698 } | 698 } |
(...skipping 11 matching lines...) Expand all Loading... |
710 std::wstring()); | 710 std::wstring()); |
711 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 711 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
712 std::wstring()); | 712 std::wstring()); |
713 body_checker.AppendExpectedChild(&checkbox_checker); | 713 body_checker.AppendExpectedChild(&checkbox_checker); |
714 document_checker.AppendExpectedChild(&body_checker); | 714 document_checker.AppendExpectedChild(&body_checker); |
715 document_checker.CheckAccessible(GetRendererAccessible()); | 715 document_checker.CheckAccessible(GetRendererAccessible()); |
716 | 716 |
717 // Check the checkbox. | 717 // Check the checkbox. |
718 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 718 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
719 new AccessibilityNotificationWaiter(shell()->web_contents(), | 719 new AccessibilityNotificationWaiter(shell()->web_contents(), |
720 ACCESSIBILITY_MODE_COMPLETE, | 720 AccessibilityMode::kComplete, |
721 ui::AX_EVENT_CHECKED_STATE_CHANGED)); | 721 ui::AX_EVENT_CHECKED_STATE_CHANGED)); |
722 ExecuteScript(L"document.body.children[0].checked=true"); | 722 ExecuteScript(L"document.body.children[0].checked=true"); |
723 waiter->WaitForNotification(); | 723 waiter->WaitForNotification(); |
724 | 724 |
725 // Check that the accessibility tree of the browser has been updated. | 725 // Check that the accessibility tree of the browser has been updated. |
726 checkbox_checker.SetExpectedState( | 726 checkbox_checker.SetExpectedState( |
727 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); | 727 STATE_SYSTEM_CHECKED | STATE_SYSTEM_FOCUSABLE); |
728 document_checker.CheckAccessible(GetRendererAccessible()); | 728 document_checker.CheckAccessible(GetRendererAccessible()); |
729 } | 729 } |
730 | 730 |
731 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 731 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
732 TestNotificationChildrenChanged) { | 732 TestNotificationChildrenChanged) { |
733 // The role attribute causes the node to be in the accessibility tree. | 733 // The role attribute causes the node to be in the accessibility tree. |
734 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); | 734 LoadInitialAccessibilityTreeFromHtml("<body role=group></body>"); |
735 | 735 |
736 // Check the browser's copy of the renderer accessibility tree. | 736 // Check the browser's copy of the renderer accessibility tree. |
737 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, | 737 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, |
738 std::wstring()); | 738 std::wstring()); |
739 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 739 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
740 std::wstring()); | 740 std::wstring()); |
741 document_checker.AppendExpectedChild(&group_checker); | 741 document_checker.AppendExpectedChild(&group_checker); |
742 document_checker.CheckAccessible(GetRendererAccessible()); | 742 document_checker.CheckAccessible(GetRendererAccessible()); |
743 | 743 |
744 // Change the children of the document body. | 744 // Change the children of the document body. |
745 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 745 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
746 new AccessibilityNotificationWaiter(shell()->web_contents(), | 746 new AccessibilityNotificationWaiter(shell()->web_contents(), |
747 ACCESSIBILITY_MODE_COMPLETE, | 747 AccessibilityMode::kComplete, |
748 ui::AX_EVENT_CHILDREN_CHANGED)); | 748 ui::AX_EVENT_CHILDREN_CHANGED)); |
749 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); | 749 ExecuteScript(L"document.body.innerHTML='<b>new text</b>'"); |
750 waiter->WaitForNotification(); | 750 waiter->WaitForNotification(); |
751 | 751 |
752 // Check that the accessibility tree of the browser has been updated. | 752 // Check that the accessibility tree of the browser has been updated. |
753 AccessibleChecker text_checker( | 753 AccessibleChecker text_checker( |
754 L"new text", ROLE_SYSTEM_STATICTEXT, std::wstring()); | 754 L"new text", ROLE_SYSTEM_STATICTEXT, std::wstring()); |
755 group_checker.AppendExpectedChild(&text_checker); | 755 group_checker.AppendExpectedChild(&text_checker); |
756 document_checker.CheckAccessible(GetRendererAccessible()); | 756 document_checker.CheckAccessible(GetRendererAccessible()); |
757 } | 757 } |
758 | 758 |
759 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 759 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
760 TestNotificationChildrenChanged2) { | 760 TestNotificationChildrenChanged2) { |
761 // The role attribute causes the node to be in the accessibility tree. | 761 // The role attribute causes the node to be in the accessibility tree. |
762 LoadInitialAccessibilityTreeFromHtml( | 762 LoadInitialAccessibilityTreeFromHtml( |
763 "<div role=group style='visibility: hidden'>text</div>"); | 763 "<div role=group style='visibility: hidden'>text</div>"); |
764 | 764 |
765 // Check the accessible tree of the browser. | 765 // Check the accessible tree of the browser. |
766 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 766 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
767 std::wstring()); | 767 std::wstring()); |
768 document_checker.CheckAccessible(GetRendererAccessible()); | 768 document_checker.CheckAccessible(GetRendererAccessible()); |
769 | 769 |
770 // Change the children of the document body. | 770 // Change the children of the document body. |
771 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 771 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
772 new AccessibilityNotificationWaiter(shell()->web_contents(), | 772 new AccessibilityNotificationWaiter(shell()->web_contents(), |
773 ACCESSIBILITY_MODE_COMPLETE, | 773 AccessibilityMode::kComplete, |
774 ui::AX_EVENT_CHILDREN_CHANGED)); | 774 ui::AX_EVENT_CHILDREN_CHANGED)); |
775 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); | 775 ExecuteScript(L"document.body.children[0].style.visibility='visible'"); |
776 waiter->WaitForNotification(); | 776 waiter->WaitForNotification(); |
777 | 777 |
778 // Check that the accessibility tree of the browser has been updated. | 778 // Check that the accessibility tree of the browser has been updated. |
779 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_STATICTEXT, | 779 AccessibleChecker static_text_checker(L"text", ROLE_SYSTEM_STATICTEXT, |
780 std::wstring()); | 780 std::wstring()); |
781 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, | 781 AccessibleChecker group_checker(std::wstring(), ROLE_SYSTEM_GROUPING, |
782 std::wstring()); | 782 std::wstring()); |
783 document_checker.AppendExpectedChild(&group_checker); | 783 document_checker.AppendExpectedChild(&group_checker); |
(...skipping 12 matching lines...) Expand all Loading... |
796 std::wstring()); | 796 std::wstring()); |
797 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); | 797 group_checker.SetExpectedState(STATE_SYSTEM_FOCUSABLE); |
798 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 798 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
799 std::wstring()); | 799 std::wstring()); |
800 document_checker.AppendExpectedChild(&group_checker); | 800 document_checker.AppendExpectedChild(&group_checker); |
801 document_checker.CheckAccessible(GetRendererAccessible()); | 801 document_checker.CheckAccessible(GetRendererAccessible()); |
802 | 802 |
803 // Focus the div in the document | 803 // Focus the div in the document |
804 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 804 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
805 new AccessibilityNotificationWaiter(shell()->web_contents(), | 805 new AccessibilityNotificationWaiter(shell()->web_contents(), |
806 ACCESSIBILITY_MODE_COMPLETE, | 806 AccessibilityMode::kComplete, |
807 ui::AX_EVENT_FOCUS)); | 807 ui::AX_EVENT_FOCUS)); |
808 ExecuteScript(L"document.body.children[0].focus()"); | 808 ExecuteScript(L"document.body.children[0].focus()"); |
809 waiter->WaitForNotification(); | 809 waiter->WaitForNotification(); |
810 | 810 |
811 // Check that the accessibility tree of the browser has been updated. | 811 // Check that the accessibility tree of the browser has been updated. |
812 SCOPED_TRACE("Check updated tree after focusing div"); | 812 SCOPED_TRACE("Check updated tree after focusing div"); |
813 group_checker.SetExpectedState( | 813 group_checker.SetExpectedState( |
814 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); | 814 STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_FOCUSED); |
815 document_checker.CheckAccessible(GetRendererAccessible()); | 815 document_checker.CheckAccessible(GetRendererAccessible()); |
816 | 816 |
817 // Focus the document accessible. This will un-focus the current node. | 817 // Focus the document accessible. This will un-focus the current node. |
818 waiter.reset( | 818 waiter.reset(new AccessibilityNotificationWaiter(shell()->web_contents(), |
819 new AccessibilityNotificationWaiter( | 819 AccessibilityMode::kComplete, |
820 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 820 ui::AX_EVENT_BLUR)); |
821 ui::AX_EVENT_BLUR)); | |
822 base::win::ScopedComPtr<IAccessible> document_accessible( | 821 base::win::ScopedComPtr<IAccessible> document_accessible( |
823 GetRendererAccessible()); | 822 GetRendererAccessible()); |
824 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); | 823 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); |
825 base::win::ScopedVariant childid_self(CHILDID_SELF); | 824 base::win::ScopedVariant childid_self(CHILDID_SELF); |
826 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); | 825 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); |
827 ASSERT_EQ(S_OK, hr); | 826 ASSERT_EQ(S_OK, hr); |
828 waiter->WaitForNotification(); | 827 waiter->WaitForNotification(); |
829 | 828 |
830 // Check that the accessibility tree of the browser has been updated. | 829 // Check that the accessibility tree of the browser has been updated. |
831 SCOPED_TRACE("Check updated tree after focusing document again"); | 830 SCOPED_TRACE("Check updated tree after focusing document again"); |
(...skipping 14 matching lines...) Expand all Loading... |
846 std::wstring()); | 845 std::wstring()); |
847 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 846 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
848 std::wstring()); | 847 std::wstring()); |
849 body_checker.AppendExpectedChild(&text_field_checker); | 848 body_checker.AppendExpectedChild(&text_field_checker); |
850 document_checker.AppendExpectedChild(&body_checker); | 849 document_checker.AppendExpectedChild(&body_checker); |
851 document_checker.CheckAccessible(GetRendererAccessible()); | 850 document_checker.CheckAccessible(GetRendererAccessible()); |
852 | 851 |
853 // Set the value of the text control | 852 // Set the value of the text control |
854 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 853 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
855 new AccessibilityNotificationWaiter(shell()->web_contents(), | 854 new AccessibilityNotificationWaiter(shell()->web_contents(), |
856 ACCESSIBILITY_MODE_COMPLETE, | 855 AccessibilityMode::kComplete, |
857 ui::AX_EVENT_VALUE_CHANGED)); | 856 ui::AX_EVENT_VALUE_CHANGED)); |
858 ExecuteScript(L"document.body.children[0].value='new value'"); | 857 ExecuteScript(L"document.body.children[0].value='new value'"); |
859 waiter->WaitForNotification(); | 858 waiter->WaitForNotification(); |
860 | 859 |
861 // Check that the accessibility tree of the browser has been updated. | 860 // Check that the accessibility tree of the browser has been updated. |
862 text_field_checker.SetExpectedValue(L"new value"); | 861 text_field_checker.SetExpectedValue(L"new value"); |
863 document_checker.CheckAccessible(GetRendererAccessible()); | 862 document_checker.CheckAccessible(GetRendererAccessible()); |
864 } | 863 } |
865 | 864 |
866 // This test verifies that the web content's accessibility tree is a | 865 // This test verifies that the web content's accessibility tree is a |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 | 1085 |
1087 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { | 1086 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { |
1088 base::win::ScopedComPtr<IAccessible2> paragraph; | 1087 base::win::ScopedComPtr<IAccessible2> paragraph; |
1089 SetUpSampleParagraph(¶graph); | 1088 SetUpSampleParagraph(¶graph); |
1090 | 1089 |
1091 LONG prev_x, prev_y, x, y, width, height; | 1090 LONG prev_x, prev_y, x, y, width, height; |
1092 base::win::ScopedVariant childid_self(CHILDID_SELF); | 1091 base::win::ScopedVariant childid_self(CHILDID_SELF); |
1093 ASSERT_HRESULT_SUCCEEDED( | 1092 ASSERT_HRESULT_SUCCEEDED( |
1094 paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); | 1093 paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); |
1095 AccessibilityNotificationWaiter location_changed_waiter( | 1094 AccessibilityNotificationWaiter location_changed_waiter( |
1096 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 1095 shell()->web_contents(), AccessibilityMode::kComplete, |
1097 ui::AX_EVENT_LOCATION_CHANGED); | 1096 ui::AX_EVENT_LOCATION_CHANGED); |
1098 EXPECT_HRESULT_SUCCEEDED( | 1097 EXPECT_HRESULT_SUCCEEDED( |
1099 paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); | 1098 paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); |
1100 location_changed_waiter.WaitForNotification(); | 1099 location_changed_waiter.WaitForNotification(); |
1101 | 1100 |
1102 ASSERT_HRESULT_SUCCEEDED( | 1101 ASSERT_HRESULT_SUCCEEDED( |
1103 paragraph->accLocation(&x, &y, &width, &height, childid_self)); | 1102 paragraph->accLocation(&x, &y, &width, &height, childid_self)); |
1104 EXPECT_EQ(prev_x, x); | 1103 EXPECT_EQ(prev_x, x); |
1105 EXPECT_GT(prev_y, y); | 1104 EXPECT_GT(prev_y, y); |
1106 | 1105 |
(...skipping 10 matching lines...) Expand all Loading... |
1117 | 1116 |
1118 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetCaretOffset) { | 1117 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetCaretOffset) { |
1119 base::win::ScopedComPtr<IAccessibleText> input_text; | 1118 base::win::ScopedComPtr<IAccessibleText> input_text; |
1120 SetUpInputField(&input_text); | 1119 SetUpInputField(&input_text); |
1121 | 1120 |
1122 LONG caret_offset = 0; | 1121 LONG caret_offset = 0; |
1123 HRESULT hr = input_text->get_caretOffset(&caret_offset); | 1122 HRESULT hr = input_text->get_caretOffset(&caret_offset); |
1124 EXPECT_EQ(S_OK, hr); | 1123 EXPECT_EQ(S_OK, hr); |
1125 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); | 1124 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); |
1126 | 1125 |
1127 AccessibilityNotificationWaiter waiter( | 1126 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1128 shell()->web_contents(), | 1127 AccessibilityMode::kComplete, |
1129 ACCESSIBILITY_MODE_COMPLETE, | 1128 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
1130 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | |
1131 caret_offset = 0; | 1129 caret_offset = 0; |
1132 hr = input_text->setCaretOffset(caret_offset); | 1130 hr = input_text->setCaretOffset(caret_offset); |
1133 EXPECT_EQ(S_OK, hr); | 1131 EXPECT_EQ(S_OK, hr); |
1134 waiter.WaitForNotification(); | 1132 waiter.WaitForNotification(); |
1135 | 1133 |
1136 hr = input_text->get_caretOffset(&caret_offset); | 1134 hr = input_text->get_caretOffset(&caret_offset); |
1137 EXPECT_EQ(S_OK, hr); | 1135 EXPECT_EQ(S_OK, hr); |
1138 EXPECT_EQ(0, caret_offset); | 1136 EXPECT_EQ(0, caret_offset); |
1139 } | 1137 } |
1140 | 1138 |
1141 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 1139 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
1142 TestMultiLineSetCaretOffset) { | 1140 TestMultiLineSetCaretOffset) { |
1143 base::win::ScopedComPtr<IAccessibleText> textarea_text; | 1141 base::win::ScopedComPtr<IAccessibleText> textarea_text; |
1144 SetUpTextareaField(&textarea_text); | 1142 SetUpTextareaField(&textarea_text); |
1145 | 1143 |
1146 LONG caret_offset = 0; | 1144 LONG caret_offset = 0; |
1147 HRESULT hr = textarea_text->get_caretOffset(&caret_offset); | 1145 HRESULT hr = textarea_text->get_caretOffset(&caret_offset); |
1148 EXPECT_EQ(S_OK, hr); | 1146 EXPECT_EQ(S_OK, hr); |
1149 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); | 1147 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); |
1150 | 1148 |
1151 AccessibilityNotificationWaiter waiter( | 1149 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1152 shell()->web_contents(), | 1150 AccessibilityMode::kComplete, |
1153 ACCESSIBILITY_MODE_COMPLETE, | 1151 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
1154 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | |
1155 caret_offset = 0; | 1152 caret_offset = 0; |
1156 hr = textarea_text->setCaretOffset(caret_offset); | 1153 hr = textarea_text->setCaretOffset(caret_offset); |
1157 EXPECT_EQ(S_OK, hr); | 1154 EXPECT_EQ(S_OK, hr); |
1158 waiter.WaitForNotification(); | 1155 waiter.WaitForNotification(); |
1159 | 1156 |
1160 hr = textarea_text->get_caretOffset(&caret_offset); | 1157 hr = textarea_text->get_caretOffset(&caret_offset); |
1161 EXPECT_EQ(S_OK, hr); | 1158 EXPECT_EQ(S_OK, hr); |
1162 EXPECT_EQ(0, caret_offset); | 1159 EXPECT_EQ(0, caret_offset); |
1163 } | 1160 } |
1164 | 1161 |
1165 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetSelection) { | 1162 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetSelection) { |
1166 base::win::ScopedComPtr<IAccessibleText> input_text; | 1163 base::win::ScopedComPtr<IAccessibleText> input_text; |
1167 SetUpInputField(&input_text); | 1164 SetUpInputField(&input_text); |
1168 | 1165 |
1169 LONG start_offset, end_offset; | 1166 LONG start_offset, end_offset; |
1170 EXPECT_HRESULT_FAILED( | 1167 EXPECT_HRESULT_FAILED( |
1171 input_text->get_selection(1, &start_offset, &end_offset)); | 1168 input_text->get_selection(1, &start_offset, &end_offset)); |
1172 HRESULT hr = input_text->get_selection(0, &start_offset, &end_offset); | 1169 HRESULT hr = input_text->get_selection(0, &start_offset, &end_offset); |
1173 // There is no selection, just a caret. | 1170 // There is no selection, just a caret. |
1174 EXPECT_EQ(E_INVALIDARG, hr); | 1171 EXPECT_EQ(E_INVALIDARG, hr); |
1175 | 1172 |
1176 AccessibilityNotificationWaiter waiter(shell()->web_contents(), | 1173 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1177 ACCESSIBILITY_MODE_COMPLETE, | 1174 AccessibilityMode::kComplete, |
1178 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | 1175 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
1179 start_offset = 0; | 1176 start_offset = 0; |
1180 end_offset = CONTENTS_LENGTH; | 1177 end_offset = CONTENTS_LENGTH; |
1181 EXPECT_HRESULT_FAILED(input_text->setSelection(1, start_offset, end_offset)); | 1178 EXPECT_HRESULT_FAILED(input_text->setSelection(1, start_offset, end_offset)); |
1182 EXPECT_HRESULT_SUCCEEDED( | 1179 EXPECT_HRESULT_SUCCEEDED( |
1183 input_text->setSelection(0, start_offset, end_offset)); | 1180 input_text->setSelection(0, start_offset, end_offset)); |
1184 waiter.WaitForNotification(); | 1181 waiter.WaitForNotification(); |
1185 | 1182 |
1186 hr = input_text->get_selection(0, &start_offset, &end_offset); | 1183 hr = input_text->get_selection(0, &start_offset, &end_offset); |
1187 EXPECT_EQ(S_OK, hr); | 1184 EXPECT_EQ(S_OK, hr); |
(...skipping 18 matching lines...) Expand all Loading... |
1206 SetUpTextareaField(&textarea_text); | 1203 SetUpTextareaField(&textarea_text); |
1207 | 1204 |
1208 LONG start_offset, end_offset; | 1205 LONG start_offset, end_offset; |
1209 EXPECT_HRESULT_FAILED( | 1206 EXPECT_HRESULT_FAILED( |
1210 textarea_text->get_selection(1, &start_offset, &end_offset)); | 1207 textarea_text->get_selection(1, &start_offset, &end_offset)); |
1211 HRESULT hr = textarea_text->get_selection(0, &start_offset, &end_offset); | 1208 HRESULT hr = textarea_text->get_selection(0, &start_offset, &end_offset); |
1212 // There is no selection, just a caret. | 1209 // There is no selection, just a caret. |
1213 EXPECT_EQ(E_INVALIDARG, hr); | 1210 EXPECT_EQ(E_INVALIDARG, hr); |
1214 | 1211 |
1215 AccessibilityNotificationWaiter waiter(shell()->web_contents(), | 1212 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1216 ACCESSIBILITY_MODE_COMPLETE, | 1213 AccessibilityMode::kComplete, |
1217 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | 1214 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
1218 start_offset = 0; | 1215 start_offset = 0; |
1219 end_offset = CONTENTS_LENGTH; | 1216 end_offset = CONTENTS_LENGTH; |
1220 EXPECT_HRESULT_FAILED( | 1217 EXPECT_HRESULT_FAILED( |
1221 textarea_text->setSelection(1, start_offset, end_offset)); | 1218 textarea_text->setSelection(1, start_offset, end_offset)); |
1222 EXPECT_HRESULT_SUCCEEDED( | 1219 EXPECT_HRESULT_SUCCEEDED( |
1223 textarea_text->setSelection(0, start_offset, end_offset)); | 1220 textarea_text->setSelection(0, start_offset, end_offset)); |
1224 waiter.WaitForNotification(); | 1221 waiter.WaitForNotification(); |
1225 | 1222 |
1226 hr = textarea_text->get_selection(0, &start_offset, &end_offset); | 1223 hr = textarea_text->get_selection(0, &start_offset, &end_offset); |
(...skipping 17 matching lines...) Expand all Loading... |
1244 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 1241 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
1245 TestStaticTextSetSelection) { | 1242 TestStaticTextSetSelection) { |
1246 base::win::ScopedComPtr<IAccessibleText> paragraph_text; | 1243 base::win::ScopedComPtr<IAccessibleText> paragraph_text; |
1247 SetUpSampleParagraph(¶graph_text); | 1244 SetUpSampleParagraph(¶graph_text); |
1248 | 1245 |
1249 LONG n_characters; | 1246 LONG n_characters; |
1250 ASSERT_HRESULT_SUCCEEDED(paragraph_text->get_nCharacters(&n_characters)); | 1247 ASSERT_HRESULT_SUCCEEDED(paragraph_text->get_nCharacters(&n_characters)); |
1251 ASSERT_LT(0, n_characters); | 1248 ASSERT_LT(0, n_characters); |
1252 | 1249 |
1253 AccessibilityNotificationWaiter waiter( | 1250 AccessibilityNotificationWaiter waiter( |
1254 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 1251 shell()->web_contents(), AccessibilityMode::kComplete, |
1255 ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED); | 1252 ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED); |
1256 LONG start_offset = 0; | 1253 LONG start_offset = 0; |
1257 LONG end_offset = n_characters; | 1254 LONG end_offset = n_characters; |
1258 EXPECT_HRESULT_FAILED( | 1255 EXPECT_HRESULT_FAILED( |
1259 paragraph_text->setSelection(1, start_offset, end_offset)); | 1256 paragraph_text->setSelection(1, start_offset, end_offset)); |
1260 EXPECT_HRESULT_SUCCEEDED( | 1257 EXPECT_HRESULT_SUCCEEDED( |
1261 paragraph_text->setSelection(0, start_offset, end_offset)); | 1258 paragraph_text->setSelection(0, start_offset, end_offset)); |
1262 waiter.WaitForNotification(); | 1259 waiter.WaitForNotification(); |
1263 | 1260 |
1264 HRESULT hr = paragraph_text->get_selection(0, &start_offset, &end_offset); | 1261 HRESULT hr = paragraph_text->get_selection(0, &start_offset, &end_offset); |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 | 1852 |
1856 base::win::ScopedVariant childid_self(CHILDID_SELF); | 1853 base::win::ScopedVariant childid_self(CHILDID_SELF); |
1857 base::win::ScopedBstr image_name; | 1854 base::win::ScopedBstr image_name; |
1858 EXPECT_HRESULT_SUCCEEDED( | 1855 EXPECT_HRESULT_SUCCEEDED( |
1859 image->get_accName(childid_self, image_name.Receive())); | 1856 image->get_accName(childid_self, image_name.Receive())); |
1860 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length())); | 1857 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length())); |
1861 image_name.Release(); | 1858 image_name.Release(); |
1862 // Cllicking the image will change its name. | 1859 // Cllicking the image will change its name. |
1863 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); | 1860 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); |
1864 AccessibilityNotificationWaiter waiter(shell()->web_contents(), | 1861 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1865 ACCESSIBILITY_MODE_COMPLETE, | 1862 AccessibilityMode::kComplete, |
1866 ui::AX_EVENT_TEXT_CHANGED); | 1863 ui::AX_EVENT_TEXT_CHANGED); |
1867 waiter.WaitForNotification(); | 1864 waiter.WaitForNotification(); |
1868 EXPECT_HRESULT_SUCCEEDED( | 1865 EXPECT_HRESULT_SUCCEEDED( |
1869 image->get_accName(childid_self, image_name.Receive())); | 1866 image->get_accName(childid_self, image_name.Receive())); |
1870 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); | 1867 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); |
1871 EXPECT_HRESULT_FAILED(image_action->doAction(1)); | 1868 EXPECT_HRESULT_FAILED(image_action->doAction(1)); |
1872 } | 1869 } |
1873 | 1870 |
1874 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { | 1871 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { |
1875 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize | 1872 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize |
1876 // is not called again after its window is added to the root window. | 1873 // is not called again after its window is added to the root window. |
1877 // Ensure that we still get a legacy HWND for accessibility. | 1874 // Ensure that we still get a legacy HWND for accessibility. |
1878 | 1875 |
1879 host_resolver()->AddRule("*", "127.0.0.1"); | 1876 host_resolver()->AddRule("*", "127.0.0.1"); |
1880 ASSERT_TRUE(embedded_test_server()->Start()); | 1877 ASSERT_TRUE(embedded_test_server()->Start()); |
1881 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 1878 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
1882 shell()->web_contents()); | 1879 shell()->web_contents()); |
1883 WebContentsView* web_contents_view = web_contents->GetView(); | 1880 WebContentsView* web_contents_view = web_contents->GetView(); |
1884 WebContentsViewAura* web_contents_view_aura = | 1881 WebContentsViewAura* web_contents_view_aura = |
1885 static_cast<WebContentsViewAura*>(web_contents_view); | 1882 static_cast<WebContentsViewAura*>(web_contents_view); |
1886 | 1883 |
1887 // Set a flag that will cause WebContentsViewAura to initialize a | 1884 // Set a flag that will cause WebContentsViewAura to initialize a |
1888 // RenderWidgetHostViewAura with a null parent view. | 1885 // RenderWidgetHostViewAura with a null parent view. |
1889 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); | 1886 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); |
1890 | 1887 |
1891 // Navigate to a new page and wait for the accessibility tree to load. | 1888 // Navigate to a new page and wait for the accessibility tree to load. |
1892 AccessibilityNotificationWaiter waiter( | 1889 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1893 shell()->web_contents(), | 1890 AccessibilityMode::kComplete, |
1894 ACCESSIBILITY_MODE_COMPLETE, | 1891 ui::AX_EVENT_LOAD_COMPLETE); |
1895 ui::AX_EVENT_LOAD_COMPLETE); | |
1896 NavigateToURL(shell(), embedded_test_server()->GetURL( | 1892 NavigateToURL(shell(), embedded_test_server()->GetURL( |
1897 "/accessibility/html/article.html")); | 1893 "/accessibility/html/article.html")); |
1898 waiter.WaitForNotification(); | 1894 waiter.WaitForNotification(); |
1899 | 1895 |
1900 // At this point the root of the accessibility tree shouldn't have an HWND | 1896 // At this point the root of the accessibility tree shouldn't have an HWND |
1901 // because we never gave a parent window to the RWHVA. | 1897 // because we never gave a parent window to the RWHVA. |
1902 BrowserAccessibilityManagerWin* manager = | 1898 BrowserAccessibilityManagerWin* manager = |
1903 static_cast<BrowserAccessibilityManagerWin*>( | 1899 static_cast<BrowserAccessibilityManagerWin*>( |
1904 web_contents->GetRootBrowserAccessibilityManager()); | 1900 web_contents->GetRootBrowserAccessibilityManager()); |
1905 ASSERT_EQ(nullptr, manager->GetParentHWND()); | 1901 ASSERT_EQ(nullptr, manager->GetParentHWND()); |
1906 | 1902 |
1907 // Now add the RWHVA's window to the root window and ensure that we have | 1903 // Now add the RWHVA's window to the root window and ensure that we have |
1908 // an HWND for accessibility now. | 1904 // an HWND for accessibility now. |
1909 web_contents_view->GetNativeView()->AddChild( | 1905 web_contents_view->GetNativeView()->AddChild( |
1910 web_contents->GetRenderWidgetHostView()->GetNativeView()); | 1906 web_contents->GetRenderWidgetHostView()->GetNativeView()); |
1911 ASSERT_NE(nullptr, manager->GetParentHWND()); | 1907 ASSERT_NE(nullptr, manager->GetParentHWND()); |
1912 } | 1908 } |
1913 | 1909 |
1914 } // namespace content | 1910 } // namespace content |
OLD | NEW |