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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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::COMPLETE, |
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( |
819 new AccessibilityNotificationWaiter( | 819 shell()->web_contents(), AccessibilityMode::COMPLETE, ui::AX_EVENT_BLUR)); |
820 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | |
821 ui::AX_EVENT_BLUR)); | |
822 base::win::ScopedComPtr<IAccessible> document_accessible( | 820 base::win::ScopedComPtr<IAccessible> document_accessible( |
823 GetRendererAccessible()); | 821 GetRendererAccessible()); |
824 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); | 822 ASSERT_NE(document_accessible.get(), reinterpret_cast<IAccessible*>(NULL)); |
825 base::win::ScopedVariant childid_self(CHILDID_SELF); | 823 base::win::ScopedVariant childid_self(CHILDID_SELF); |
826 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); | 824 HRESULT hr = document_accessible->accSelect(SELFLAG_TAKEFOCUS, childid_self); |
827 ASSERT_EQ(S_OK, hr); | 825 ASSERT_EQ(S_OK, hr); |
828 waiter->WaitForNotification(); | 826 waiter->WaitForNotification(); |
829 | 827 |
830 // Check that the accessibility tree of the browser has been updated. | 828 // Check that the accessibility tree of the browser has been updated. |
831 SCOPED_TRACE("Check updated tree after focusing document again"); | 829 SCOPED_TRACE("Check updated tree after focusing document again"); |
(...skipping 14 matching lines...) Expand all Loading... |
846 std::wstring()); | 844 std::wstring()); |
847 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, | 845 AccessibleChecker document_checker(std::wstring(), ROLE_SYSTEM_DOCUMENT, |
848 std::wstring()); | 846 std::wstring()); |
849 body_checker.AppendExpectedChild(&text_field_checker); | 847 body_checker.AppendExpectedChild(&text_field_checker); |
850 document_checker.AppendExpectedChild(&body_checker); | 848 document_checker.AppendExpectedChild(&body_checker); |
851 document_checker.CheckAccessible(GetRendererAccessible()); | 849 document_checker.CheckAccessible(GetRendererAccessible()); |
852 | 850 |
853 // Set the value of the text control | 851 // Set the value of the text control |
854 std::unique_ptr<AccessibilityNotificationWaiter> waiter( | 852 std::unique_ptr<AccessibilityNotificationWaiter> waiter( |
855 new AccessibilityNotificationWaiter(shell()->web_contents(), | 853 new AccessibilityNotificationWaiter(shell()->web_contents(), |
856 ACCESSIBILITY_MODE_COMPLETE, | 854 AccessibilityMode::COMPLETE, |
857 ui::AX_EVENT_VALUE_CHANGED)); | 855 ui::AX_EVENT_VALUE_CHANGED)); |
858 ExecuteScript(L"document.body.children[0].value='new value'"); | 856 ExecuteScript(L"document.body.children[0].value='new value'"); |
859 waiter->WaitForNotification(); | 857 waiter->WaitForNotification(); |
860 | 858 |
861 // Check that the accessibility tree of the browser has been updated. | 859 // Check that the accessibility tree of the browser has been updated. |
862 text_field_checker.SetExpectedValue(L"new value"); | 860 text_field_checker.SetExpectedValue(L"new value"); |
863 document_checker.CheckAccessible(GetRendererAccessible()); | 861 document_checker.CheckAccessible(GetRendererAccessible()); |
864 } | 862 } |
865 | 863 |
866 // This test verifies that the web content's accessibility tree is a | 864 // 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 | 1084 |
1087 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { | 1085 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { |
1088 base::win::ScopedComPtr<IAccessible2> paragraph; | 1086 base::win::ScopedComPtr<IAccessible2> paragraph; |
1089 SetUpSampleParagraph(¶graph); | 1087 SetUpSampleParagraph(¶graph); |
1090 | 1088 |
1091 LONG prev_x, prev_y, x, y, width, height; | 1089 LONG prev_x, prev_y, x, y, width, height; |
1092 base::win::ScopedVariant childid_self(CHILDID_SELF); | 1090 base::win::ScopedVariant childid_self(CHILDID_SELF); |
1093 ASSERT_HRESULT_SUCCEEDED( | 1091 ASSERT_HRESULT_SUCCEEDED( |
1094 paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); | 1092 paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); |
1095 AccessibilityNotificationWaiter location_changed_waiter( | 1093 AccessibilityNotificationWaiter location_changed_waiter( |
1096 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, | 1094 shell()->web_contents(), AccessibilityMode::COMPLETE, |
1097 ui::AX_EVENT_LOCATION_CHANGED); | 1095 ui::AX_EVENT_LOCATION_CHANGED); |
1098 EXPECT_HRESULT_SUCCEEDED( | 1096 EXPECT_HRESULT_SUCCEEDED( |
1099 paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); | 1097 paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); |
1100 location_changed_waiter.WaitForNotification(); | 1098 location_changed_waiter.WaitForNotification(); |
1101 | 1099 |
1102 ASSERT_HRESULT_SUCCEEDED( | 1100 ASSERT_HRESULT_SUCCEEDED( |
1103 paragraph->accLocation(&x, &y, &width, &height, childid_self)); | 1101 paragraph->accLocation(&x, &y, &width, &height, childid_self)); |
1104 EXPECT_EQ(prev_x, x); | 1102 EXPECT_EQ(prev_x, x); |
1105 EXPECT_GT(prev_y, y); | 1103 EXPECT_GT(prev_y, y); |
1106 | 1104 |
(...skipping 10 matching lines...) Expand all Loading... |
1117 | 1115 |
1118 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetCaretOffset) { | 1116 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetCaretOffset) { |
1119 base::win::ScopedComPtr<IAccessibleText> input_text; | 1117 base::win::ScopedComPtr<IAccessibleText> input_text; |
1120 SetUpInputField(&input_text); | 1118 SetUpInputField(&input_text); |
1121 | 1119 |
1122 LONG caret_offset = 0; | 1120 LONG caret_offset = 0; |
1123 HRESULT hr = input_text->get_caretOffset(&caret_offset); | 1121 HRESULT hr = input_text->get_caretOffset(&caret_offset); |
1124 EXPECT_EQ(S_OK, hr); | 1122 EXPECT_EQ(S_OK, hr); |
1125 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); | 1123 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); |
1126 | 1124 |
1127 AccessibilityNotificationWaiter waiter( | 1125 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1128 shell()->web_contents(), | 1126 AccessibilityMode::COMPLETE, |
1129 ACCESSIBILITY_MODE_COMPLETE, | 1127 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
1130 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | |
1131 caret_offset = 0; | 1128 caret_offset = 0; |
1132 hr = input_text->setCaretOffset(caret_offset); | 1129 hr = input_text->setCaretOffset(caret_offset); |
1133 EXPECT_EQ(S_OK, hr); | 1130 EXPECT_EQ(S_OK, hr); |
1134 waiter.WaitForNotification(); | 1131 waiter.WaitForNotification(); |
1135 | 1132 |
1136 hr = input_text->get_caretOffset(&caret_offset); | 1133 hr = input_text->get_caretOffset(&caret_offset); |
1137 EXPECT_EQ(S_OK, hr); | 1134 EXPECT_EQ(S_OK, hr); |
1138 EXPECT_EQ(0, caret_offset); | 1135 EXPECT_EQ(0, caret_offset); |
1139 } | 1136 } |
1140 | 1137 |
1141 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, | 1138 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, |
1142 TestMultiLineSetCaretOffset) { | 1139 TestMultiLineSetCaretOffset) { |
1143 base::win::ScopedComPtr<IAccessibleText> textarea_text; | 1140 base::win::ScopedComPtr<IAccessibleText> textarea_text; |
1144 SetUpTextareaField(&textarea_text); | 1141 SetUpTextareaField(&textarea_text); |
1145 | 1142 |
1146 LONG caret_offset = 0; | 1143 LONG caret_offset = 0; |
1147 HRESULT hr = textarea_text->get_caretOffset(&caret_offset); | 1144 HRESULT hr = textarea_text->get_caretOffset(&caret_offset); |
1148 EXPECT_EQ(S_OK, hr); | 1145 EXPECT_EQ(S_OK, hr); |
1149 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); | 1146 EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); |
1150 | 1147 |
1151 AccessibilityNotificationWaiter waiter( | 1148 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1152 shell()->web_contents(), | 1149 AccessibilityMode::COMPLETE, |
1153 ACCESSIBILITY_MODE_COMPLETE, | 1150 ui::AX_EVENT_TEXT_SELECTION_CHANGED); |
1154 ui::AX_EVENT_TEXT_SELECTION_CHANGED); | |
1155 caret_offset = 0; | 1151 caret_offset = 0; |
1156 hr = textarea_text->setCaretOffset(caret_offset); | 1152 hr = textarea_text->setCaretOffset(caret_offset); |
1157 EXPECT_EQ(S_OK, hr); | 1153 EXPECT_EQ(S_OK, hr); |
1158 waiter.WaitForNotification(); | 1154 waiter.WaitForNotification(); |
1159 | 1155 |
1160 hr = textarea_text->get_caretOffset(&caret_offset); | 1156 hr = textarea_text->get_caretOffset(&caret_offset); |
1161 EXPECT_EQ(S_OK, hr); | 1157 EXPECT_EQ(S_OK, hr); |
1162 EXPECT_EQ(0, caret_offset); | 1158 EXPECT_EQ(0, caret_offset); |
1163 } | 1159 } |
1164 | 1160 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 | 1734 |
1739 base::win::ScopedVariant childid_self(CHILDID_SELF); | 1735 base::win::ScopedVariant childid_self(CHILDID_SELF); |
1740 base::win::ScopedBstr image_name; | 1736 base::win::ScopedBstr image_name; |
1741 EXPECT_HRESULT_SUCCEEDED( | 1737 EXPECT_HRESULT_SUCCEEDED( |
1742 image->get_accName(childid_self, image_name.Receive())); | 1738 image->get_accName(childid_self, image_name.Receive())); |
1743 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length())); | 1739 EXPECT_EQ(L"image", std::wstring(image_name, image_name.Length())); |
1744 image_name.Release(); | 1740 image_name.Release(); |
1745 // Cllicking the image will change its name. | 1741 // Cllicking the image will change its name. |
1746 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); | 1742 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); |
1747 AccessibilityNotificationWaiter waiter(shell()->web_contents(), | 1743 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1748 ACCESSIBILITY_MODE_COMPLETE, | 1744 AccessibilityMode::COMPLETE, |
1749 ui::AX_EVENT_TEXT_CHANGED); | 1745 ui::AX_EVENT_TEXT_CHANGED); |
1750 waiter.WaitForNotification(); | 1746 waiter.WaitForNotification(); |
1751 EXPECT_HRESULT_SUCCEEDED( | 1747 EXPECT_HRESULT_SUCCEEDED( |
1752 image->get_accName(childid_self, image_name.Receive())); | 1748 image->get_accName(childid_self, image_name.Receive())); |
1753 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); | 1749 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); |
1754 EXPECT_HRESULT_FAILED(image_action->doAction(1)); | 1750 EXPECT_HRESULT_FAILED(image_action->doAction(1)); |
1755 } | 1751 } |
1756 | 1752 |
1757 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { | 1753 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { |
1758 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize | 1754 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize |
1759 // is not called again after its window is added to the root window. | 1755 // is not called again after its window is added to the root window. |
1760 // Ensure that we still get a legacy HWND for accessibility. | 1756 // Ensure that we still get a legacy HWND for accessibility. |
1761 | 1757 |
1762 host_resolver()->AddRule("*", "127.0.0.1"); | 1758 host_resolver()->AddRule("*", "127.0.0.1"); |
1763 ASSERT_TRUE(embedded_test_server()->Start()); | 1759 ASSERT_TRUE(embedded_test_server()->Start()); |
1764 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 1760 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
1765 shell()->web_contents()); | 1761 shell()->web_contents()); |
1766 WebContentsView* web_contents_view = web_contents->GetView(); | 1762 WebContentsView* web_contents_view = web_contents->GetView(); |
1767 WebContentsViewAura* web_contents_view_aura = | 1763 WebContentsViewAura* web_contents_view_aura = |
1768 static_cast<WebContentsViewAura*>(web_contents_view); | 1764 static_cast<WebContentsViewAura*>(web_contents_view); |
1769 | 1765 |
1770 // Set a flag that will cause WebContentsViewAura to initialize a | 1766 // Set a flag that will cause WebContentsViewAura to initialize a |
1771 // RenderWidgetHostViewAura with a null parent view. | 1767 // RenderWidgetHostViewAura with a null parent view. |
1772 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); | 1768 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); |
1773 | 1769 |
1774 // Navigate to a new page and wait for the accessibility tree to load. | 1770 // Navigate to a new page and wait for the accessibility tree to load. |
1775 AccessibilityNotificationWaiter waiter( | 1771 AccessibilityNotificationWaiter waiter(shell()->web_contents(), |
1776 shell()->web_contents(), | 1772 AccessibilityMode::COMPLETE, |
1777 ACCESSIBILITY_MODE_COMPLETE, | 1773 ui::AX_EVENT_LOAD_COMPLETE); |
1778 ui::AX_EVENT_LOAD_COMPLETE); | |
1779 NavigateToURL(shell(), embedded_test_server()->GetURL( | 1774 NavigateToURL(shell(), embedded_test_server()->GetURL( |
1780 "/accessibility/html/article.html")); | 1775 "/accessibility/html/article.html")); |
1781 waiter.WaitForNotification(); | 1776 waiter.WaitForNotification(); |
1782 | 1777 |
1783 // At this point the root of the accessibility tree shouldn't have an HWND | 1778 // At this point the root of the accessibility tree shouldn't have an HWND |
1784 // because we never gave a parent window to the RWHVA. | 1779 // because we never gave a parent window to the RWHVA. |
1785 BrowserAccessibilityManagerWin* manager = | 1780 BrowserAccessibilityManagerWin* manager = |
1786 static_cast<BrowserAccessibilityManagerWin*>( | 1781 static_cast<BrowserAccessibilityManagerWin*>( |
1787 web_contents->GetRootBrowserAccessibilityManager()); | 1782 web_contents->GetRootBrowserAccessibilityManager()); |
1788 ASSERT_EQ(nullptr, manager->GetParentHWND()); | 1783 ASSERT_EQ(nullptr, manager->GetParentHWND()); |
1789 | 1784 |
1790 // Now add the RWHVA's window to the root window and ensure that we have | 1785 // Now add the RWHVA's window to the root window and ensure that we have |
1791 // an HWND for accessibility now. | 1786 // an HWND for accessibility now. |
1792 web_contents_view->GetNativeView()->AddChild( | 1787 web_contents_view->GetNativeView()->AddChild( |
1793 web_contents->GetRenderWidgetHostView()->GetNativeView()); | 1788 web_contents->GetRenderWidgetHostView()->GetNativeView()); |
1794 ASSERT_NE(nullptr, manager->GetParentHWND()); | 1789 ASSERT_NE(nullptr, manager->GetParentHWND()); |
1795 } | 1790 } |
1796 | 1791 |
1797 } // namespace content | 1792 } // namespace content |
OLD | NEW |