Skip to content

Commit

Permalink
Fetch correct Firefox profile name based on WEB_EXT_FIREFOX env var
Browse files Browse the repository at this point in the history
  • Loading branch information
hecerinc committed Mar 15, 2021
1 parent bfca738 commit b331bf6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/react-devtools-extensions/firefox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The source code for this extension has moved to `shells/webextension`.

Modify the source code there and then rebuild this extension by running `node build` from this directory or `yarn run build:extension:firefox` from the root directory.
Modify the source code there and then rebuild this extension by running `node build` from this directory or `yarn run build:firefox` from the root directory.

## Testing in Firefox

Expand Down
21 changes: 20 additions & 1 deletion packages/react-devtools-extensions/firefox/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,32 @@ const {argv} = require('yargs');
const EXTENSION_PATH = resolve('./firefox/build/unpacked');
const START_URL = argv.url || 'https://reactjs.org/';

const ffVersion = process.env.WEB_EXT_FIREFOX;

const getFFProfileName = () => {
// Keys are pulled from https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#--firefox
// and profile names from https://searchfox.org/mozilla-central/source/toolkit/profile/xpcshell/head.js#96
switch (ffVersion) {
case 'firefox':
return 'default-release';
case 'beta':
return 'default-beta';
case 'nightly':
return 'default-nightly';
case 'firefoxdeveloperedition':
return 'dev-edition-default';
default:
return 'default';
}
};

const main = async () => {
const finder = new Finder();

// Use default Firefox profile for testing purposes.
// This prevents users from having to re-login-to sites before testing.
const findPathPromise = new Promise((resolvePromise, rejectPromise) => {
finder.getPath('default', (error, profile) => {
finder.getPath(getFFProfileName(), (error, profile) => {
if (error) {
rejectPromise(error);
} else {
Expand Down

0 comments on commit b331bf6

Please sign in to comment.