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.

21 Responses to “Disabling Safe Mode in Firefox 17”

  1. Live January 13, 2013 at 12:46 pm #

    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.

    • Mike Kaply January 20, 2013 at 2:57 pm #

      I'm surprised my old code is working for you, but if it is, that's great.

  2. Bill January 15, 2013 at 5:07 pm #

    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?

    • Mike Kaply January 20, 2013 at 2:57 pm #

      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.

      • Bill January 30, 2013 at 6:54 pm #

        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. Marco January 17, 2013 at 8:46 am #

    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

    • Mike Kaply January 20, 2013 at 2:55 pm #

      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. Josh January 20, 2013 at 12:22 pm #

    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?

    • Mike Kaply January 20, 2013 at 2:53 pm #

      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. Josh January 20, 2013 at 3:04 pm #

    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?

    • Mike Kaply January 20, 2013 at 3:11 pm #

      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. Josh January 20, 2013 at 3:28 pm #

    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.

    • Mike Kaply January 20, 2013 at 3:34 pm #

      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.

      • Josh January 20, 2013 at 3:43 pm #

        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. Chris January 31, 2013 at 4:22 am #

    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

    • Mike Kaply April 1, 2013 at 10:02 am #

      I'm going to do a new post on the safe mode thing since more people seem to be having problems. Hopefully I can be more clear there.

      • Bill April 25, 2013 at 6:41 pm #

        Thanks, Mike. Looking forward to your new post to clarify safe mode.

  8. Chris February 1, 2013 at 3:21 am #

    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. Patrick May 10, 2013 at 8:17 am #

    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

    • Mike Kaply May 13, 2013 at 9:03 am #

      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.

      • Patrick May 18, 2013 at 5:07 am #

        Thank you for checking!
        I'll wait for your new post.

Leave a Reply:

Gravatar Image