Write a WebExtension that behaves correctly on both Firefox and Chrome, handling API namespace and background-context differences

domain: developer.mozilla.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Use the browser.* Promise-based namespace as the primary API surface, matching Firefox's native model
  2. Bundle Mozilla's webextension-polyfill so browser.* calls also work under Chrome's chrome.*-only implementation
  3. For Manifest V3, check each browser's current 'background' manifest key expectations rather than assuming Chrome's service-worker model applies identically to Firefox
  4. Register event listeners synchronously at the top level of the background script so they survive suspension/restart under either model
  5. Persist state via storage APIs rather than in-memory globals, since the background context can be killed and restarted
  6. Cross-check MDN's 'Chrome incompatibilities' and cross-browser extension pages before relying on any one vendor's behavior

Known gotchas

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans