Skip to content

Commit

Permalink
Use safe way to get tab icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Aug 11, 2014
1 parent 9a88897 commit c0632cc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ var privateTab = {
closedTabs.unshift({
state: tabState,
title: tabTitle,
image: gBrowser.getIcon(tab),
image: this.getTabIcon(tab),
pos: tab._tPos,
closedAt: Date.now()
});
Expand All @@ -1291,6 +1291,14 @@ var privateTab = {
closedTabs.splice(maxTabsUndo, length - maxTabsUndo);
}
},
getTabIcon: function(tab) {
var window = tab.ownerDocument.defaultView;
var gBrowser = window.gBrowser;
if("getIcon" in gBrowser)
return gBrowser.getIcon(tab);
return (tab.image || "")
.replace(/[&#]-moz-resolution=\d+,\d+$/, ""); // Firefox 22+
},
checkForLastPrivateTab: function(e) {
var tab = e.originalTarget || e.target;
var window = tab.ownerDocument.defaultView;
Expand Down Expand Up @@ -4020,8 +4028,7 @@ API.prototype = {
if(!tab.parentNode) // Tab was closed
return;
_dbgv && _log("_updateBookmarkFavicon(): delay");
var icon = (tab.image || "")
.replace(/[&#]-moz-resolution=\d+,\d+$/, ""); // Firefox 22+
var icon = privateTabInternal.getTabIcon(tab);
if(!icon)
return;
_log("_updateBookmarkFavicon(): tab icon: " + icon.substr(0, 255));
Expand Down

0 comments on commit c0632cc

Please sign in to comment.