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

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

Issue 383263002: Fix a use after free crasher in the BrowserAccessibilityManagerWinTest.TestAccessibleHWND test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/accessibility/browser_accessibility_win.cc ('k') | no next file » | 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/win/scoped_bstr.h" 7 #include "base/win/scoped_bstr.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/scoped_variant.h" 9 #include "base/win/scoped_variant.h"
10 #include "content/browser/accessibility/browser_accessibility_manager.h" 10 #include "content/browser/accessibility/browser_accessibility_manager.h"
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // new parent_hwnd with the right window class to fool older screen 737 // new parent_hwnd with the right window class to fool older screen
738 // readers. 738 // readers.
739 BrowserAccessibilityStateImpl::GetInstance()->OnScreenReaderDetected(); 739 BrowserAccessibilityStateImpl::GetInstance()->OnScreenReaderDetected();
740 manager->MaybeCallNotifyWinEvent(0, 0); 740 manager->MaybeCallNotifyWinEvent(0, 0);
741 HWND new_parent_hwnd = manager->parent_hwnd(); 741 HWND new_parent_hwnd = manager->parent_hwnd();
742 ASSERT_NE(desktop_hwnd, new_parent_hwnd); 742 ASSERT_NE(desktop_hwnd, new_parent_hwnd);
743 WCHAR hwnd_class_name[256]; 743 WCHAR hwnd_class_name[256];
744 ASSERT_NE(0, GetClassName(new_parent_hwnd, hwnd_class_name, 256)); 744 ASSERT_NE(0, GetClassName(new_parent_hwnd, hwnd_class_name, 256));
745 ASSERT_STREQ(L"Chrome_RenderWidgetHostHWND", hwnd_class_name); 745 ASSERT_STREQ(L"Chrome_RenderWidgetHostHWND", hwnd_class_name);
746 746
747 // Destroy the hwnd explicitly; that should trigger clearing parent_hwnd(). 747 // Destroy the TestLegacyRenderWidgetHostHWND instance. That should in turn
748 DestroyWindow(new_parent_hwnd); 748 // destroy the hwnd, which should clear the parent_hwnd().
749 accessibility_test.reset(NULL);
750 ASSERT_EQ(FALSE, ::IsWindow(new_parent_hwnd));
749 ASSERT_EQ(NULL, manager->parent_hwnd()); 751 ASSERT_EQ(NULL, manager->parent_hwnd());
750 752
751 // Now create it again. 753 // Now create it again.
752 accessibility_test.reset(new TestLegacyRenderWidgetHostHWND); 754 accessibility_test.reset(new TestLegacyRenderWidgetHostHWND);
753 EXPECT_EQ(accessibility_test->Initialize(::GetDesktopWindow()), true); 755 EXPECT_EQ(accessibility_test->Initialize(::GetDesktopWindow()), true);
754 manager.reset( 756 manager.reset(
755 new BrowserAccessibilityManagerWin( 757 new BrowserAccessibilityManagerWin(
756 accessibility_test->accessible_hwnd(), 758 accessibility_test->accessible_hwnd(),
757 desktop_hwnd_iaccessible, 759 desktop_hwnd_iaccessible,
758 BrowserAccessibilityManagerWin::GetEmptyDocument(), 760 BrowserAccessibilityManagerWin::GetEmptyDocument(),
759 NULL)); 761 NULL));
760 manager->MaybeCallNotifyWinEvent(0, 0); 762 manager->MaybeCallNotifyWinEvent(0, 0);
761 new_parent_hwnd = manager->parent_hwnd(); 763 new_parent_hwnd = manager->parent_hwnd();
762 ASSERT_FALSE(NULL == new_parent_hwnd); 764 ASSERT_FALSE(NULL == new_parent_hwnd);
763 765
764 // This time, destroy the manager first, make sure the AccessibleHWND doesn't 766 // This time, destroy the manager first, make sure the AccessibleHWND doesn't
765 // crash on destruction (to be caught by SyzyASAN or other tools). 767 // crash on destruction (to be caught by SyzyASAN or other tools).
766 manager.reset(NULL); 768 manager.reset(NULL);
767 } 769 }
768 770
769 } // namespace content 771 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698