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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "base/win/scoped_bstr.h" | 14 #include "base/win/scoped_bstr.h" |
15 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
16 #include "base/win/scoped_variant.h" | 16 #include "base/win/scoped_variant.h" |
17 #include "content/browser/accessibility/accessibility_mode_helper.h" | 17 #include "content/browser/accessibility/accessibility_mode_helper.h" |
18 #include "content/browser/accessibility/accessibility_tree_formatter.h" | 18 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
19 #include "content/browser/accessibility/accessibility_tree_formatter_utils_win.h
" | 19 #include "content/browser/accessibility/accessibility_tree_formatter_utils_win.h
" |
| 20 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
20 #include "content/browser/accessibility/browser_accessibility_win.h" | 21 #include "content/browser/accessibility/browser_accessibility_win.h" |
21 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 23 #include "content/browser/web_contents/web_contents_impl.h" |
| 24 #include "content/browser/web_contents/web_contents_view_aura.h" |
22 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 26 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
25 #include "content/public/browser/render_widget_host_view.h" | 28 #include "content/public/browser/render_widget_host_view.h" |
26 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
28 #include "content/public/test/content_browser_test.h" | 31 #include "content/public/test/content_browser_test.h" |
29 #include "content/public/test/content_browser_test_utils.h" | 32 #include "content/public/test/content_browser_test_utils.h" |
30 #include "content/shell/browser/shell.h" | 33 #include "content/shell/browser/shell.h" |
31 #include "content/test/accessibility_browser_test_utils.h" | 34 #include "content/test/accessibility_browser_test_utils.h" |
32 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
| 36 #include "net/dns/mock_host_resolver.h" |
| 37 #include "net/test/embedded_test_server/embedded_test_server.h" |
33 #include "third_party/iaccessible2/ia2_api_all.h" | 38 #include "third_party/iaccessible2/ia2_api_all.h" |
34 #include "third_party/isimpledom/ISimpleDOMNode.h" | 39 #include "third_party/isimpledom/ISimpleDOMNode.h" |
35 #include "ui/aura/window.h" | 40 #include "ui/aura/window.h" |
36 #include "ui/aura/window_tree_host.h" | 41 #include "ui/aura/window_tree_host.h" |
37 | 42 |
38 namespace content { | 43 namespace content { |
39 | 44 |
40 namespace { | 45 namespace { |
41 | 46 |
42 | 47 |
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); | 1709 EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); |
1705 AccessibilityNotificationWaiter waiter(shell(), AccessibilityModeComplete, | 1710 AccessibilityNotificationWaiter waiter(shell(), AccessibilityModeComplete, |
1706 ui::AX_EVENT_TEXT_CHANGED); | 1711 ui::AX_EVENT_TEXT_CHANGED); |
1707 waiter.WaitForNotification(); | 1712 waiter.WaitForNotification(); |
1708 EXPECT_HRESULT_SUCCEEDED( | 1713 EXPECT_HRESULT_SUCCEEDED( |
1709 image->get_accName(childid_self, image_name.Receive())); | 1714 image->get_accName(childid_self, image_name.Receive())); |
1710 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); | 1715 EXPECT_EQ(L"image2", std::wstring(image_name, image_name.Length())); |
1711 EXPECT_HRESULT_FAILED(image_action->doAction(1)); | 1716 EXPECT_HRESULT_FAILED(image_action->doAction(1)); |
1712 } | 1717 } |
1713 | 1718 |
| 1719 IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { |
| 1720 // This test simulates a scenario where RenderWidgetHostViewAura::SetSize |
| 1721 // is not called again after its window is added to the root window. |
| 1722 // Ensure that we still get a legacy HWND for accessibility. |
| 1723 |
| 1724 host_resolver()->AddRule("*", "127.0.0.1"); |
| 1725 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1726 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 1727 shell()->web_contents()); |
| 1728 WebContentsView* web_contents_view = web_contents->GetView(); |
| 1729 WebContentsViewAura* web_contents_view_aura = |
| 1730 static_cast<WebContentsViewAura*>(web_contents_view); |
| 1731 |
| 1732 // Set a flag that will cause WebContentsViewAura to initialize a |
| 1733 // RenderWidgetHostViewAura with a null parent view. |
| 1734 web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); |
| 1735 |
| 1736 // Navigate to a new page and wait for the accessibility tree to load. |
| 1737 AccessibilityNotificationWaiter waiter( |
| 1738 shell(), AccessibilityModeComplete, |
| 1739 ui::AX_EVENT_LOAD_COMPLETE); |
| 1740 NavigateToURL(shell(), embedded_test_server()->GetURL( |
| 1741 "/accessibility/html/article.html")); |
| 1742 waiter.WaitForNotification(); |
| 1743 |
| 1744 // At this point the root of the accessibility tree shouldn't have an HWND |
| 1745 // because we never gave a parent window to the RWHVA. |
| 1746 BrowserAccessibilityManagerWin* manager = |
| 1747 static_cast<BrowserAccessibilityManagerWin*>( |
| 1748 web_contents->GetRootBrowserAccessibilityManager()); |
| 1749 ASSERT_EQ(nullptr, manager->GetParentHWND()); |
| 1750 |
| 1751 // Now add the RWHVA's window to the root window and ensure that we have |
| 1752 // an HWND for accessibility now. |
| 1753 web_contents_view->GetNativeView()->AddChild( |
| 1754 web_contents->GetRenderWidgetHostView()->GetNativeView()); |
| 1755 ASSERT_NE(nullptr, manager->GetParentHWND()); |
| 1756 } |
| 1757 |
1714 } // namespace content | 1758 } // namespace content |
OLD | NEW |