summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 18:45:45 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 18:45:45 +0000
commitd0033329c98edaf3fff226aabe8f5adc7aa10c62 (patch)
treec9f400c195784b778ca8dc24a945abcf91a4ec5c /chrome/browser/views
parentd53b4ad91e57d3cf64c3188a89843242c75347aa (diff)
downloadchromium_src-d0033329c98edaf3fff226aabe8f5adc7aa10c62.zip
chromium_src-d0033329c98edaf3fff226aabe8f5adc7aa10c62.tar.gz
chromium_src-d0033329c98edaf3fff226aabe8f5adc7aa10c62.tar.bz2
Fix 8063: Find-in-page remains open on History/Downloads page.
Added a UI test to catch this in the future. Also, in some of the UI tests I added a generic URL for pages that don't care about the content of the page and are just testing visibility of the Find box, etc. TEST=Covered by tests already. BUG=8063 Review URL: http://codereview.chromium.org/28162 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/find_bar_win.cc8
-rw-r--r--chrome/browser/views/find_bar_win_uitest.cc44
-rw-r--r--chrome/browser/views/frame/browser_view.cc2
3 files changed, 48 insertions, 6 deletions
diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc
index 8c4cce9..dd9056c 100644
--- a/chrome/browser/views/find_bar_win.cc
+++ b/chrome/browser/views/find_bar_win.cc
@@ -225,10 +225,12 @@ void FindBarWin::ChangeWebContents(WebContents* contents) {
web_contents_ = contents;
- if (web_contents_) {
- if (IsVisible() && web_contents_ && !web_contents_->find_ui_active())
- ShowWindow(SW_HIDE);
+ // Hide any visible find window from the previous tab if NULL |web_contents|
+ // is passed in or if the find UI is not active in the new tab.
+ if (IsVisible() && (!web_contents_ || !web_contents_->find_ui_active()))
+ ShowWindow(SW_HIDE);
+ if (web_contents_) {
NotificationService::current()->AddObserver(
this, NotificationType::FIND_RESULT_AVAILABLE,
Source<TabContents>(web_contents_));
diff --git a/chrome/browser/views/find_bar_win_uitest.cc b/chrome/browser/views/find_bar_win_uitest.cc
index 21d2287..88dc0ed 100644
--- a/chrome/browser/views/find_bar_win_uitest.cc
+++ b/chrome/browser/views/find_bar_win_uitest.cc
@@ -17,6 +17,7 @@ class FindInPageControllerTest : public UITest {
}
};
+const std::wstring kSimplePage = L"404_is_enough_for_us.html";
const std::wstring kFramePage = L"files/find_in_page/frames.html";
const std::wstring kFrameData = L"files/find_in_page/framedata_general.html";
const std::wstring kUserSelectPage = L"files/find_in_page/user-select.html";
@@ -198,7 +199,7 @@ TEST_F(FindInPageControllerTest, FindMovesOnTabClose_Issue1343052) {
HTTPTestServer::CreateServer(L"chrome/test/data", NULL);
ASSERT_TRUE(NULL != server.get());
- GURL url = server->TestServerPageW(kFramePage);
+ GURL url = server->TestServerPageW(kSimplePage);
scoped_ptr<TabProxy> tabA(GetActiveTab());
ASSERT_TRUE(tabA->NavigateToURL(url));
WaitUntilTabCount(1);
@@ -259,7 +260,7 @@ TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
HTTPTestServer::CreateServer(L"chrome/test/data", NULL);
ASSERT_TRUE(NULL != server.get());
- GURL url = server->TestServerPageW(kUserSelectPage);
+ GURL url = server->TestServerPageW(kSimplePage);
GURL url2 = server->TestServerPageW(kFramePage);
scoped_ptr<TabProxy> tab(GetActiveTab());
ASSERT_TRUE(tab->NavigateToURL(url));
@@ -280,3 +281,42 @@ TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
EXPECT_TRUE(tab->NavigateToURL(url2));
EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), false));
}
+
+// Make sure Find box disappears when History/Downloads page is opened, and
+// when a New Tab is opened.
+TEST_F(FindInPageControllerTest, FindDisappearOnNewTabAndHistory) {
+ scoped_refptr<HTTPTestServer> server =
+ HTTPTestServer::CreateServer(L"chrome/test/data", NULL);
+ ASSERT_TRUE(NULL != server.get());
+
+ GURL url = server->TestServerPageW(kSimplePage);
+ scoped_ptr<TabProxy> tab(GetActiveTab());
+ ASSERT_TRUE(tab->NavigateToURL(url));
+ WaitUntilTabCount(1);
+
+ scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get() != NULL);
+
+ // Open the Find window and wait for it to animate.
+ EXPECT_TRUE(browser->OpenFindInPage());
+ EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true));
+
+ // Open another tab (tab B).
+ EXPECT_TRUE(browser->AppendTab(url));
+ scoped_ptr<TabProxy> tabB(GetActiveTab());
+
+ // Wait for the Find box to disappear.
+ EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), false));
+
+ // Close tab B.
+ EXPECT_TRUE(tabB->Close(true));
+
+ // Wait for the Find box to appear again.
+ EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), true));
+
+ // Open History page.
+ EXPECT_TRUE(browser->RunCommand(IDC_SHOW_HISTORY));
+
+ // Wait for the Find box to disappear.
+ EXPECT_TRUE(WaitForFindWindowVisibilityChange(browser.get(), false));
+}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index f06bd67..e7b36b8 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -937,7 +937,7 @@ void BrowserView::TabSelectedAt(TabContents* old_contents,
UpdateToolbar(new_contents, true);
UpdateUIForContents(new_contents);
- if (find_bar_.get() && new_contents->AsWebContents())
+ if (find_bar_.get())
find_bar_->ChangeWebContents(new_contents->AsWebContents());
}