Bug 629418: If the add-ons manager is opened as a background tab (e.g. by session restore) then the back and forward buttons are hidden. r=Unfocused, a=sdwilsh

This commit is contained in:
Dave Townsend 2011-02-01 13:27:07 -08:00
parent ad76d4bbbc
commit e0605bd695
2 changed files with 45 additions and 3 deletions

View File

@ -1519,10 +1519,18 @@ var gHeader = {
gViewController.loadView("addons://search/" + encodeURIComponent(query));
}, false);
if (this.shouldShowNavButtons) {
document.getElementById("back-btn").hidden = false;
document.getElementById("forward-btn").hidden = false;
function updateNavButtonVisibility() {
var shouldShow = gHeader.shouldShowNavButtons;
document.getElementById("back-btn").hidden = !shouldShow;
document.getElementById("forward-btn").hidden = !shouldShow;
}
window.addEventListener("focus", function(aEvent) {
if (aEvent.target == window)
updateNavButtonVisibility();
}, false);
updateNavButtonVisibility();
},
get shouldShowNavButtons() {

View File

@ -628,3 +628,37 @@ add_test(function() {
});
});
});
// Tests that when displaying in-content and opened in the background the back
// and forward buttons still appear when switching tabs
add_test(function() {
if (!gUseInContentUI)
run_next_text();
var tab = gBrowser.addTab("about:addons");
var browser = gBrowser.getBrowserForTab(tab);
browser.addEventListener("pageshow", function(event) {
if (event.target.location.href != "about:addons")
return;
browser.removeEventListener("pageshow", arguments.callee, true);
wait_for_manager_load(browser.contentWindow.wrappedJSObject, function() {
wait_for_view_load(browser.contentWindow.wrappedJSObject, function(aManager) {
gBrowser.selectedTab = tab;
var doc = aManager.document;
var btn = document.getElementById("back-button");
if (!btn || is_hidden(btn)) {
is_element_visible(doc.getElementById("back-btn"), "Back button should not be hidden");
is_element_visible(doc.getElementById("forward-btn"), "Forward button should not be hidden");
} else {
is_element_hidden(doc.getElementById("back-btn"), "Back button should be hidden");
is_element_hidden(doc.getElementById("forward-btn"), "Forward button should be hidden");
}
close_manager(aManager, run_next_test);
});
});
}, true);
});