Disabling Safe Mode in Firefox 17

In an earlier post, I showed how to disable safe mode, but unfortunately that method doesn't work anymore. I've since discovered a way to disable safe mode. It's not as good as before, but it does work. I'm going to assume that you've read the earlier article as well as this article about customizing Firefox by writing a simple extension.

The original safe mode dialog has an option to ignore the choice to go into safe mode and just continue to start Firefox. The new dialog removed that option which is why it's a little more difficult to disable it.

So instead of doing what we did before and simply starting Firefox, we're going to tell the user that safe mode has been disabled and close Firefox. Here's how we do that.

First we need to override the built in dialog so we can show one of our own. to do that, you add this to a chrome.manifest:

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

Then we need to create a custom dialog. Here's the XUL for that:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        buttons=","
        onload="window.close()">
<description>
Safe Mode has been disabled.
</description>
</dialog>

Now when you try to start Firefox in safe mode, it will simple close the window and close Firefox.

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 *

25 thoughts on “Disabling Safe Mode in Firefox 17

  1. Hi Mike, I appreciate the time that you're making Firefox a better browser that the folks at Mozilla.

    I've tried your earlier post:

    http://mike.kaply.com/2012/04/10/customizing-firefox-disabling-safe-mode/

    my browser is FF 10. It worked like a charm. Then I upgraded to FF 18.

    This new version of Firefox, got even more dangerous, because the "Restart with Add-Ons Disabled" is always available.

    So I tried your new code above, sadly it doesn't work, it restarts finely with addons disabled - TOTAL SECURITY MESS, right?

    So I tried your OLD CODE again, then it's working for Firefox 18.0. Each time I restart with add-ons disabled, it will show a small window, where the user can't do anything but hit minimize or close. Then it doesn't launch the Safe Mode, viola - it's working!

    Am I missing something here?

    PS: I would also like to point out as an added security, to DISABLE Firefox Updates, you can do this by about:config >

    app.update.certs.1.commonName change it to something else.
    app.update.certs.2.commonName change it to something else.

    Thank you for your very nice efforts.

  2. This is great. I've been using firefox 3.6 because it is the latest version before they created the ability to enter safemode using the shift key. How can I (a computer novice) make these changes so I can use FF 17 again?

    • Why does safe mode prevent you from using Firefox 17? the changes to disable safe mode are pretty straightforward. Even a novice should be able to do them.

      • Then I guess you should call me a pre-novice because I don't know what a chrome.manifest is, etc and I would love to implement these changes.

  3. hi mike,

    great article about the safe mode! I have a question about an other function in firefox.

    we use firefox in a business environment and I can't disable the "click-to-play" feature. Is there any possibility to deactivate this?

    kind regards
    Marco

    • Click to Play is controlled by a preference - plugins.click_to_play

      If you set it to false, it should be disabled.

      You might be running into particular plugins that are disabled. This is usually security related.

  4. Hello Mike!

    Your information about this problem has been useful. The previous fixed worked very well.

    I can't figure how exactly does Firefox determine if Safe Mode should be enable or not.

    I tried adding the ~/.mozilla directory (which contains that profile directory) and the standalone firefox directory ~/firefox to Git version control and tried resetting the files to a healthy state before each Firefox startup, but Firefox still opened the Safe Mode dialog. It obviously stores a flag about this somewhere outside of these directories.

    Did you notice where Firefox stores that flag?

    • Firefox should only open safe mode if you hold the shift key or pass the -safe-mode paramter.

      I know of no other reason why it would open it by default.

  5. I looked into the relevant source code and found that if you set "toolkit.startup.max_resumed_crashes" to -1, then Firefox would never open the Safe Mode dialog. The setting's name should more appropriately read "toolkit.startup.max_crashes_before_safe_mode_invoked" or something similar.

    Wouldn't that be a better solution than the XUL hack?

    • We're talking about two different things.

      The safe mode dialog is the dialog that appears when you press the shift key when starting Firefox. It allows you to disable add-ons when you start Firefox.

      You are talking about the session resume page. And yes, that's how you disable that page.

  6. That isn't for the session resume page.
    The session resume page is controlled by: "browser.sessionstore.max_resumed_crashes"

    "toolkit.startup.max_resumed_crashes" is used for controlling when the Safe Mode dialog appears.

    • That preference only controls whether or not the safe mode dialog comes up when there are multiple start-up crashes.

      It doesn't prevent the display of the safe mode dialog with the -safe-mode parameter or the holding down of the Shift key.

      • It doesn't indeed prevent the Safe Mode dialog when using the Shift-key, but it disables the Safe Mode dialog caused by crashes, which is the problem I was trying to solve and your article was the first and only one that dealt with this problem.

        It doesn't disable the Safe Mode itself, which was your aim with the dialog overloads.

        In my case, the dialog was stopping automated usage of Firefox and getting rid of the Safe Mode dialog induced by crashes solves our problems.

        Thank you for your insight on the topic. Without your articles, we might not have discovered a solution to our own problem.

  7. Hi Mike,

    here's what I did for ESR 17.0.2.

    At first I created four directories (the root one next to the firefox.exe):
    distribution
    distribution/bundles
    distribution/bundles/disablesafemode
    distribution/bundles/disablesafemode/content

    Then I created the distribution/bundles/disablesafemode/chrome.manifest file and copied your "redirection" code into it. After that I created distribution/bundles/disablesafemode/content/safeMode.xul and copied your second code fragment into it.

    Fact is, for some reason Firefox won't read / execute the modified safeMode.xul so I'm left with the firefox.exe process still running--but at least no SafeMode window is shown.

    Any ideas how to fix that / make it work as intended?

    Regards,
    Chris

  8. Hi everybody,

    I was trying to implement the hacks Mike suggested above. Sadly, they didn't work me. So I tinkered around a little inside the browser's chrome examining possible candidates for the override to put in chrome.manifest.

    Oddly enough, just by putting the single line "override chrome://browser/content/safeMode.xul chrome://browser/content/safeMode.xul" in a chrome.manifest file seems to work in my case. The browser starts, seems to stall a bit without showing any window and finally shuts down the main process firefox.exe, i.e. the user has no way to run the browser in Safe Mode.

    Probably not very elegant but very efficient to me.

  9. Hi Mike,

    This worked great (as a very small addon) in FireFox 17 ESR.

    Today I started playing around with the beta version 21. Here this no longer works.

    I know the browser is still in a beta phase, but is there already something known about why this no longer works?

    Thanks, Patrick

    • This is probably because the distribution directory location has changed, but it has since changed back, so you should be OK with the official Firefox 21. I need to revisit disabling safe mode, so I'll do a new post soon.

  10. I have been checking in for some help on this also. Anything new? I really want to disable safe mode so I can't circumvent my Leechblock add-on settings so easily.

    I used the disabling tip you had kindly shared for Firefox 7 and it worked great, but I finally had to breakdown and update FF to the latest version (currently 22.0) because the old version was causing problems keeping up for other uses. Ugh.

    Thanks!