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/chromiumfolder or thedist/chromium.zipfile.
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:preferencesand 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:configand setbrowser.firefoxbridge.enabledtotrueand change the field inbrowser.firefoxbridge.extensionOriginsto “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.requiredtofalse - Set
extensions.experiments.enabledtotrue
To load the extension:
- Go to
about:debugging#/runtime/this-firefox - Click on "Load Temporary Add-on..."
- Select the
build/firefox/manifest.jsonfile. - Click
Inspectto 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
srcfolder contains theshared,_locales,firefox, andchromiumfolders. - The
chromiumandfirefoxfolders contain aninterfacesfolder that contains the interfaces for the shared logic. - Within shared files, imports from respective interfaces are done through the
Interfacesalias. This resolves to the correct interface at build time. - The
builddirectory holds the built extension and thedistfolder 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 buildto build the browser - Run
./mach runto 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.