From 4e45c5bb30d03b6dd2aa046e81a2990e12d994b6 Mon Sep 17 00:00:00 2001 From: "Adam Dane [:hobophobe]" Date: Thu, 11 Jul 2013 18:42:34 -0500 Subject: [PATCH] Bug 892384 - When switching to a tab with an open find bar, focus it. r=dao --HG-- extra : rebase_source : b55d5a749c8349552fdcebd531da893bebe18007 --- browser/base/content/tabbrowser.xml | 8 ++++---- browser/base/content/test/browser_bug537013.js | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index 7fe05923b1b7..4034a220deb0 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1105,11 +1105,11 @@ } } - // If the find bar is focused, keep it focused. - if (gFindBarInitialized && - !gFindBar.hidden && - gFindBar.getElement("findbar-textbox").getAttribute("focused") == "true") + // If the find bar is open, focus it. + if (gFindBarInitialized && !gFindBar.hidden) { + gFindBar._findField.focus(); break; + } // Otherwise, focus the content area. let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); diff --git a/browser/base/content/test/browser_bug537013.js b/browser/base/content/test/browser_bug537013.js index 87080b879a45..2a54dfc96407 100644 --- a/browser/base/content/test/browser_bug537013.js +++ b/browser/base/content/test/browser_bug537013.js @@ -69,6 +69,9 @@ function continueTests() { ok(gFindBar.hidden, "First tab doesn't show find bar!"); gBrowser.selectedTab = tabs[1]; ok(!gFindBar.hidden, "Second tab shows find bar!"); + // Test for bug 892384 + is(gFindBar._findField.getAttribute("focused"), "true", + "Open findbar refocused on tab change!"); gBrowser.selectedTab = tabs[0]; ok(gFindBar.hidden, "First tab doesn't show find bar!");