Skip to content

Firefox support for addons.mozilla.org - #4

Merged
dhivadhiva merged 4 commits into
mainfrom
firefox-port
Nov 4, 2026
Merged

dhivadhiva merged 4 commits into
mainfrom
firefox-port

Conversation

@dhivadhiva

Copy link
Copy Markdown
Contributor

Closes #3

Changes

  • Build: node scripts/build.mjs --firefox writes dist/firefox. The manifest gets an event-page background, no offscreen permission, gecko id pasteguard@dhiva-labs, Firefox 140 minimum and data_collection_permissions: none. An esbuild __FIREFOX__ define removes the Firefox code from the Chrome bundles.
  • Packaging: npm run package:firefox makes dist/pasteguard-firefox-<v>.zip. npm run package:source makes the source archive that AMO requires for minified code.
  • Model host: the offscreen page runs in an iframe inside the Firefox background page, on the same runtime messages.
  • Vault: in Firefox, content scripts get their own site's vault with pg:vault:get and are told when it changes, because storage.session is closed to them there.
  • Rich-editor paste: synthetic paste data goes through the event's page view, so ProseMirror composers keep their line breaks in Firefox.
  • Extra sites: port-less match patterns in Firefox. permissions.onAdded finishes adding a site if the popup closes during the permission prompt.
  • Tests and docs: a headless Firefox e2e suite (npm run test:e2e:firefox), docs/BUILD_FIREFOX.md for AMO reviewers, and README and architecture notes.

The Chrome build has the same behaviour as before. Rebuilt without identifier minification, content.js, offscreen.js and options.js match main exactly. service-worker.js and popup.js differ only by a helper that returns the same ${origin}/* string.

Testing

  • Unit tests: npm test, 26/26.
  • Chrome e2e: npm run build:test && npm run test:e2e, 12/12.
  • Firefox e2e: npm run test:e2e:firefox on Firefox 157, 12/12. It checks:
    • a name, email and phone redacted through the iframe model
    • placeholder highlighting and copy restore
    • forget from the options page
    • a site added through permissions.onAdded
    • the model reloading after the background page suspends
    • no console errors in any context
  • Firefox 140 ESR: 11/12. The failing test is the "Protect this site" case: 140's WebDriver BiDi can't grant the origin permission.
  • Production zip in Firefox 157: the playground, name and email paste, ProseMirror line breaks, copy restore and the popup all work.
  • Lint: web-ext lint gives 0 errors and 3 warnings. Two are in onnxruntime-web's bundle; the third is the Android minimum version. All three are explained in BUILD_FIREFOX.md.
  • Reproducibility: the source archive, rebuilt in a clean directory (npm ci, fetch:model, build.mjs --firefox), matches the Firefox zip file for file.
  • Submission: submitted to addons.mozilla.org as pasteguard-ai, version 0.1.0, awaiting review.

`node scripts/build.mjs --firefox` writes dist/firefox with a Firefox
manifest: an event-page background, no offscreen permission, a gecko id,
Firefox 140 as the minimum and data_collection_permissions "none", which
addons.mozilla.org now requires of new add-ons. An esbuild __FIREFOX__
define selects the Firefox code paths, so the Chrome bundles drop them.

`package.mjs --firefox` zips it, and package-source.mjs builds the source
archive AMO asks for when the bundle is minified. It uses git archive
through a throwaway index, so uncommitted files are included and ignored
files (node_modules, dist, model weights) are not.

Refs: #3
- Model: Firefox has no offscreen documents, but its background page has
  a DOM. The model page runs there in an iframe and gets the same runtime
  messages. Its idle timer removes the frame, since an iframe can't close
  itself.
- Vault: content scripts can't read storage.session in Firefox
  (setAccessLevel is unsupported). The background answers pg:vault:get
  with the sender's own site's vault only, and sends pg:vault:changed to
  that site's tabs when it changes.
- Rich editors: Firefox ignores clipboardData in a synthetic paste's init
  and hides data a content script sets from the page. Write it through the
  event's wrappedJSObject, or ProseMirror composers drop line breaks.
- Extra sites: Firefox match patterns with a port never match, so the
  pattern covers the host on any port. permissions.onAdded finishes adding
  the site in case the popup closes when the permission prompt opens.

Refs: #3
Loads the Firefox test build over WebDriver BiDi and covers the paths
that differ from Chrome: model redaction from the background-page iframe,
vault handoff and copy restore, forget from the options page, sites added
through permissions.onAdded, the model reloading after the background page
suspends, and console errors from every context.

Refs: #3
BUILD_FIREFOX.md gives addons.mozilla.org reviewers the environment, the
three commands that rebuild the submitted package file for file, what
fetch:model downloads, where each packaged file comes from, and why the
lint warnings in onnxruntime-web's bundle are harmless.

Refs: #3
@dhivadhiva
dhivadhiva merged commit a184210 into main Nov 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firefox support for addons.mozilla.org

1 participant