Open Bug 1604376 Opened 2 years ago Updated 4 months ago

add command-line option to create a temporary profile that is deleted on exit


(Toolkit :: Startup and Profile System, enhancement, P5)






(Reporter: pabs3, Unassigned)


Google Chromium has the --temp-profile command-line option to use a temp profile:

          Use a throw-away/temporary profile for this session.  This creates an entirely new user profile temporarily.  It is not the same as incognito mode.

It would be nice if Firefox had a similar option that would create a new profile in a temporary directory, start Firefox using that and delete the directory when Firefox exits.

I'm currently using the following shell script to work around this feature being missing in Firefox:

set -e
dir="$(mktemp --tmpdir --directory firefox-dev-XXXXXXXX)"
cleanup () { rm --recursive --force "$dir"; }
trap cleanup EXIT
firefox -no-remote -profile "$dir" "$@"

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: General → Startup and Profile System
Product: Firefox → Toolkit

That's almost what ./mach run is already doing, so it shouldn't be too hard to port.

Paul, what's your use case?

Flags: needinfo?(pabs3)

For situations where I don't want the cookies, addons etc to persist and for situations where I need to check if my profile is causing an issue that I am seeing.

Flags: needinfo?(pabs3)

Also feature parity with chromium would be nice, since that already has this simple feature.

Gathering a few notes in case it turns out to be something I could mentor.

  1. Extend nsToolkitProfileService::SelectStartupProfile to handle a new option --temp-profile to:
    1. Create a temporary directory;
    2. Use that directory;
    3. Cleanup the directory upon exit. <-- This is probably the difficult part.
  2. How can we unit/integration test this?
  3. How do we ensure that the directory is cleaned up even in case of crash?

I'm not sure how Chrome does this, probably worth looking that up before implementation.

One option for cleaning up would be to create a child process that waits until the parent process exits and then removes the profile. The exit notification could be via waiting for the profile lock to be released. Another option would be to create a pipe in the parent process and wait for EOF in the child process.

You need to log in before you can comment on or make changes to this bug.