Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/stats.js

Issue 6444238522810368: Fixed unit tests (Closed)
Patch Set: Created Dec. 18, 2013, 12:54 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | qunit/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/stats.js
===================================================================
--- a/lib/stats.js
+++ b/lib/stats.js
@@ -37,39 +37,39 @@ let getStats = exports.getStats = functi
return (key in Prefs.stats_total ? Prefs.stats_total[key] : 0);
let frameData = getFrameData(tab, 0);
return (frameData && key in frameData ? frameData[key] : 0);
};
FilterNotifier.addListener(function(action, item, newValue, oldValue, tab)
{
- if (action != "filter.hitCount")
+ if (action != "filter.hitCount" || !tab)
return;
-
+
let blocked = item instanceof BlockingFilter;
-
+
// Increment counts
if (blocked)
{
if ("blocked" in Prefs.stats_total)
Prefs.stats_total.blocked++;
else
Prefs.stats_total.blocked = 1;
Prefs.stats_total = Prefs.stats_total;
-
+
let frameData = getFrameData(tab, 0);
if (frameData)
{
if ("blocked" in frameData)
frameData.blocked++;
else
frameData.blocked = 1;
}
-
+
// Update number in icon
if (Prefs.show_statsinicon)
{
tab.browserAction.setBadge({
color: badgeColor,
number: frameData.blocked
});
}
@@ -94,17 +94,17 @@ function forEachTab(func)
}
});
}
Prefs.addListener(function(name)
{
if (name != "show_statsinicon")
return;
-
+
forEachTab(function(tab)
{
let badge = null;
if (Prefs.show_statsinicon)
{
let frameData = getFrameData(tab, 0);
if (frameData && "blocked" in frameData)
{
« no previous file with comments | « no previous file | qunit/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld