Customizing Firefox – Disabling Safe Mode

NOTE: None of the methods documented in this post work anymore. The safe mode dialog was changed and I can find no way to prevent it from displaying.

I have one more post planned about customizing Firefox with add-ons and the CCK Wizard, but I wanted to get this out in the mean time.

A lot of people ask how to disable safe mode in Firefox in an enterprise environment. This post will tell you how to do it with an add-on.

In my previous post about Integrating Add-ons into Firefox, I talked about putting add-ons into the distribution/bundles directory. The important thing to realize about putting add-ons into this directory is they become a part of Firefox. They are not disabled when Firefox is placed into safe mode (and they shouldn’t be!). So we can build an add-on that disables safe mode and by placing it here, it will always be executed.

Unfortunately, we can’t completely remove the concept of safe mode. The code that makes safe mode happen is in C++ startup code, so we can’t mess with that. But we can make it so that when the safe mode dialog appears, it simply is ignored and the browser is restarted. We do that by overriding the safe mode dialog and forcing it to press the “Make Changes and Restart” button without actually making any changes.

This is a very simple add-on that will consist of two files. I’ll tell you exactly where to put them and where to name them.

Note: There is no need for an install.rdf when you put add-ons in distribution/bundles. (I just discovered this.) Also, it doesn’t matter what the directory is called under bundles.

chrome.manifest goes in distribution/bundles/disablesafemode and looks like this:

content disablesafemode content/

overlay chrome://browser/content/safeMode.xul chrome://disablesafemode/content/safeMode.xul

safeMode.xul goes in distribution/bundles/disablesafemode/content and looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<overlay xmlns="">
<dialog hidden="true" id="safeModeDialog" onload="onOK()"/>

You can test it by starting Firefox with the -safe-mode parameter or holding down the shift key on Windows or option key on Mac. You’ll see the safe mode window show up for a second (sized very small) and then the browser will restart.

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

