A Chromium and Firefox extension that allows the user to open Firefox from Chromium quickly as well as open other browsers from Firefox.
- Firefox Nightly or Developer Edition 122+ (for the Firefox extension) or 126+ (to be able to launch pages in Firefox from the chromium extension)
- Some Chromium browser 97+
Run npm i
to install dependencies.
Run npm run build
to build the extension.
Warning
npm run build
requires python < 3.12. You may want to specify a different python version if your default python version is 3.12 or above: GLEAN_PYTHON=python3.11 npm run build
To see changes made to the extension, first build the extension, then reload the extension in the browser.
- Open your chromium browser
- Go to the extensions page (e.g.
chrome://extensions
) - Enable developer mode
- Click on "Load unpacked" and select the
build/chromium
folder or thedist/chromium.zip
file.
To see console logs, inspect the service worker.
To be able to launch pages in Firefox, native messaging must be enabled. To do so:
- Ensure you have Firefox Nightly v126 or later installed. You can find this out in
about:preferences
and search “Update” - Load the extension into your chromium browser and take note of the ID. It will look something like this:
ID: idlakildeggleoomlepepihnnilkckob
- On Firefox Nightly, navigate to
about:config
and setbrowser.firefoxbridge.enabled
totrue
and change the field inbrowser.firefoxbridge.extensionOrigins
to “chrome-extension://your-id-here
/“. - Completely close and reopen Firefox Nightly. Now, the native messaging host will be installed for that extension ID. If the incorrect ID is used or the configs are not set, then the extension will think Firefox is not installed.
Repeat step 2 & 4 any time the ID changes.
Since Firefox Bridge for Firefox uses experimental APIs, you will need to use Firefox Nightly or Beta, then:
- Open your Firefox browser
- Go to about:config
- Set
xpinstall.signatures.required
tofalse
- Set
extensions.experiments.enabled
totrue
To load the extension:
- Go to
about:debugging#/runtime/this-firefox
- Click on "Load Temporary Add-on..."
- Select the
build/firefox/manifest.json
file. - Click
Inspect
to see the console logs.
Run npm test
to run the tests.
The tests use the files in the build
folder. Since the shared logic is the same for both browsers, the shared tests are imported from the build/chromium
folder only.
Since the Firefox and Chromium extension has a lot of shared logic, but also independent logic, the build process is a bit complicated.
- The
src
folder contains theshared
,_locales
,firefox
, andchromium
folders. - The
chromium
andfirefox
folders contain aninterfaces
folder that contains the interfaces for the shared logic. - Within shared files, imports from respective interfaces are done through the
Interfaces
alias. This resolves to the correct interface at build time. - The
build
directory holds the built extension and thedist
folder holds the packaged versions.
In Firefox, we use experimental APIs to fetch which browsers are installed on the users computer as well as launch the browser without relying on the protocol handler. To learn more about the APIs, see the Experiments Documentation.
Due to the privileged-ness of the Firefox extension, we must use manifest V2, hence the lack of callbacks and browser.browserAction
vs browser.action
.
To develop the experimental APIs, you will need to install the Firefox source code and build the browser.
- Follow the instructions to install the Firefox source code.
- Navigate to
mozilla-unified/
- Run
./mach build
to build the browser - Run
./mach run
to run the browser - Follow the above instructions to load the extension in Firefox
Doing this, you will be able to have much more context in the console, including the ability to see the logs from the console.log
statements in api.js
.