How to run a Firefox instance with a temporary profile without jpm (jpm run) or web-ext (web-ext run)

  1. Create a temporary profile using firefox-profile.
    const FirefoxProfile = require("firefox-profile");
    new Promise((resolve, reject) => {
      let profile = new FirefoxProfile();
      profile.setPreference("devtools.chrome.enabled", true);
      // ..append preferences as you want..
      profile.updatePreferences();
    
      profile.encoded((zippedProfile) => {
        resolve(profile, zippedProfile);
        // Note: you can obtain profile directory by `profile.profileDir`!
      });
    });
  2. Run firefox instance using node-firefo-connect.
    const FxRunner = require("fx-runner/lib/run");
    FxRunner({
      "no-remote": true,
      "profile": profileDir, // profile.profileDir
      "env": process.env,
    });
    • Note: FxRunner returns a Promise object that is resolved just after the Firefox process starts.
      FxRunner({ /* ..snip.. */ }).then((results) => {
        /* Any Firefox window have not been open yet. */
        return new Promise((resolve, reject) => {
          require("timer").setTimeout(() => resolve(results), 1000);
        });
      }).then((results) => {
        /* Firefox window is already open. */
      });
  3. You do not have to delete the temporary profile. "firefox-profile" do it on process exit.

Example: Run firefox with remote debugging