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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Test that the expected installTelemetryInfo are being set on the system addon
// installed/updated through Balrog.
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");
let distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "empty"], true);
registerDirectory("XREAppFeat", distroDir);
AddonTestUtils.usePrivilegedSignatures = id => "system";
add_task(() => initSystemAddonDirs());
add_task(async function test_addon_update() {
Services.prefs.setBoolPref(PREF_SYSTEM_ADDON_UPDATE_ENABLED, true);
// Define the set of initial conditions to run each test against:
// - setup: A task to setup the profile into the initial state.
// - initialState: The initial expected system add-on state after setup has run.
const initialSetup = {
async setup() {
await buildPrefilledUpdatesDir();
distroDir.leafName = "empty";
},
initialState: [
{ isUpgrade: false, version: null },
{ isUpgrade: true, version: "2.0" },
],
};
await setupSystemAddonConditions(initialSetup, distroDir);
const newlyInstalledSystemAddonId = "system1@tests.mozilla.org";
const updatedSystemAddonId = "system2@tests.mozilla.org";
const updateXML = buildSystemAddonUpdates([
// Newly installed system addon entry.
{
id: newlyInstalledSystemAddonId,
version: "1.0",
path: "system1_1.xpi",
xpi: await getSystemAddonXPI(1, "1.0"),
},
// Updated system addon entry.
{
id: updatedSystemAddonId,
version: "3.0",
path: "system2_3.xpi",
xpi: await getSystemAddonXPI(2, "3.0"),
},
]);
await Promise.all([
updateAllSystemAddons(updateXML),
promiseWebExtensionStartup(newlyInstalledSystemAddonId),
promiseWebExtensionStartup(updatedSystemAddonId),
]);
await verifySystemAddonState(
initialSetup.initialState,
[
{ isUpgrade: true, version: "1.0" },
{ isUpgrade: true, version: "3.0" },
{ isUpgrade: false, version: null },
{ isUpgrade: false, version: null },
{ isUpgrade: false, version: null },
],
false,
distroDir
);
const newlyInstalledSystemAddon = await AddonManager.getAddonByID(
newlyInstalledSystemAddonId
);
Assert.deepEqual(
newlyInstalledSystemAddon.installTelemetryInfo,
// For addons installed for the first time through the product addon checker
// we set a `method` in the telemetryInfo.
{ source: "system-addon", method: "product-updates" },
"Got the expected telemetry info on balrog system addon installed addon"
);
const updatedSystemAddon = await AddonManager.getAddonByID(
updatedSystemAddonId
);
Assert.deepEqual(
updatedSystemAddon.installTelemetryInfo,
// For addons that are distributed in Firefox, then updated through the product
// addon checker, `method` will not be set.
{ source: "system-addon" },
"Got the expected telemetry info on balrog system addon updated addon"
);
await promiseShutdownManager();
});
|