summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/bookmark_bar_view_test.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 23:01:28 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-19 23:01:28 +0000
commitf785ad125747f9125c952c7e74f2154098ee15a9 (patch)
tree69f59438f60dc382d7159d25e2cd34320b71c3c3 /chrome/browser/views/bookmark_bar_view_test.cc
parentec322ff6c39bf30e9b3c1eb878a95507029c6002 (diff)
downloadchromium_src-f785ad125747f9125c952c7e74f2154098ee15a9.zip
chromium_src-f785ad125747f9125c952c7e74f2154098ee15a9.tar.gz
chromium_src-f785ad125747f9125c952c7e74f2154098ee15a9.tar.bz2
Fixes crash when showing modal dialog from context menu. With this
sequence ContainerWin remains on the stack while the modal dialog is showing. Prior to this fix we would delete the ContainerWin, so that when the modal dialog closed control would return to a deleted object. The fix is to effectively delay deleting of the ConatinerWins used by menus. BUG=4580 TEST=This is the sequence that triggered the crash: open a folder on the bookmark bar, right child on a child folder that has more than 15 descendant URLs, click open all, a dialog should appear asking if you really want to open all, click cancel and make sure it doesn't crash. This is a subtle change to bookmark menus though, would be good to thoroughly exercise the menus in as many permutations as you can think of. Review URL: http://codereview.chromium.org/11289 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5724 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/bookmark_bar_view_test.cc')
-rw-r--r--chrome/browser/views/bookmark_bar_view_test.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc
index 94d9a9c..8d31eb1 100644
--- a/chrome/browser/views/bookmark_bar_view_test.cc
+++ b/chrome/browser/views/bookmark_bar_view_test.cc
@@ -5,6 +5,7 @@
#include "base/string_util.h"
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/page_navigator.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/views/bookmark_bar_view.h"
@@ -892,3 +893,69 @@ class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase {
};
VIEW_TEST(BookmarkBarViewTest11, CloseMenuAfterClosingContextMenu)
+
+// Tests showing a modal dialog from a context menu.
+class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase {
+ protected:
+ virtual void DoTestOnMessageLoop() {
+ // Open up the other folder.
+ views::TextButton* button = bb_view_->other_bookmarked_button();
+ ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT,
+ ui_controls::DOWN | ui_controls::UP,
+ CreateEventTask(this, &BookmarkBarViewTest12::Step2));
+ bookmark_utils::num_urls_before_prompting = 1;
+ }
+
+ ~BookmarkBarViewTest12() {
+ bookmark_utils::num_urls_before_prompting = 15;
+ }
+
+ private:
+ void Step2() {
+ // Menu should be showing.
+ views::MenuItemView* menu = bb_view_->GetMenu();
+ ASSERT_TRUE(menu != NULL);
+ ASSERT_TRUE(menu->GetSubmenu()->IsShowing());
+
+ views::MenuItemView* child_menu =
+ menu->GetSubmenu()->GetMenuItemAt(1);
+ ASSERT_TRUE(child_menu != NULL);
+
+ // Right click on the second child (a folder) to get its context menu.
+ ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT,
+ ui_controls::DOWN | ui_controls::UP,
+ CreateEventTask(this, &BookmarkBarViewTest12::Step3));
+ }
+
+ void Step3() {
+ // Make sure the context menu is showing.
+ views::MenuItemView* menu = bb_view_->GetContextMenu();
+ ASSERT_TRUE(menu && menu->GetSubmenu() && menu->GetSubmenu()->IsShowing());
+
+ // Select the first item in the context menu (open all).
+ views::MenuItemView* child_menu =
+ menu->GetSubmenu()->GetMenuItemAt(0);
+ ASSERT_TRUE(child_menu != NULL);
+ ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT,
+ ui_controls::DOWN | ui_controls::UP, NULL);
+
+ // Press tab to give focus to the cancel button.
+ ui_controls::SendKeyPressNotifyWhenDone(VK_TAB, false, false, false,
+ NULL);
+ // And press enter so that the cancel button is selected.
+ ui_controls::SendKeyPressNotifyWhenDone(VK_RETURN, false, false, false,
+ CreateEventTask(this, &BookmarkBarViewTest12::Step4));
+ }
+
+ void Step4() {
+ // Do a delayed task to give the dialog time to exit.
+ MessageLoop::current()->PostTask(
+ FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest12::Step5));
+ }
+
+ void Step5() {
+ Done();
+ }
+};
+
+VIEW_TEST(BookmarkBarViewTest12, CloseWithModalDialog)