diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index f2abf21b2ae0..a4e2a87dc2cc 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -832,9 +832,6 @@ function buildHelpMenu() { document.getElementById("feedbackPage") .disabled = !Services.policies.isAllowed("feedbackCommands"); - document.getElementById("helpSafeMode") - .disabled = !Services.policies.isAllowed("safeMode"); - // Enable/disable the "Report Web Forgery" menu item. if (typeof gSafeBrowsing != "undefined") { gSafeBrowsing.setReportPhishingMenu(); diff --git a/browser/components/enterprisepolicies/Policies.jsm b/browser/components/enterprisepolicies/Policies.jsm index f1432f5e2073..1cb94dc573e4 100644 --- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -215,14 +215,6 @@ var Policies = { } }, - "DisableSafeMode": { - onBeforeUIStartup(manager, param) { - if (param) { - manager.disallowFeature("safeMode"); - } - } - }, - "DisableSysAddonUpdate": { onBeforeAddons(manager, param) { if (param) { diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json index 242d7e93777a..ab2d1a94d32b 100644 --- a/browser/components/enterprisepolicies/schemas/policies-schema.json +++ b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -170,13 +170,6 @@ "type": "boolean" }, - "DisableSafeMode": { - "description": "Prevents ability to restart in safe mode.", - "first_available": "60.0", - - "type": "boolean" - }, - "DisableSysAddonUpdate": { "description": "Prevent the browser from installing and updating system addons.", "first_available": "60.0", diff --git a/browser/components/enterprisepolicies/tests/browser/browser.ini b/browser/components/enterprisepolicies/tests/browser/browser.ini index bd1cc87d1cf8..93c19e69b4a6 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser.ini +++ b/browser/components/enterprisepolicies/tests/browser/browser.ini @@ -32,7 +32,6 @@ support-files = [browser_policy_disable_pdfjs.js] [browser_policy_disable_pocket.js] [browser_policy_disable_privatebrowsing.js] -[browser_policy_disable_safemode.js] [browser_policy_disable_shield.js] [browser_policy_display_bookmarks.js] [browser_policy_display_menu.js] diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_safemode.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_safemode.js deleted file mode 100644 index 87127dcb92e6..000000000000 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_safemode.js +++ /dev/null @@ -1,42 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ -"use strict"; - -add_task(async function setup() { - await setupPolicyEngineWithJson({ - "policies": { - "DisableSafeMode": true - } - }); -}); - -add_task(async function test_help_menu() { - buildHelpMenu(); - let safeModeMenu = document.getElementById("helpSafeMode"); - is(safeModeMenu.getAttribute("disabled"), "true", - "The `Restart with Add-ons Disabled...` item should be disabled"); -}); - -add_task(async function test_safemode_from_about_support() { - let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:support", false); - - await ContentTask.spawn(tab.linkedBrowser, null, async function() { - let button = content.document.getElementById("restart-in-safe-mode-button"); - is(button.getAttribute("disabled"), "true", - "The `Restart with Add-ons Disabled...` button should be disabled"); - }); - - await BrowserTestUtils.removeTab(tab); -}); - -add_task(async function test_safemode_from_about_profiles() { - let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:profiles", false); - - await ContentTask.spawn(tab.linkedBrowser, null, async function() { - let button = content.document.getElementById("restart-in-safe-mode-button"); - is(button.getAttribute("disabled"), "true", - "The `Restart with Add-ons Disabled...` button should be disabled"); - }); - - await BrowserTestUtils.removeTab(tab); -}); diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_cli_arguments.py b/testing/marionette/harness/marionette_harness/tests/unit/test_cli_arguments.py index ed1d035dd750..98bd688e5a61 100644 --- a/testing/marionette/harness/marionette_harness/tests/unit/test_cli_arguments.py +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_cli_arguments.py @@ -5,14 +5,6 @@ from __future__ import absolute_import import copy -import platform -try: - import winreg -except ImportError: - try: - import _winreg as winreg - except ImportError: - pass from marionette_harness import MarionetteTestCase @@ -42,36 +34,9 @@ class TestCommandLineArguments(MarionetteTestCase): return Services.appinfo.inSafeMode; """) + self.assertTrue(safe_mode, "Safe Mode has not been enabled") - def test_safe_mode_blocked_by_policy(self): - if platform.system() != 'Windows': - return - - reg_policies = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, "SOFTWARE\\Policies", 0, winreg.KEY_WRITE) - reg_mozilla = winreg.CreateKeyEx(reg_policies, "Mozilla", 0, winreg.KEY_WRITE) - reg_firefox = winreg.CreateKeyEx(reg_mozilla, "Firefox", 0, winreg.KEY_WRITE) - winreg.SetValueEx(reg_firefox, "DisableSafeMode", 0, winreg.REG_DWORD, 1) - - self.marionette.instance.app_args.append("-safe-mode") - - self.marionette.quit() - self.marionette.start_session() - - with self.marionette.using_context("chrome"): - safe_mode = self.marionette.execute_script(""" - Cu.import("resource://gre/modules/Services.jsm"); - - return Services.appinfo.inSafeMode; - """) - self.assertFalse(safe_mode, "Safe Mode has been enabled") - - winreg.CloseKey(reg_firefox) - winreg.DeleteKey(reg_mozilla, "Firefox") - winreg.CloseKey(reg_mozilla) - winreg.DeleteKey(reg_policies, "Mozilla") - winreg.CloseKey(reg_policies) - def test_startup_timeout(self): startup_timeout = self.marionette.startup_timeout diff --git a/toolkit/content/aboutProfiles.js b/toolkit/content/aboutProfiles.js index 9a9864d20b34..92a0a835101d 100644 --- a/toolkit/content/aboutProfiles.js +++ b/toolkit/content/aboutProfiles.js @@ -85,11 +85,7 @@ function refreshUI() { createButton.onclick = createProfileWizard; let restartSafeModeButton = document.getElementById("restart-in-safe-mode-button"); - if (Services.policies.isAllowed("safeMode")) { - restartSafeModeButton.onclick = function() { restart(true); }; - } else { - restartSafeModeButton.setAttribute("disabled", "true"); - } + restartSafeModeButton.onclick = function() { restart(true); }; let restartNormalModeButton = document.getElementById("restart-button"); restartNormalModeButton.onclick = function() { restart(false); }; diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 8981cf2337d9..28122ada5151 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -1207,9 +1207,6 @@ function populateActionBox() { $("safe-mode-box").style.display = "block"; $("action-box").style.display = "block"; } - if (!Services.policies.isAllowed("safeMode")) { - $("restart-in-safe-mode-button").setAttribute("disabled", "true"); - } } // Prompt user to restart the browser in safe mode diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 45dbd0a38493..838368d6f1d7 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -3154,40 +3154,6 @@ public: #endif }; -#ifdef XP_WIN -namespace { - -bool PolicyHasRegValue(HKEY aKey, LPCTSTR aName, DWORD* aValue) -{ - HKEY hkey = NULL; - LONG ret = RegOpenKeyExW(aKey, - L"SOFTWARE\\Policies\\Mozilla\\Firefox", 0, KEY_READ, &hkey); - if (ret != ERROR_SUCCESS) { - return false; - } - nsAutoRegKey key(hkey); - DWORD len = sizeof(aValue); - ret = RegQueryValueExW(hkey, aName, 0, NULL, (LPBYTE)aValue, &len); - RegCloseKey(key); - return ret == ERROR_SUCCESS; -} - -bool SafeModeBlockedByPolicy() -{ - LPCTSTR policyName = L"DisableSafeMode"; - DWORD value; - if (PolicyHasRegValue(HKEY_LOCAL_MACHINE, policyName, &value)) { - return value == 1; - } - if (PolicyHasRegValue(HKEY_CURRENT_USER, policyName, &value)) { - return value == 1; - } - return false; -} - -} // anonymous namespace -#endif // XP_WIN - /* * XRE_mainInit - Initial setup and command line parameter processing. * Main() will exit early if either return value != 0 or if aExitFlag is @@ -3524,6 +3490,12 @@ XREMain::XRE_mainInit(bool* aExitFlag) gRestartArgv[gRestartArgc] = nullptr; + if (EnvHasValue("MOZ_SAFE_MODE_RESTART")) { + gSafeMode = true; + // unset the env variable + SaveToEnv("MOZ_SAFE_MODE_RESTART="); + } + ar = CheckArg("safe-mode", true); if (ar == ARG_BAD) { PR_fprintf(PR_STDERR, "Error: argument --safe-mode is invalid when argument --osint is specified\n"); @@ -3553,20 +3525,6 @@ XREMain::XRE_mainInit(bool* aExitFlag) gSafeMode = true; #endif -#ifdef XP_WIN -if (gSafeMode && SafeModeBlockedByPolicy()) { - gSafeMode = false; - } -#endif - - // The Safe Mode Policy should not be enforced for the env var case - // (used by updater and crash-recovery). - if (EnvHasValue("MOZ_SAFE_MODE_RESTART")) { - gSafeMode = true; - // unset the env variable - SaveToEnv("MOZ_SAFE_MODE_RESTART="); - } - #ifdef XP_WIN { // Add CPU microcode version to the crash report as "CPUMicrocodeVersion".