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
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 01 Feb 2011 13:27:07 -0800
changeset 61750 4b8f9705b339fd050bf0981d591f7a02c8a686e6
parent 61749 9521cf441d3ad078398e9ffbee7cc02e998841e3
child 61751 a85d6ae60d96ff4523de57ab315ba72fd96a955d
push idunknown
push userunknown
push dateunknown
reviewersUnfocused, sdwilsh
bugs629418
milestone2.0b11pre
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
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser_bug562797.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1514,20 +1514,28 @@ var gHeader = {
     this._search.addEventListener("command", function(aEvent) {
       var query = aEvent.target.value;
       if (query.length == 0)
         return false;
 
       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() {
     var docshellItem = window.QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIWebNavigation)
                              .QueryInterface(Ci.nsIDocShellTreeItem);
 
     // If there is no outer frame then make the buttons visible
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
@@ -623,8 +623,42 @@ add_test(function() {
         info("Part 1");
         is_in_list(aManager, "addons://list/plugin", false, false);
 
         close_manager(aManager, run_next_test);
       });
     });
   });
 });
+
+// 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);
+});