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

Unified Diff: ui/views/accessibility/native_view_accessibility_win_unittest.cc

Issue 23851012: Fix crash when calling get_accChild on empty WebView. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/accessibility/native_view_accessibility_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/accessibility/native_view_accessibility_win_unittest.cc
diff --git a/ui/views/accessibility/native_view_accessibility_win_unittest.cc b/ui/views/accessibility/native_view_accessibility_win_unittest.cc
index 7dcbac221458f538d7b625be3c2f820392bbcb0a..db0b64a438a3f9342ff90e9539a451dbb094989a 100644
--- a/ui/views/accessibility/native_view_accessibility_win_unittest.cc
+++ b/ui/views/accessibility/native_view_accessibility_win_unittest.cc
@@ -7,6 +7,7 @@
#include "base/win/scoped_bstr.h"
#include "base/win/scoped_comptr.h"
#include "base/win/scoped_variant.h"
+#include "ui/views/accessibility/native_view_accessibility.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/test/views_test_base.h"
@@ -61,5 +62,34 @@ TEST_F(NativeViewAcccessibilityWinTest, TextfieldAccessibility) {
ASSERT_STREQ(L"New value", textfield->text().c_str());
}
+TEST_F(NativeViewAcccessibilityWinTest, UnattachedWebView) {
+ // This is a regression test. Calling get_accChild on the native accessible
+ // object for a WebView with no attached WebContents was causing an
+ // infinite loop and crash. This test simulates that with an ordinary
+ // View that registers itself as a web view with NativeViewAcccessibility.
+
+ Widget widget;
+ Widget::InitParams init_params =
+ CreateParams(Widget::InitParams::TYPE_POPUP);
+ init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget.Init(init_params);
+
+ View* content = new View;
+ widget.SetContentsView(content);
+
+ View* web_view = new View;
+ content->AddChildView(web_view);
+ NativeViewAccessibility::RegisterWebView(web_view);
+
+ base::win::ScopedComPtr<IAccessible> web_view_accessible(
+ web_view->GetNativeViewAccessible());
+ base::win::ScopedComPtr<IDispatch> result_dispatch;
+ base::win::ScopedVariant child_index(-999);
+ ASSERT_EQ(E_FAIL, web_view_accessible->get_accChild(
+ child_index, result_dispatch.Receive()));
+
+ NativeViewAccessibility::UnregisterWebView(web_view);
+}
+
} // namespace test
} // namespace views
« no previous file with comments | « ui/views/accessibility/native_view_accessibility_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698