diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 7588afd0ca16..10401ae66ea3 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7766,13 +7766,11 @@ var TabContextMenu = {
menuItems[i].disabled = disabled;
// Session store
- // XXXzeniko should't we just disable this item as we disable
- // the tabbrowser-multiple items above - for consistency?
- document.getElementById("context_undoCloseTab").hidden =
+ document.getElementById("context_undoCloseTab").disabled =
Cc["@mozilla.org/browser/sessionstore;1"].
getService(Ci.nsISessionStore).
getClosedTabCount(window) == 0;
-
+
// Only one of pin/unpin should be visible
document.getElementById("context_pinTab").hidden = this.contextTab.pinned;
document.getElementById("context_unpinTab").hidden = !this.contextTab.pinned;
diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul
index f7cf0c28ce50..5a10e69f895d 100644
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -140,7 +140,7 @@
+ observes="History:UndoCloseTab"/>
diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in
index 65f2804b880d..36c434f1bef4 100644
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -137,6 +137,7 @@ _BROWSER_FILES = \
browser_bug562649.js \
browser_bug563588.js \
browser_bug577121.js \
+ browser_bug580956.js \
browser_contextSearchTabPosition.js \
browser_ctrlTab.js \
browser_discovery.js \
diff --git a/browser/base/content/test/browser_bug580956.js b/browser/base/content/test/browser_bug580956.js
new file mode 100644
index 000000000000..67c3c14abd5d
--- /dev/null
+++ b/browser/base/content/test/browser_bug580956.js
@@ -0,0 +1,27 @@
+function numClosedTabs()
+ Cc["@mozilla.org/browser/sessionstore;1"].
+ getService(Ci.nsISessionStore).
+ getClosedTabCount(window);
+
+function isUndoCloseEnabled() {
+ document.popupNode = gBrowser.tabs[0];
+ TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
+ return !document.getElementById("context_undoCloseTab").disabled;
+}
+
+function test() {
+ waitForExplicitFinish();
+
+ gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", 0);
+ gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
+ is(numClosedTabs(), 0, "There should be 0 closed tabs.");
+ ok(!isUndoCloseEnabled(), "Undo Close Tab should be disabled.");
+
+ var tab = gBrowser.addTab("http://mochi.test:8888/");
+ var browser = gBrowser.getBrowserForTab(tab);
+ browser.addEventListener("load", function() {
+ gBrowser.removeTab(tab);
+ ok(isUndoCloseEnabled(), "Undo Close Tab should be enabled.");
+ finish();
+ }, true);
+}