Context menu items are context-aware and only appear when relevant
Why it matters
Context menu items registered with contexts: ['all'] appear on every right-click — blank page areas, the New Tab page, chrome:// settings, PDFs — cluttering the menu with options that cannot function in those contexts. Users right-clicking to copy text wade past irrelevant extension entries, and Chrome Web Store reviewers flag menu-spamming extensions as a policy concern under the single-purpose and minimal-permission guidelines. On pages where the extension has no host permission, clicking the item produces a silent no-op and looks broken.
Severity rationale
Info because over-broad contexts degrade polish and discoverability without breaking core functionality.
Remediation
Scope every chrome.contextMenus.create call to the narrowest context that makes sense: ['selection'] for text actions, ['image'] for image actions, ['link'] for link actions. Add documentUrlPatterns to exclude pages where the extension cannot operate. In background.js:
chrome.contextMenus.create({
id: 'search-selection',
title: 'Search "%s"',
contexts: ['selection'],
documentUrlPatterns: ['https://*/*', 'http://*/*'],
});
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.
Taxons
History
- 2026-04-18·v1.0.0·Initial import from extension-ux-performance·automated