Bug 892926 - Findbar steals focus from content when switching tabs r=mconley

This commit is contained in:
Adam Dane [:hobophobe] 2014-04-22 15:37:47 -05:00
parent e406831a66
commit 39512dc04c
2 changed files with 12 additions and 2 deletions

View File

@ -1125,6 +1125,11 @@
// Adjust focus
oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused);
if (this.isFindBarInitialized(oldTab)) {
let findBar = this.getFindBar(oldTab);
oldTab._findBarFocused = (!findBar.hidden &&
findBar._findField.getAttribute("focused") == "true");
}
do {
// When focus is in the tab bar, retain it there.
if (document.activeElement == oldTab) {
@ -1160,8 +1165,9 @@
}
}
// If the find bar is open, focus it.
if (gFindBarInitialized && !gFindBar.hidden) {
// Focus the find bar if it was previously focused for that tab.
if (gFindBarInitialized && !gFindBar.hidden &&
this.selectedTab._findBarFocused) {
gFindBar._findField.focus();
break;
}

View File

@ -86,6 +86,7 @@ function continueTests2() {
// Test for bug 892384
is(gFindBar._findField.getAttribute("focused"), "true",
"Open findbar refocused on tab change!");
gURLBar.focus();
gBrowser.selectedTab = tabs[0];
ok(gFindBar.hidden, "First tab doesn't show find bar!");
@ -95,6 +96,9 @@ function continueTests2() {
// Now we jump to the second, then first, and then fourth
gBrowser.selectedTab = tabs[1];
// Test for bug 892384
ok(!gFindBar._findField.hasAttribute("focused"),
"Open findbar not refocused on tab change!");
gBrowser.selectedTab = tabs[0];
gBrowser.selectedTab = tabs[3];
ok(gFindBar.hidden, "Fourth tab doesn't show find bar!");