Check if the tab is closed when trying to set its icon
This commit is contained in:
parent
23190af270
commit
6fa6982e8e
11
messaging.js
11
messaging.js
|
@ -49,10 +49,15 @@ function updateIcon(tab, styles) {
|
||||||
chrome.browserAction.setIcon({
|
chrome.browserAction.setIcon({
|
||||||
path: {19: "19" + postfix + ".png", 38: "38" + postfix + ".png"},
|
path: {19: "19" + postfix + ".png", 38: "38" + postfix + ".png"},
|
||||||
tabId: tab.id
|
tabId: tab.id
|
||||||
|
}, function() {
|
||||||
|
// if the tab was just closed an error may occur,
|
||||||
|
// e.g. 'windowPosition' pref updated in edit.js::window.onbeforeunload
|
||||||
|
if (!chrome.runtime.lastError) {
|
||||||
|
var t = prefs.get("show-badge") && styles.length ? ("" + styles.length) : "";
|
||||||
|
chrome.browserAction.setBadgeText({text: t, tabId: tab.id});
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({color: disableAll ? "#aaa" : [0, 0, 0, 0]});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var t = prefs.get("show-badge") && styles.length ? ("" + styles.length) : "";
|
|
||||||
chrome.browserAction.setBadgeText({text: t, tabId: tab.id});
|
|
||||||
chrome.browserAction.setBadgeBackgroundColor({color: disableAll ? "#aaa" : [0, 0, 0, 0]});
|
|
||||||
//console.log("Tab " + tab.id + " (" + tab.url + ") badge text set to '" + t + "'.");
|
//console.log("Tab " + tab.id + " (" + tab.url + ") badge text set to '" + t + "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user