Commit 87bd283c authored by Michael Kaply's avatar Michael Kaply
Browse files

Bug 1600007 - Check entire policy for empty objects. r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D55713

--HG--
extra : moz-landing-system : lando
parent f4d13636
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_empty_policy() {
await setupPolicyEngineWithJson({
policies: {
Certificates: {},
},
});
equal(
Services.policies.status,
Ci.nsIEnterprisePolicies.INACTIVE,
"Engine is not active"
);
});
......@@ -8,6 +8,7 @@ support-files =
[test_appupdateurl.js]
[test_clear_blocked_cookies.js]
[test_defaultbrowsercheck.js]
[test_empty_policy.js]
[test_extensions.js]
[test_extensionsettings.js]
[test_macosparser_unflatten.js]
......
......@@ -58,6 +58,20 @@ let env = Cc["@mozilla.org/process/environment;1"].getService(
);
const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
// We're only testing for empty objects, not
// empty strings.
function isEmptyObject(obj) {
if (Object.keys(obj).length === 0) {
return true;
}
for (let key of Object.keys(obj)) {
if (typeof obj[key] !== "object" || !isEmptyObject(obj[key])) {
return false;
}
}
return true;
}
function EnterprisePoliciesManager() {
Services.obs.addObserver(this, "profile-after-change", true);
Services.obs.addObserver(this, "final-ui-startup", true);
......@@ -443,7 +457,7 @@ class JSONPoliciesProvider {
get hasPolicies() {
return (
this._failed ||
(this._policies !== null && Object.keys(this._policies).length)
(this._policies !== null && !isEmptyObject(this._policies))
);
}
......@@ -554,7 +568,7 @@ class WindowsGPOPoliciesProvider {
}
get hasPolicies() {
return this._policies !== null && Object.keys(this._policies).length;
return this._policies !== null && !isEmptyObject(this._policies);
}
get policies() {
......
......@@ -3,7 +3,7 @@
"use strict";
add_task(async function test_app_update_URL() {
add_task(async function test_empty_toplevel() {
await setupPolicyEngineWithJson({
policies: {},
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment