blob: 14a9c92bc5b107c1669ea60fa1f82e940c55a9aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
ChromeUtils.defineESModuleGetters(this, {
UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs",
});
var updateService = Cc["@mozilla.org/updates/update-service;1"].getService(
Ci.nsIApplicationUpdateService
);
// This test is intended to ensure that nsIUpdateService::canCheckForUpdates
// is true before the "DisableAppUpdate" policy is applied. Testing that
// nsIUpdateService::canCheckForUpdates is false after the "DisableAppUpdate"
// policy is applied needs to occur in a different test since the policy does
// not properly take effect unless it is applied during application startup.
add_task(async function test_updates_pre_policy() {
// Turn off automatic update before we set app.update.disabledForTesting to
// false so that we don't cause an actual update.
let originalUpdateAutoValue = await UpdateUtils.getAppUpdateAutoEnabled();
await UpdateUtils.setAppUpdateAutoEnabled(false);
registerCleanupFunction(async () => {
await UpdateUtils.setAppUpdateAutoEnabled(originalUpdateAutoValue);
});
await SpecialPowers.pushPrefEnv({
set: [["app.update.disabledForTesting", false]],
});
is(
Services.policies.isAllowed("appUpdate"),
true,
"Since no policies have been set, appUpdate should be allowed by default"
);
is(
updateService.canCheckForUpdates,
true,
"Should be able to check for updates before any policies are in effect."
);
});
|