Make getURLFromTab more robust against ghost tabs from ctrl-clicking downloadable files. Closes issue 790.
Make getURLFromTab more robust against ghost tabs from ctrl-clicking downloadable files. Closes issue 790.

diff --git a/common/content/buffer.js b/common/content/buffer.js
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -1349,21 +1349,25 @@
         function getIndicator (tab) {
             if (tab == config.tabbrowser.mCurrentTab)
                 return "%";
             else if (tab == tabs.alternate)
                 return "#";
             return " ";
         }
         function getURLFromTab (tab) {
-            if ("linkedBrowser" in tab)
-                return ("__SS_restoreState" in tab.linkedBrowser && "__SS_data" in tab.linkedBrowser) ?
-                    tab.linkedBrowser.__SS_data.entries.slice(-1)[0].url :
-                    tab.linkedBrowser.contentDocument.location.href;
-            else {
+            if ("linkedBrowser" in tab) {
+                if ("__SS_restoreState" in tab.linkedBrowser && "__SS_data" in tab.linkedBrowser) {
+                    if (tab.linkedBrowser.__SS_data.entries.length)
+                        return tab.linkedBrowser.__SS_data.entries.slice(-1)[0].url;
+                    else
+                        return tab.linkedBrowser.__SS_data.userTypedValue || 'about:blank';
+                } else
+                    return tab.linkedBrowser.contentDocument.location.href;
+            } else {
                 let i = config.tabbrowser.mTabContainer.getIndexOfItem(tab);
                 let info = config.tabbrowser.tabInfo[i];
                 return info.browser ?
                     info.browser.contentDocument.location.href :
                     info.mode.getBrowser(tab).contentDocument.location.href;
             }
         }
smarter/vimperator-labs