summaryrefslogtreecommitdiffstats
path: root/toolkit/components/telemetry/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/telemetry/tests/unit')
-rw-r--r--toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs7
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js58
-rw-r--r--toolkit/components/telemetry/tests/unit/xpcshell.toml1
3 files changed, 66 insertions, 0 deletions
diff --git a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs
index 0df6dfc2c1..1a4015df36 100644
--- a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs
+++ b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs
@@ -40,6 +40,8 @@ const PROFILE_RESET_DATE_MS = Date.now();
// The profile creation date, in milliseconds (Yesterday).
const PROFILE_FIRST_USE_MS = PROFILE_RESET_DATE_MS - MILLISECONDS_PER_DAY;
const PROFILE_CREATION_DATE_MS = PROFILE_FIRST_USE_MS - MILLISECONDS_PER_DAY;
+const PROFILE_RECOVERED_FROM_BACKUP =
+ PROFILE_RESET_DATE_MS - MILLISECONDS_PER_HOUR;
const GFX_VENDOR_ID = "0xabcd";
const GFX_DEVICE_ID = "0x1234";
@@ -126,6 +128,7 @@ export var TelemetryEnvironmentTesting = {
created: PROFILE_CREATION_DATE_MS,
reset: PROFILE_RESET_DATE_MS,
firstUse: PROFILE_FIRST_USE_MS,
+ recoveredFromBackup: PROFILE_RECOVERED_FROM_BACKUP,
}
);
},
@@ -392,6 +395,10 @@ export var TelemetryEnvironmentTesting = {
data.profile.firstUseDate,
truncateToDays(PROFILE_FIRST_USE_MS)
);
+ lazy.Assert.equal(
+ data.profile.recoveredFromBackup,
+ truncateToDays(PROFILE_RECOVERED_FROM_BACKUP)
+ );
},
checkPartnerSection(data, isInitial) {
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
index 9990d83fdf..ca43772a07 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -712,6 +712,64 @@ add_task(async function test_addons() {
await addon.uninstall();
});
+add_task(async function test_signedTheme() {
+ AddonTestUtils.useRealCertChecks = true;
+
+ const { PKCS7_WITH_SHA1, COSE_WITH_SHA256 } = Ci.nsIAppSignatureInfo;
+
+ const ADDON_THEME_INSTALL_URL = gDataRoot + "webext-implicit-id.xpi";
+ const ADDON_THEME_ID = "{46607a7b-1b2a-40ce-9afe-91cda52c46a6}";
+
+ // Install the theme.
+ let deferred = Promise.withResolvers();
+ TelemetryEnvironment.registerChangeListener(
+ "test_signedAddon",
+ deferred.resolve
+ );
+ let theme = await installXPIFromURL(ADDON_THEME_INSTALL_URL);
+ await theme.enable();
+ ok(theme.isActive, "Theme should be active");
+
+ // Install an extension to force the telemetry environment to be
+ // updated (currently theme add-ons changes do not seem to be
+ // notified as changes, see EnvironmentAddonBuilder _updateAddons
+ // method for how changes to the environment.addons property are
+ // being detected).
+ const ADDON_INSTALL_URL = gDataRoot + "amosigned.xpi";
+ let addon = await installXPIFromURL(ADDON_INSTALL_URL);
+
+ await deferred.promise;
+ TelemetryEnvironment.unregisterChangeListener("test_signedAddon");
+
+ let data = TelemetryEnvironment.currentEnvironment;
+ TelemetryEnvironmentTesting.checkEnvironmentData(data);
+
+ // Check signedState and signedTypes on active theme data
+ // (NOTE: other properties of active theme are technically
+ // not covered by any other test task in this xpcshell test).
+ Assert.equal(
+ data.addons.theme.id,
+ ADDON_THEME_ID,
+ "Theme should be in the environment."
+ );
+ Assert.equal(
+ data.addons.theme.signedState,
+ AddonManager.SIGNEDSTATE_SIGNED,
+ "Got expected signedState on activeTheme"
+ );
+ Assert.equal(
+ data.addons.theme.signedTypes,
+ JSON.stringify([COSE_WITH_SHA256, PKCS7_WITH_SHA1]),
+ "Got expected signedTypes on activeTheme"
+ );
+
+ AddonTestUtils.useRealCertChecks = false;
+ await addon.startupPromise;
+ await addon.uninstall();
+ await theme.startupPromise;
+ await theme.uninstall();
+});
+
add_task(async function test_signedAddon() {
AddonTestUtils.useRealCertChecks = true;
diff --git a/toolkit/components/telemetry/tests/unit/xpcshell.toml b/toolkit/components/telemetry/tests/unit/xpcshell.toml
index 0c660888ed..ea5f6f418c 100644
--- a/toolkit/components/telemetry/tests/unit/xpcshell.toml
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.toml
@@ -18,6 +18,7 @@ support-files = [
"testNoPDBAArch64.dll",
"!/toolkit/mozapps/extensions/test/xpcshell/head_addons.js",
"../../../../mozapps/extensions/test/xpinstall/amosigned.xpi",
+ "../../../../mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi",
]
generated-files = [
"system.xpi",