diff --git a/mobile/chrome/content/bindings.xml b/mobile/chrome/content/bindings.xml index 4e6960558576..003d558c13fb 100644 --- a/mobile/chrome/content/bindings.xml +++ b/mobile/chrome/content/bindings.xml @@ -391,11 +391,25 @@ if (!item.hasAttribute("url")) continue; - let itemHost = self._getEffectiveHost(Services.io.newURI(item.getAttribute("url"), null, null)); + let currentURL = item.getAttribute("url"); + let itemHost = self._getEffectiveHost(Services.io.newURI(currentURL, null, null)); for (let badgeHost in self._badges) { if (itemHost == badgeHost) { + // wrap the item to prevent setting a badge on a wrong item + let wrapper = { + set: function(aBadge) { + if (item.getAttribute("url") != currentURL) + return; + + if (!aBadge || aBadge == "") + item.removeAttribute("badge"); + else + item.setAttribute("badge", aBadge); + } + }; + let handler = self._badges[badgeHost]; - handler.updateBadge ? handler.updateBadge(item) : handler(item); + handler.updateBadge ? handler.updateBadge(wrapper) : handler(wrapper); break; } } @@ -1216,15 +1230,15 @@ tabs.push({ name: client.clientName }); client.tabs.forEach(function({title, urlHistory, icon}) { - let pageUrl = urlHistory[0]; + let pageURL = urlHistory[0]; // Skip tabs that are already open - if (engine.locallyOpenTabMatchesURL(pageUrl)) + if (engine.locallyOpenTabMatchesURL(pageURL)) return; tabs.push({ - title: title || pageUrl, - uri: pageUrl, + title: title || pageURL, + uri: pageURL, icon: Weave.Utils.getIcon(icon, "chrome://browser/skin/images/tab.png") }); }); diff --git a/mobile/chrome/content/browser-ui.js b/mobile/chrome/content/browser-ui.js index c1f950bb4f8b..b2a8e448a532 100644 --- a/mobile/chrome/content/browser-ui.js +++ b/mobile/chrome/content/browser-ui.js @@ -2512,11 +2512,11 @@ var BadgeHandlers = { _lastUpdate: 0, _lastCount: 0, url: "http://mail.google.com", - updateBadge: function(aItem) { + updateBadge: function(aBadge) { // Use the cache if possible let now = Date.now(); if (this._lastCount && this._lastUpdate > now - 1000) { - aItem.setAttribute("badge", this._lastCount); + aBadge.set(this._lastCount); return; } @@ -2538,7 +2538,7 @@ var BadgeHandlers = { } else { this._lastCount = 0; } - this._lastCount = BadgeHandlers.setNumberBadge(aItem, this._lastCount); + this._lastCount = BadgeHandlers.setNumberBadge(aBadge, this._lastCount); } }; req.send(null); @@ -2566,12 +2566,12 @@ var BadgeHandlers = { return aValue; }, - setNumberBadge: function(aItem, aValue) { + setNumberBadge: function(aBadge, aValue) { if (parseInt(aValue) != 0) { aValue = this.clampBadge(aValue); - aItem.setAttribute("badge", aValue); + aBadge.set(aValue); } else { - aItem.removeAttribute("badge"); + aBadge.set(""); } return aValue; }