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

Unified Diff: lib/stats.js

Issue 29680693: [$csp3 adblockpluschrome] Issue 5241 - Avoid setting badge text before navigation is committed (Closed)
Patch Set: Remove onLoading listener Created March 7, 2018, 11:32 a.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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/stats.js
diff --git a/lib/stats.js b/lib/stats.js
index f64c2cee9f5835610f8e08da253473a32ea9c895..ae586b8f0989cc15b3da1271051b629ac8b6b380 100644
--- a/lib/stats.js
+++ b/lib/stats.js
@@ -36,13 +36,18 @@ let getBlockedPerPage =
*/
exports.getBlockedPerPage = page => blockedPerPage.get(page) || 0;
-// Chrome automatically clears the browser action badge text when the URL of
-// the tab is updated, but Firefox doesn't.
-// https://bugzilla.mozilla.org/show_bug.cgi?id=1395074
-ext.pages.onLoading.addListener(page =>
+// Once nagivation for the tab has been committed to (e.g. it's no longer
+// being prerendered) we clear its badge, or if some requests were already
+// blocked beforehand we display those on the badge now.
+browser.webNavigation.onCommitted.addListener(details =>
{
- if (!blockedPerPage.get(page))
- page.browserAction.setBadge();
+ let page = new ext.Page({id: details.tabId});
+ let blocked = blockedPerPage.get(page);
+
+ page.browserAction.setBadge(blocked && {
+ color: badgeColor,
+ number: blocked
+ });
});
FilterNotifier.on("filter.hitCount", (filter, newValue, oldValue, page) =>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld