Backed out changeset 83dffebb1536 (bug 1440573) for bc failures on browser_policy_disable_safemode.js CLOSED TREE

This commit is contained in:
Brindusan Cristian 2018-03-16 05:15:39 +02:00
Родитель 603ddf6b44
Коммит ed15f7d5a4
9 изменённых файлов: 8 добавлений и 153 удалений

Просмотреть файл

@ -832,9 +832,6 @@ function buildHelpMenu() {
document.getElementById("feedbackPage") document.getElementById("feedbackPage")
.disabled = !Services.policies.isAllowed("feedbackCommands"); .disabled = !Services.policies.isAllowed("feedbackCommands");
document.getElementById("helpSafeMode")
.disabled = !Services.policies.isAllowed("safeMode");
// Enable/disable the "Report Web Forgery" menu item. // Enable/disable the "Report Web Forgery" menu item.
if (typeof gSafeBrowsing != "undefined") { if (typeof gSafeBrowsing != "undefined") {
gSafeBrowsing.setReportPhishingMenu(); gSafeBrowsing.setReportPhishingMenu();

Просмотреть файл

@ -215,14 +215,6 @@ var Policies = {
} }
}, },
"DisableSafeMode": {
onBeforeUIStartup(manager, param) {
if (param) {
manager.disallowFeature("safeMode");
}
}
},
"DisableSysAddonUpdate": { "DisableSysAddonUpdate": {
onBeforeAddons(manager, param) { onBeforeAddons(manager, param) {
if (param) { if (param) {

Просмотреть файл

@ -170,13 +170,6 @@
"type": "boolean" "type": "boolean"
}, },
"DisableSafeMode": {
"description": "Prevents ability to restart in safe mode.",
"first_available": "60.0",
"type": "boolean"
},
"DisableSysAddonUpdate": { "DisableSysAddonUpdate": {
"description": "Prevent the browser from installing and updating system addons.", "description": "Prevent the browser from installing and updating system addons.",
"first_available": "60.0", "first_available": "60.0",

Просмотреть файл

@ -32,7 +32,6 @@ support-files =
[browser_policy_disable_pdfjs.js] [browser_policy_disable_pdfjs.js]
[browser_policy_disable_pocket.js] [browser_policy_disable_pocket.js]
[browser_policy_disable_privatebrowsing.js] [browser_policy_disable_privatebrowsing.js]
[browser_policy_disable_safemode.js]
[browser_policy_disable_shield.js] [browser_policy_disable_shield.js]
[browser_policy_display_bookmarks.js] [browser_policy_display_bookmarks.js]
[browser_policy_display_menu.js] [browser_policy_display_menu.js]

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -5,14 +5,6 @@
from __future__ import absolute_import from __future__ import absolute_import
import copy import copy
import platform
try:
import winreg
except ImportError:
try:
import _winreg as winreg
except ImportError:
pass
from marionette_harness import MarionetteTestCase from marionette_harness import MarionetteTestCase
@ -42,36 +34,9 @@ class TestCommandLineArguments(MarionetteTestCase):
return Services.appinfo.inSafeMode; return Services.appinfo.inSafeMode;
""") """)
self.assertTrue(safe_mode, "Safe Mode has not been enabled") 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): def test_startup_timeout(self):
startup_timeout = self.marionette.startup_timeout startup_timeout = self.marionette.startup_timeout

Просмотреть файл

@ -85,11 +85,7 @@ function refreshUI() {
createButton.onclick = createProfileWizard; createButton.onclick = createProfileWizard;
let restartSafeModeButton = document.getElementById("restart-in-safe-mode-button"); let restartSafeModeButton = document.getElementById("restart-in-safe-mode-button");
if (Services.policies.isAllowed("safeMode")) { restartSafeModeButton.onclick = function() { restart(true); };
restartSafeModeButton.onclick = function() { restart(true); };
} else {
restartSafeModeButton.setAttribute("disabled", "true");
}
let restartNormalModeButton = document.getElementById("restart-button"); let restartNormalModeButton = document.getElementById("restart-button");
restartNormalModeButton.onclick = function() { restart(false); }; restartNormalModeButton.onclick = function() { restart(false); };

Просмотреть файл

@ -1207,9 +1207,6 @@ function populateActionBox() {
$("safe-mode-box").style.display = "block"; $("safe-mode-box").style.display = "block";
$("action-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 // Prompt user to restart the browser in safe mode

Просмотреть файл

@ -3154,40 +3154,6 @@ public:
#endif #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. * XRE_mainInit - Initial setup and command line parameter processing.
* Main() will exit early if either return value != 0 or if aExitFlag is * 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; 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); ar = CheckArg("safe-mode", true);
if (ar == ARG_BAD) { if (ar == ARG_BAD) {
PR_fprintf(PR_STDERR, "Error: argument --safe-mode is invalid when argument --osint is specified\n"); 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; gSafeMode = true;
#endif #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 #ifdef XP_WIN
{ {
// Add CPU microcode version to the crash report as "CPUMicrocodeVersion". // Add CPU microcode version to the crash report as "CPUMicrocodeVersion".