Badge count accurately reflects number of unread or active items
Why it matters
A badge count that drifts from reality undermines the entire notification contract. When bulk-delete actions, crash-interrupted decrements, or missed code paths leave the counter stale, users open the popup expecting unread items and find none — or worse, miss real items because the badge showed zero. ISO 25010:2011 functional-suitability.functional-correctness applies directly: the badge's job is accurate representation of state, and independent increment/decrement counters are structurally incapable of guaranteeing that.
Severity rationale
Medium because stale badge counts cause user confusion and erode trust in the extension's reliability, but do not expose security risk or block core functionality.
Remediation
Derive the badge count from a single source of truth on every update rather than maintaining a separate counter. Tie badge updates to chrome.storage.onChanged so any write to the underlying data automatically recalculates the displayed count.
async function updateBadge() {
const { items } = await chrome.storage.local.get(['items']);
const unread = (items ?? []).filter(item => !item.read).length;
chrome.action.setBadgeText({
text: unread > 0 ? String(unread) : ''
});
}
chrome.storage.onChanged.addListener(() => updateBadge());
Never increment or decrement a counter variable directly — every code path that modifies items must go through storage, and onChanged handles the badge automatically.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Extension UX & Performance Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · functional-suitability.functional-correctness
Taxons
History
- 2026-04-18·v1.0.0·Initial import from extension-ux-performance·automated