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

Unified Diff: ui/views/controls/menu/menu_runner_cocoa_unittest.mm

Issue 1876013002: Fixed potential crash on destroying MenuRunnerImplCocoa. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: ui/views/controls/menu/menu_runner_cocoa_unittest.mm
diff --git a/ui/views/controls/menu/menu_runner_cocoa_unittest.mm b/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
index d25a6628b47db5294dba95b81c3816386746ed48..7505e66b62a82c9ada647b58fc5c8309c8045d41 100644
--- a/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
+++ b/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
@@ -159,6 +159,19 @@ TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) {
EXPECT_EQ(MenuRunner::MENU_DELETED, result);
}
+// Tests that there is no "use after free" when we canceling menu
+// (that causes deferred destructor in MenuRunnerImplCocoa::RunMenuAt()) and
+// release it just after canceling (that was cause destructor
+// in MenuRunnerImplCocoa::Release()).
tapted 2016/04/12 06:22:58 this comment is a bit hard to read perhaps // Ens
+TEST_F(MenuRunnerCocoaTest, DestroyAfterCanceling) {
+ MenuRunner::RunResult result = RunMenu(^{
tapted 2016/04/12 06:22:58 We got rid of all the Objective C blocks in this f
+ runner_->Cancel();
+ runner_->Release();
tapted 2016/04/12 06:22:58 Is there code in Chrome that already follows this
+ runner_ = nullptr;
+ });
+ EXPECT_EQ(MenuRunner::MENU_DELETED, result);
+}
+
TEST_F(MenuRunnerCocoaTest, RunMenuTwice) {
for (int i = 0; i < 2; ++i) {
MenuRunner::RunResult result = RunMenu(^{
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_runner_impl_cocoa.h » ('j') | ui/views/controls/menu/menu_runner_impl_cocoa.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698