mirror of
https://github.com/bitwarden/clients.git
synced 2026-06-04 21:04:29 +08:00
* add Claude guidance on injected content script exceptions * update CODEOWNERS * update CODEOWNERS * remove high-level Claude guidance * update CODEOWNERS * execute PR feedback * include all autofill content files in the rule
1.1 KiB
1.1 KiB
Browser Extension - Critical Rules
-
NEVER use
chrome.*orbrowser.*APIs directly in business logic- Always use
BrowserApiabstraction:/apps/browser/src/platform/browser/browser-api.ts - Required for cross-browser compatibility (Chrome/Firefox/Safari/Opera)
- Exception: injected content scripts (see
.claude/rules/autofill-content-scripts.md)
- Always use
-
ALWAYS use
BrowserApi.addListener()for event listeners in popup context- Safari requires manual cleanup to prevent memory leaks
- DON'T use native
chrome.*.addListener()orbrowser.*.addListener()directly
-
CRITICAL: Safari has tab query bugs
- Use
BrowserApi.tabsQueryFirstCurrentWindowForSafari()when querying current window tabs - Safari can return tabs from multiple windows incorrectly
- Use
Manifest V3
- Extension uses Web Extension API Manifest V3
- Service workers replace background pages
- Background context runs as service worker (can be terminated anytime)
- DON'T assume background page persists indefinitely
- Use message passing for communication between contexts
chrome.extension.getBackgroundPage()returnsnullin MV3