37 thoughts on “Customizing Firefox – Disabling Safe Mode

  1. Why would you want to disable safe mode? If you just want to force the user to run particular add ons, then why not just have those add-ons in the distribution/bundles directory.

    The other features of safe mode are all about resetting to factory defaults. Would those defaults include any CCK customisations? If not, then they probably should.

    • > Why would you want to disable safe mode?

      “Ours is not to question why, Ours is but to do and die.”

      People ask me how to do things, I show them how to do them 🙂

      > If you just want to force the user to run particular add ons, then why not just have those add-ons in the distribution/bundles directory.

      I agree. That would be the right thing to do. But I also know there are cases where add-ons are placed in the browser in other ways than that and you don’t want a user to be able to disable them via safe mode. This solves that problem.

      > The other features of safe mode are all about resetting to factory defaults. Would those defaults include any CCK customisations? If not, then they probably should.

      It depends on how the CCK is installed. If you reset prefs, it would reset the CCK prefs and cause it to firstrun again.

  2. > “Ours is not to question why, Ours is but to do and die.”

    > People ask me how to do things, I show them how to do them 🙂

    I disagree. As a web developer, clients often ask me to implement strange solutions. Often, I find I can offer better suggestions if I just ask them why they want to do something. (of course if the answer is something like “my manager said so” or “corporate policy” then you’ve just got to go ahead and implement the sub-optimal solution anyway).

    • I’ll certainly recommend better solutions, but if a customer wants something done and they think they need it, I’ll build it for them.

      The core problem with safe mode is that Mozilla made it too easy. If it was just a command line option, I’d be fine with it.

      The problem is all it takes is holding down the shift key to enter safe mode on Windows.

      This means that even someone who doesn’t have access to the command line can enter safe mode.

      So if you have a kiosk, shift can be held when it restarts. Or you can mess with other types of locked down machines.

      I should be able to customize a machine and prevent a user from messing with it.

      • Just out of curiosity though, what does safe mode give a kiosk user that normal mode doesn’t? Do some kiosks use an add-on(s) to monitor time or data usage for charging users? I’ve only ever seen that done with platform-level custom software.

        • The issue would be somehow using safe mode to hack a kiosk. Perhaps to reset preferences, or disable things or something.

          I understand there are better ways to lock down a kiosk, but you want to prevent as much as possible.

          (and there are entire sites dedicated to hacking kiosks)

  3. I have a definite use case for disabling safe mode: I use Selenium Webdriver for testing websites, and it causes repeated Firefox windows to pop up while I’m trying to do other work. If I happen to have Shift held down at the time the firefox window pops up, it opens in Safe Mode and selenium won’t function. It would be very useful if Selenium could launch Firefox with Safe Mode disabled!

    (I’m linking this blog entry from the selenium bug on this issue,, in case it is helpful to the selenium devs…)

  4. Yes we recently ran into this problem with webDriver and Firefox too. you get something like this:
    org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host on port 7055 after 45000 ms. Firefox console output:
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Skipping unavailable install location app-system-local
    *** LOG addons.xpi: Skipping unavailable install location app-system-share

    i will try this workaround within the next days, but for now I’ll enjoy my much deserved weekend :>

    • The distribution/bundles directory doesn’t exist by default on Firefox.

      You can just create it in the directory where the Firefox executable is located. On Mac that is:


  5. I’ve put the xul file under ./MacOs/disablesafemode/content/safeMode.xul but that isn’t working.

    I think it can’t find the xul file. If I point my browser to chrome://disablesafemode/content/safeMode.xul it cannot find the file. If I enter chrome://browser/content/safeMode.xul it finds that one. Would chrome.manifest need to reference safeMode.xul differently on OS X?


    • The XUL file needs to be under MacOS/distribution/bundles/disablesafemode/content/safeMode.xul.

      Then you should be able to reference it.

  6. Hi Mike. Thanks for the quick replies. Sorry to be a pest, but it’s still not working for me. Looked over and over this for typos.

    I still get a 404 on chrome://disablesafemode/content/safeMode.xul

    This is my setup:

    $ less MacOS/distribution/bundles/disablesafemode/content/safeMode.xul

    $ less MacOS/chrome.manifest

    manifest components/binary.manifest

    content disablesafemode content/

    overlay chrome://browser/content/safeMode.xul chrome://disablesafemode/content/safeMode.xul

    • Ah, looks like the xml won’t go through. Probably isn’t that helpful for debugging anyways though.

        • Thanks! It looks like the bundle is registered. I don’t get a 404 browsing to chrome://disablesafemode/content/safeMode.xul anymore.

          Unfortunately it doesn’t seem to prevent the safemode popup from showing when running selenium tests like I was hoping. The combo of TotalTerminal, Selenium, and Firefox seems to always trigger safe mode. I’ll keep digging for an hour and report back, otherwise I’m giving up 🙁

          • So.. I’m no closer to getting this working. The extension seems to be there but if I hold down option when starting firefox I still get the safe mode modal.

            … But I did solve my problem with my selenium tests and TotalTerminal. TotalTerminal allows you to bring up a fullscreen terminal using a hotkey. I have KeyRemap4Macbook installed and configured to translate the eject key to Command+option+shift+whatever as my hotkey in TotalTerminal. The option key was what was causing the problem as I would use the terminal to start my tests, then press eject again to exit the terminal. I just ended up binding eject and TotalTerminal to F13 and all is well.

            Sorry if that’s a lot of detail, but I figured if I wound up on this page trying to solve this problem, someone else might too!

  7. Thank you. Works great. I can see FF restarting over and over until I release the shift key.

    This is a necessity for Windows 7 where you use the shift key to launch a new instance of applications pinned to the taskbar.

    (Edit suggestion, copy the instructions for creating the subdirectories here so it’s all in one spot.)

  8. I followed the instructions on OS X, Firefox 13.0.1 and when I start FF with the Option key pressed, FF crashes and I get the crash reporter window. If I start FF without Option pressed, it starts as usual. Any ideas?

  9. Unfortunately, you lost me at the line:

    chrome.manifest goes in distribution/bundles/disablesafemode

    because that “distribution” directory does not exist. Apparently I have to create it (?) but where do I create it? Can you be more explicit about this? I guess I don’t know as much as I thought! lol

    I am on Windows 7.

  10. Hello Mike,

    i’m from Germany and build currently a Windows-Kiosk-Terminal with Firefox. My Question: Can you tell me exactly what i have to do ?

    Create a folder named ‘distribution’ in the folder where the firefox executable is (e.g. C:\Progam Files\Mozilla Firefox\distribution)

    Create a folder named ‘bundles’ in the ‘distribution’-folder

    Create a folder named ‘disablesafemode’ in the ‘bundles’-folder

    Create a file named ‘chrome.manifest’ and put

    ‘content disablesafemode content/

    overlay chrome://browser/content/safeMode.xul

    into it

    Create a folder named ‘content’ in the ‘disablesafemode’-folder

    Create a file named ‘safeMode.xul’ and put

    into it.

    Is is right ? I have done so an it will not work. Can you help me ?

    Greets from Germany,

    • Unfortunately it appears that the safe mode dialog has been modified and there is no way to prevent entering safe mode.

      I’m still researching to see if I can figure out a new way.

  11. Easy solution. Don’t disable safe mode, just put all the same addons that prevent modifying things in regular mode in that directory you mention. That way Safe Mode is identical to regular mode.

    • Totally agree.

      But if you are installing third party add-ons, some of them don’t work properly in the distribution directory.

  12. I’ve used an add-on to hide the help menu option. Is there any way to prevent safemode while holding shift and restarting?

  13. Thanks a lot for this post Mike. Do you have any steps for the latest version of FirefoxPortable? The steps above doesn’t seem to work on it.

  14. Hey Mike. I have a bad habit of getting onto sites that I’ve been trying to avoid but can’t due to being able to start up firefox in safe mode with the shift key option. Is there any way I can block or disable myself from using safe mode in the newest version of firefox or is there a new version of CPPK Wizard coming out to help with that?

  15. Hey Mike,

    Just wanted to drop you a note that your method can still disable safe mode for FF v52.0.1, though it’s on my personal laptop. Not sure if it’s the same for enterprise environment…